cleaned up data-clos tests and code. cleanly compiles.
[CommonLispStat.git] / TODO.lisp
blobfbbf7e55bb3c706d9d3c5564e4dff549e6e2a3ab
1 ;;; -*- mode: lisp -*-
3 ;;; Time-stamp: <2009-04-01 18:08:45 tony>
4 ;;; Creation: <2008-09-08 08:06:30 tony>
5 ;;; File: TODO.lisp
6 ;;; Author: AJ Rossini <blindglobe@gmail.com>
7 ;;; Copyright: (c) 2007-2008, AJ Rossini <blindglobe@gmail.com>. BSD.
8 ;;; Purpose: Stuff that needs to be made working sits inside the progns...
10 ;;; What is this talk of 'release'? Klingons do not make software
11 ;;; 'releases'. Our software 'escapes', leaving a bloody trail of
12 ;;; designers and quality assurance people in its wake.
14 ;;; This file contains the current challenges to solve, including a
15 ;;; description of the setup and the work to solve....
17 ;;; SET UP
19 (in-package :cl-user)
20 ;;(asdf:oos 'asdf:compile-op 'lispstat)
21 ;;(asdf:oos 'asdf:load-op 'lispstat)
23 (in-package :lisp-stat-unittests)
25 ;; tests = 80, failures = 7, errors = 17
27 (describe (run-tests :suite 'lisp-stat-ut))
28 (run-tests :suite 'lisp-stat-ut)
31 ;; FIXME: Example: currently not relevant, yet
32 (describe
33 (lift::run-test
34 :test-case 'lisp-stat-unittests::create-proto
35 :suite 'lisp-stat-unittests::lisp-stat-ut-proto))
38 (describe 'lisp-stat-ut)
39 (in-package :ls-user)
42 (progn ;; dataframe
44 (describe (lift::run-tests :suite 'lisp-stat-ut-dataclos))
45 (lift::run-tests :suite 'lisp-stat-ut-dataclos)
47 (describe
48 (lift::run-test
49 :test-case 'lisp-stat-unittests::create-proto
50 :suite 'lisp-stat-unittests::lisp-stat-ut-proto))
52 (defparameter *my-df-1*
53 (make-instance 'dataframe-array
54 :storage #2A((1 2 3 4 5)
55 (10 20 30 40 50))
56 :doc "This is an interesting dataframe-array"
57 :case-labels (list "x" "y")
58 :var-labels (list "a" "b" "c" "d" "e")))
60 (setf (dfref *my-df-1* 0 0) -1d0)
63 (make-dataframe #2A((1 2 3 4 5)
64 (10 20 30 40 50)))
66 (make-dataframe (rand 4 3))
69 (equalp (dataset
70 (make-instance 'dataframe-array
71 :storage #2A(('a 'b)
72 ('c 'd))))
73 #2A(('a 'b)
74 ('c 'd)) )
76 (equalp (dataset
77 (make-instance 'dataframe-array
78 :storage #2A((1 2)
79 (3 4))))
80 #2A((1 2)
81 (3 4)))
83 (equalp (dataset
84 (make-instance 'dataframe-array
85 :storage #2A((1d0 2d0)
86 (3d0 4d0))))
87 #2A((1d0 2d0)
88 (3d0 4d0)))
91 (defparameter *my-df-1*
92 (make-dataframe #2A((1 2 3 4 5)
93 (10 20 30 40 50))
94 :caselabels (list "x" "y")
95 :varlabels (list "a" "b" "c" "d" "e")
96 :doc "This is an interesting dataframe-array"))
98 (caselabels *my-df-1*)
99 (varlabels *my-df-1*)
102 (defparameter *my-df-2*
103 (make-instance 'dataframe-array
104 :storage
105 (make-array-from-listoflists
106 (cybertiggyr-dsv::load-escaped
107 "/media/disk/Desktop/sandbox/CLS.git/Data/example-mixed.csv"))
108 :doc "This is an interesting dataframe-array"))
109 #| :case-labels (list "x" "y")
110 :var-labels (list "a" "b" "c" "d" "e")
116 (progn ;; Data setup
118 (describe 'make-matrix)
120 (defparameter *indep-vars-2-matrix*
121 (make-matrix (length iron) 2
122 :initial-contents
123 (mapcar #'(lambda (x y)
124 (list (coerce x 'double-float)
125 (coerce y 'double-float)))
126 iron aluminum)))
129 (defparameter *dep-var*
130 (make-vector (length absorbtion)
131 :type :row
132 :initial-contents
133 (list
134 (mapcar #'(lambda (x) (coerce x 'double-float))
135 absorbtion))))
137 (make-dataframe *dep-var*)
138 (make-dataframe (transpose *dep-var*))
140 (defparameter *dep-var-int*
141 (make-vector (length absorbtion)
142 :type :row
143 :element-type 'integer
144 :initial-contents (list absorbtion)))
147 (defparameter *xv+1a*
148 (make-matrix
150 :initial-contents #2A((1d0 1d0)
151 (1d0 3d0)
152 (1d0 2d0)
153 (1d0 4d0)
154 (1d0 3d0)
155 (1d0 5d0)
156 (1d0 4d0)
157 (1d0 6d0))))
159 (defparameter *xv+1b*
160 (bind2
161 (ones 8 1)
162 (make-matrix
164 :initial-contents '((1d0)
165 (3d0)
166 (2d0)
167 (4d0)
168 (3d0)
169 (5d0)
170 (4d0)
171 (6d0)))
172 :by :column))
174 (m= *xv+1a* *xv+1b*) ; => T
176 (princ "Data Set up"))
181 (progn
182 ;; REVIEW: general Lisp use guidance
184 (fdefinition 'make-matrix)
185 (documentation 'make-matrix 'function)
187 #| Examples from CLHS, a bit of guidance.
189 ;; This function assumes its callers have checked the types of the
190 ;; arguments, and authorizes the compiler to build in that assumption.
191 (defun discriminant (a b c)
192 (declare (number a b c))
193 "Compute the discriminant for a quadratic equation."
194 (- (* b b) (* 4 a c))) => DISCRIMINANT
195 (discriminant 1 2/3 -2) => 76/9
197 ;; This function assumes its callers have not checked the types of the
198 ;; arguments, and performs explicit type checks before making any assumptions.
199 (defun careful-discriminant (a b c)
200 "Compute the discriminant for a quadratic equation."
201 (check-type a number)
202 (check-type b number)
203 (check-type c number)
204 (locally (declare (number a b c))
205 (- (* b b) (* 4 a c)))) => CAREFUL-DISCRIMINANT
206 (careful-discriminant 1 2/3 -2) => 76/9
211 #+nil
212 (progn ;; FIXME: Regression modeling
214 ;; data setup in previous FIXME
215 (defparameter *m* nil
216 "holding variable.")
217 ;; need to make vectors and matrices from the lists...
219 ;; BROKEN
220 (def *m* (regression-model (list->vector-like iron)
221 (list->vector-like absorbtion)))
223 (def m (regression-model (list->vector-like iron)
224 (list->vector-like absorbtion) :print nil))
225 ;;Good
226 (send m :print)
227 (send m :own-slots)
228 (send m :own-methods)
229 ;; (lsos::ls-objects-methods m) ; bogus?
230 (send m :show)
232 (def m (regression-model (list->vector-like iron)
233 (list->vector-like absorbtion)))
235 (def m (regression-model (listoflists->matrix-like (list iron aluminum))
236 (list->vector-like absorbtion) :print nil))
239 (send m :compute)
240 (send m :sweep-matrix)
241 (format t "~%~A~%" (send m :sweep-matrix))
243 ;; need to get multiple-linear regression working (simple linear regr
244 ;; works)... to do this, we need to redo the whole numeric structure,
245 ;; I'm keeping these in as example of brokenness...
247 (send m :basis) ;; this should be positive?
248 (send m :coef-estimates) )
250 #+nil
251 (progn ;; FIXME: Need to clean up data examples, licenses, attributions, etc.
252 ;; The following breaks because we should use a package to hold
253 ;; configuration details, and this would be the only package outside
254 ;; of packages.lisp, as it holds the overall defsystem structure.
255 (load-data "iris.lsp") ;; (the above partially fixed).
256 (variables)
257 diabetes )
262 (progn ;; FIXME: read data from CSV file. To do.
265 ;; challenge is to ensure that we get mixed arrays when we want them,
266 ;; and single-type (simple) arrays in other cases.
269 (defparameter *csv-num*
270 (cybertiggyr-dsv::load-escaped
271 #p"/media/disk/Desktop/sandbox/CLS.git/Data/example-numeric.csv"
272 :field-separator #\,
273 :trace T))
275 (nth 0 (nth 0 *csv-num*))
277 (defparameter *csv-num*
278 (cybertiggyr-dsv::load-escaped
279 #p"/media/disk/Desktop/sandbox/CLS.git/Data/example-numeric2.dsv"
280 :field-separator #\:))
282 (nth 0 (nth 0 *csv-num*))
285 ;; The handling of these types should be compariable to what we do for
286 ;; matrices, but without the numerical processing. i.e. mref, bind2,
287 ;; make-dataframe, and the class structure should be similar.
289 ;; With numerical data, there should be a straightforward mapping from
290 ;; the data.frame to a matrix. With categorical data (including
291 ;; dense categories such as doc-strings, as well as sparse categories
292 ;; such as binary data), we need to include metadata about ordering,
293 ;; coding, and such. So the structures should probably consider
295 ;; Using the CSV file:
297 (defun parse-number (s)
298 (let* ((*read-eval* nil)
299 (n (read-from-string s)))
300 (if (numberp n) n)))
302 (parse-number "34")
303 (parse-number "34 ")
304 (parse-number " 34")
305 (parse-number " 34 ")
307 (+ (parse-number "3.4") 3)
308 (parse-number "3.4 ")
309 (parse-number " 3.4")
310 (+ (parse-number " 3.4 ") 3)
312 (parse-number "a")
314 ;; (coerce "2.3" 'number) => ERROR
315 ;; (coerce "2" 'float) => ERROR
317 (defparameter *csv-num*
318 (cybertiggyr-dsv::load-escaped
319 #p"/media/disk/Desktop/sandbox/CLS.git/Data/example-numeric.csv"
320 :field-separator #\,
321 :filter #'parse-number
322 :trace T))
324 (nth 0 (nth 0 *csv-num*))
326 (defparameter *csv-num*
327 (cybertiggyr-dsv::load-escaped
328 #p"/media/disk/Desktop/sandbox/CLS.git/Data/example-numeric2.dsv"
329 :field-separator #\:
330 :filter #'parse-number))
332 (nth 0 (nth 0 *csv-num*))
334 ;; now we've got the DSV code in the codebase, auto-loaded I hope:
335 cybertiggyr-dsv:*field-separator*
336 (defparameter *example-numeric.csv*
337 (cybertiggyr-dsv:load-escaped "Data/example-numeric.csv"
338 :field-separator #\,))
339 *example-numeric.csv*
341 ;; the following fails because we've got a bit of string conversion
342 ;; to do. 2 thoughts: #1 modify dsv package, but mucking with
343 ;; encapsulation. #2 add a coercion tool (better, but potentially
344 ;; inefficient).
345 #+nil(coerce (nth 3 (nth 3 *example-numeric.csv*)) 'double-float)
347 ;; cases, simple to not so
348 (defparameter *test-string1* "1.2")
349 (defparameter *test-string2* " 1.2")
350 (defparameter *test-string3* " 1.2 ")
354 #+nil
355 (progn ;; experiments with GSL and the Lisp interface.
356 (asdf:oos 'asdf:load-op 'gsll)
357 (asdf:oos 'asdf:load-op 'gsll-tests)
359 ;; the following should be equivalent
360 (setf *t1* (LIST 6.18d0 6.647777777777779d0 6.18d0))
361 (setf *t2* (MULTIPLE-VALUE-LIST
362 (LET ((VEC
363 (gsll:make-marray 'DOUBLE-FLOAT
364 :INITIAL-CONTENTS '(-3.21d0 1.0d0 12.8d0)))
365 (WEIGHTS
366 (gsll:MAKE-MARRAY 'DOUBLE-FLOAT
367 :INITIAL-CONTENTS '(3.0d0 1.0d0 2.0d0))))
368 (LET ((MEAN (gsll:MEAN VEC)))
369 (LIST (gsll:ABSOLUTE-DEVIATION VEC)
370 (gsll:WEIGHTED-ABSOLUTE-DEVIATION VEC WEIGHTS)
371 (gsll:ABSOLUTE-DEVIATION VEC MEAN))))))
372 (eql *t1* *t2*)
374 ;; from (gsll:examples 'gsll::numerical-integration) ...
375 (gsll:integration-qng gsll::one-sine 0.0d0 PI)
377 (gsll:defun-single axpb (x) (+ (* 2 x) 3)) ;; a<-2, b<-3
378 (gsll:integration-qng axpb 1d0 2d0)
380 (let ((a 2)
381 (b 3))
382 (defun-single axpb2 (x) (+ (* a x) b)))
383 (gsll:integration-qng axpb2 1d0 2d0)
385 ;; BAD
386 ;; (gsll:integration-qng
387 ;; (let ((a 2)
388 ;; (b 3))
389 ;; (defun-single axpb2 (x) (+ (* a x) b)))
390 ;; 1d0 2d0)
392 ;; right, but weird expansion...
393 (gsll:integration-qng
394 (let ((a 2)
395 (b 3))
396 (defun axpb2 (x) (+ (* a x) b))
397 (gsll:def-single-function axpb2)
398 axpb2)
399 1d0 2d0)
401 ;; Linear least squares
403 (gsll:gsl-lookup "gsl_linalg_LU_decomp") ; => gsll:lu-decomposition
404 (gsll:gsl-lookup "gsl_linalg_LU_solve") ; => gsll:lu-solve
409 #+nil
410 (progn ;; philosophy time
412 (setf my-model (model :name "ex1"
413 :data-slots (list w x y z)
414 :param-slots (list alpha beta gamma)
415 :math-form (regression-model :formula '(= w (+ (* beta x)
416 (* alpha y)
417 (* gamma z)
418 normal-error))
419 :centrality 'median ; 'mean
422 #| or:
423 #R"W ~ x+ y + z "
426 (setf my-dataset (statistical-table :table data-frame-contents
427 :metadata (list (:case-names (list ))
428 (:var-names (list ))
429 (:documentation "string of doc"))))
431 (setf my-analysis (analysis
432 :model my-model
433 :data my-dataset
434 :parameter-map (pairing (model-param-slots my-model)
435 (data-var-names my-dataset))))
437 ;; ontological implications -- the analysis is an abstract class of
438 ;; data, model, and mapping between the model and data. The fit is
439 ;; the instantiation of such. This provides a statistical object
440 ;; computation theory which can be realized as "executable
441 ;; statistics" or "computable statistics".
442 (setf my-analysis (analyze my-fit
443 :estimation-method 'linear-least-squares-regression))
445 ;; one of the tricks here is that one needs to provide the structure
446 ;; from which to consider estimation, and more importantly, the
447 ;; validity of the estimation.
450 (setf linear-least-squares-regression
451 (estimation-method-definition
452 :variable-defintions ((list
453 ;; from MachLearn: supervised,
454 ;; unsupervised
455 :data-response-vars list-drv ; nil if unsup
457 :param-vars list-pv
458 :data-predictor-vars list-dpv
459 ;; nil in this case. these
460 ;; describe "out-of-box" specs
461 :hyper-vars list-hv))
462 :form '(regression-additive-error
463 :central-form (linear-form drv pv dpv)
464 :error-form 'normal-error)
465 :resulting-decision '(point-estimation interval-estimation)
466 :philosophy 'frequentist
467 :documentation "use least squares to fit a linear regression
468 model to data."))
470 (defparameter *statistical-philosophies*
471 '(frequentist bayesian fiducial decision-analysis)
472 "can be combined to build decision-making approaches and
473 characterizations")
475 (defparameter *decisions*
476 '(estimation selection testing)
477 "possible results from a...")
478 ;; is this really true? One can embedded hypothesis testing within
479 ;; estimation, as the hypothesis estimated to select. And
480 ;; categorical/continuous rear their ugly heads, but not really in
481 ;; an essential way.
483 (defparameter *ontology-of-decision-procedures*
484 (list :decisions
485 (list :estimation
486 (list :point
487 (list :maximum-likelihood
488 :minimum-entropy
489 :least-squares
490 :method-of-moments)
491 :interval
492 (list :maximum-likelihood
494 :testing
495 (list :fisherian
496 :neyman-pearson
497 (list :traditional
498 :bioequivalence-inversion)
499 :selection
500 (list :ranking
501 :top-k-of-n-select))
502 :parametric
503 :partially-parametric))
504 "start of ontology"))
507 ;;;; LM
509 (progn
511 (defparameter *y*
512 (make-vector
514 :type :row
515 :initial-contents '((1d0 2d0 3d0 4d0 5d0 6d0 7d0 8d0))))
518 (defparameter *xv+1*
519 (make-matrix
521 :initial-contents '((1d0 1d0)
522 (1d0 3d0)
523 (1d0 2d0)
524 (1d0 4d0)
525 (1d0 3d0)
526 (1d0 5d0)
527 (1d0 4d0)
528 (1d0 6d0))))
531 ;; so something like (NOTE: matrices are transposed to begin with, hence the incongruety)
532 (defparameter *xtx-2* (m* (transpose *xv+1*) *xv+1*))
533 ;; #<LA-SIMPLE-MATRIX-DOUBLE 2 x 2
534 ;; 8.0d0 28.0d0
535 ;; 28.0d0 116.0d0>
537 (defparameter *xty-2* (m* (transpose *xv+1*) (transpose *y*)))
538 ;; #<LA-SIMPLE-VECTOR-DOUBLE (2 x 1)
539 ;; 36.0d0
540 ;; 150.0d0>
542 (defparameter *rcond-2* 0.000001)
543 (defparameter *betahat-2* (gelsy *xtx-2* *xty-2* *rcond-2*))
544 ;; *xtx-2* => "details of complete orthogonal factorization"
545 ;; according to man page:
546 ;; #<LA-SIMPLE-MATRIX-DOUBLE 2 x 2
547 ;; -119.33147112141039d0 -29.095426104883202d0
548 ;; 0.7873402682880205d0 -1.20672274167718d0>
550 ;; *xty-2* => output becomes solution:
551 ;; #<LA-SIMPLE-VECTOR-DOUBLE (2 x 1)
552 ;; -0.16666666666668312d0
553 ;; 1.333333333333337d0>
555 *betahat-2* ; which matches R, see below
557 (documentation 'gelsy 'function)
560 ;; (#<LA-SIMPLE-VECTOR-DOUBLE (2 x 1)
561 ;; -0.16666666666668312 1.333333333333337>
562 ;; 2)
564 ;; ## Test case in R:
565 ;; x <- c( 1.0, 3.0, 2.0, 4.0, 3.0, 5.0, 4.0, 6.0)
566 ;; y <- c( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0)
567 ;; lm(y~x)
568 ;; ## => Call: lm(formula = y ~ x)
570 ;; Coefficients: (Intercept) x
571 ;; -0.1667 1.3333
573 ;; summary(lm(y~x))
574 ;; ## =>
576 ;; Call:
577 ;; lm(formula = y ~ x)
579 ;; Residuals:
580 ;; Min 1Q Median 3Q Max
581 ;; -1.833e+00 -6.667e-01 -3.886e-16 6.667e-01 1.833e+00
583 ;; Coefficients:
584 ;; Estimate Std. Error t value Pr(>|t|)
585 ;; (Intercept) -0.1667 1.1587 -0.144 0.89034
586 ;; x 1.3333 0.3043 4.382 0.00466 **
587 ;; ---
588 ;; Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
590 ;; Residual standard error: 1.291 on 6 degrees of freedom
591 ;; Multiple R-squared: 0.7619, Adjusted R-squared: 0.7222
592 ;; F-statistic: 19.2 on 1 and 6 DF, p-value: 0.004659
596 ;; which suggests one might do (modulo ensuring correct
597 ;; orientations). When this is finalized, it should migrate to
598 ;; CLS.
602 (defparameter *n* 20) ; # rows = # obsns
603 (defparameter *p* 10) ; # cols = # vars
604 (defparameter *x-temp* (rand *n* *p*))
605 (defparameter *b-temp* (rand *p* 1))
606 (defparameter *y-temp* (m* *x-temp* *b-temp*))
607 ;; so Y=Xb + \eps
608 (defparameter *rcond* (* (coerce (expt 2 -52) 'double-float)
609 (max (nrows *x-temp*) (ncols *y-temp*))))
610 (defparameter *orig-x* (copy *x-temp*))
611 (defparameter *orig-b* (copy *b-temp*))
612 (defparameter *orig-y* (copy *y-temp*))
614 (defparameter *lm-result* (lm *x-temp* *y-temp*))
615 (princ (first *lm-result*))
616 (princ (second *lm-result*))
617 (princ (third *lm-result*))
618 (v= (third *lm-result*)
619 (v- (first (first *lm-result*))
620 (first (second *lm-result*))))
625 ;; Some issues exist in the LAPACK vs. LINPACK variants, hence R
626 ;; uses LINPACK primarily, rather than LAPACK. See comments in R
627 ;; source for issues.
630 ;; Goal is to start from X, Y and then realize that if
631 ;; Y = X \beta, then, i.e. 8x1 = 8xp px1 + 8x1
632 ;; XtX \hat\beta = Xt Y
633 ;; so that we can solve the equation W \beta = Z where W and Z
634 ;; are known, to estimate \beta.
636 ;; the above is known to be numerically instable -- some processing
637 ;; of X is preferred and should be done prior. And most of the
638 ;; transformation-based work does precisely that.
640 ;; recall: Var[Y] = E[(Y - E[Y])(Y-E[Y])t]
641 ;; = E[Y Yt] - 2 \mu \mut + \mu \mut
642 ;; = E[Y Yt] - \mu \mut
644 ;; Var Y = E[Y^2] - \mu^2
647 ;; For initial estimates of covariance of \hat\beta:
649 ;; \hat\beta = (Xt X)^-1 Xt Y
650 ;; with E[ \hat\beta ]
651 ;; = E[ (Xt X)^-1 Xt Y ]
652 ;; = E[(Xt X)^-1 Xt (X\beta)]
653 ;; = \beta
655 ;; So Var[\hat\beta] = ...
656 ;; (Xt X)
657 ;; and this gives SE(\beta_i) = (* (sqrt (mref Var i i)) adjustment)
660 ;; from docs:
662 (setf *temp-result*
663 (let ((*default-implementation* :foreign-array))
664 (let* ((m 10)
665 (n 10)
666 (a (rand m n))
667 (x (rand n 1))
668 (b (m* a x))
669 (rcond (* (coerce (expt 2 -52) 'double-float)
670 (max (nrows a) (ncols a))))
671 (orig-a (copy a))
672 (orig-b (copy b))
673 (orig-x (copy x)))
674 (list x (gelsy a b rcond))
675 ;; no applicable conversion?
676 ;; (m- (#<FA-SIMPLE-VECTOR-DOUBLE (10 x 1))
677 ;; (#<FA-SIMPLE-VECTOR-DOUBLE (10 x 1)) )
678 (v- x (first (gelsy a b rcond))))))
681 (princ *temp-result*)
683 (setf *temp-result*
684 (let ((*default-implementation* :lisp-array))
685 (let* ((m 10)
686 (n 10)
687 (a (rand m n))
688 (x (rand n 1))
689 (b (m* a x))
690 (rcond (* (coerce (expt 2 -52) 'double-float)
691 (max (nrows a) (ncols a))))
692 (orig-a (copy a))
693 (orig-b (copy b))
694 (orig-x (copy x)))
695 (list x (gelsy a b rcond))
696 (m- x (first (gelsy a b rcond)))
698 (princ *temp-result*)
701 (defparameter *xv*
702 (make-vector
704 :type :row ;; default, not usually needed!
705 :initial-contents '((1d0 3d0 2d0 4d0 3d0 5d0 4d0 6d0))))
707 (defparameter *y*
708 (make-vector
710 :type :row
711 :initial-contents '((1d0 2d0 3d0 4d0 5d0 6d0 7d0 8d0))))
713 ;; so something like (NOTE: matrices are transposed to begin with, hence the incongruety)
714 (defparameter *xtx-1* (m* *xv* (transpose *xv*)))
715 (defparameter *xty-1* (m* *xv* (transpose *y*)))
716 (defparameter *rcond-in* (* (coerce (expt 2 -52) 'double-float)
717 (max (nrows *xtx-1*)
718 (ncols *xty-1*))))
720 (defparameter *betahat* (gelsy *xtx-1* *xty-1* *rcond-in*))
722 ;; (#<LA-SIMPLE-VECTOR-DOUBLE (1 x 1)
723 ;; 1.293103448275862>
724 ;; 1)
726 ;; ## Test case in R:
727 ;; x <- c( 1.0, 3.0, 2.0, 4.0, 3.0, 5.0, 4.0, 6.0)
728 ;; y <- c( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0)
729 ;; lm(y~x-1)
730 ;; ## =>
731 ;; Call:
732 ;; lm(formula = y ~ x - 1)
734 ;; Coefficients:
735 ;; x
736 ;; 1.293
738 (first *betahat*))
742 #+nil
743 (progn
745 (asdf:oos 'asdf:load-op 'cl-plplot)
747 (plot-ex))
751 (type-of #2A((1 2 3 4 5)
752 (10 20 30 40 50)))
754 (type-of (rand 10 20))
756 (typep #2A((1 2 3 4 5)
757 (10 20 30 40 50))
758 'matrix-like)
760 (typep (rand 10 20) 'matrix-like)
762 (typep #2A((1 2 3 4 5)
763 (10 20 30 40 50))
764 'array)
766 (typep (rand 10 20) 'array)