API cleanup,
[CommonLispStat.git] / TODO.lisp
blob32b0718d2d70f2205448e3de4c30627fd018909a
1 ;;; -*- mode: lisp -*-
3 ;;; Time-stamp: <2009-04-03 17:37:08 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
9 ;;; progns... This file contains the current challenges to
10 ;;; solve, including a description of the setup and the work
11 ;;; to solve....
13 ;;; What is this talk of 'release'? Klingons do not make software
14 ;;; 'releases'. Our software 'escapes', leaving a bloody trail of
15 ;;; designers and quality assurance people in its wake.
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 = 79, failures = 7, errors = 15
26 (run-tests :suite 'lisp-stat-ut)
27 (describe (run-tests :suite 'lisp-stat-ut))
29 ;; FIXME: Example: currently not relevant, yet
30 ;; (describe (lift::run-test :test-case 'lisp-stat-unittests::create-proto
31 ;; :suite 'lisp-stat-unittests::lisp-stat-ut-proto))
33 (describe 'lisp-stat-ut)
35 (in-package :ls-user)
37 (progn ;; FIXME: Regression modeling (some data future-ish)
39 (defparameter *m* nil "holding variable.")
40 (def *m* (regression-model (list->vector-like iron) ;; BROKEN
41 (list->vector-like absorbtion)))
43 (def m (regression-model (list->vector-like iron)
44 (list->vector-like absorbtion) :print nil))
45 ;;Good
46 (send m :print)
47 (send m :own-slots)
48 (send m :own-methods)
49 ;; (lsos::ls-objects-methods m) ; bogus?
50 (send m :show)
52 (def m (regression-model (list->vector-like iron)
53 (list->vector-like absorbtion)))
55 (def m (regression-model (listoflists->matrix-like (list iron aluminum))
56 (list->vector-like absorbtion) :print nil))
58 (send m :compute)
59 (send m :sweep-matrix)
60 (format t "~%~A~%" (send m :sweep-matrix))
62 ;; need to get multiple-linear regression working (simple linear regr
63 ;; works)... to do this, we need to redo the whole numeric structure,
64 ;; I'm keeping these in as example of brokenness...
66 (send m :basis) ;; this should be positive?
67 (send m :coef-estimates) )
69 #+nil
70 (progn ;; FIXME: Need to clean up data examples, licenses, attributions, etc.
71 ;; The following breaks because we should use a package to hold
72 ;; configuration details, and this would be the only package outside
73 ;; of packages.lisp, as it holds the overall defsystem structure.
74 (load-data "iris.lsp") ;; (the above partially fixed).
75 (variables)
76 diabetes )
79 (progn ;; dataframe
81 (describe (lift::run-tests :suite 'lisp-stat-ut-dataframe))
82 (lift::run-tests :suite 'lisp-stat-ut-dataframe)
84 (describe
85 (lift::run-test
86 :test-case 'lisp-stat-unittests::create-proto
87 :suite 'lisp-stat-unittests::lisp-stat-ut-proto))
89 (defparameter *my-df-1*
90 (make-instance 'dataframe-array
91 :storage #2A((1 2 3 4 5)
92 (10 20 30 40 50))
93 :doc "This is an interesting dataframe-array"
94 :case-labels (list "x" "y")
95 :var-labels (list "a" "b" "c" "d" "e")))
97 (setf (dfref *my-df-1* 0 0) -1d0)
101 (make-dataframe #2A((1 2 3 4 5)
102 (10 20 30 40 50)))
104 (make-dataframe (rand 4 3))
107 (equalp (dataset
108 (make-instance 'dataframe-array
109 :storage #2A(('a 'b)
110 ('c 'd))))
111 #2A(('a 'b)
112 ('c 'd)) )
114 (equalp (dataset
115 (make-instance 'dataframe-array
116 :storage #2A((1 2)
117 (3 4))))
118 #2A((1 2)
119 (3 4)))
121 (equalp (dataset
122 (make-instance 'dataframe-array
123 :storage #2A((1d0 2d0)
124 (3d0 4d0))))
125 #2A((1d0 2d0)
126 (3d0 4d0)))
129 (defparameter *my-df-1*
130 (make-dataframe #2A((1 2 3 4 5)
131 (10 20 30 40 50))
132 :caselabels (list "x" "y")
133 :varlabels (list "a" "b" "c" "d" "e")
134 :doc "This is an interesting dataframe-array"))
136 (caselabels *my-df-1*)
137 (varlabels *my-df-1*)
140 (defparameter *my-df-2*
141 (make-instance 'dataframe-array
142 :storage
143 (make-array-from-listoflists
144 (cybertiggyr-dsv::load-escaped
145 "/media/disk/Desktop/sandbox/CLS.git/Data/example-mixed.csv"))
146 :doc "This is an interesting dataframe-array"))
147 #| :case-labels (list "x" "y")
148 :var-labels (list "a" "b" "c" "d" "e")
154 (progn ;; Data setup
156 (describe 'make-matrix)
158 (defparameter *indep-vars-2-matrix*
159 (make-matrix (length iron) 2
160 :initial-contents
161 (mapcar #'(lambda (x y)
162 (list (coerce x 'double-float)
163 (coerce y 'double-float)))
164 iron aluminum)))
167 (defparameter *dep-var*
168 (make-vector (length absorbtion)
169 :type :row
170 :initial-contents
171 (list
172 (mapcar #'(lambda (x) (coerce x 'double-float))
173 absorbtion))))
175 (make-dataframe *dep-var*)
176 (make-dataframe (transpose *dep-var*))
178 (defparameter *dep-var-int*
179 (make-vector (length absorbtion)
180 :type :row
181 :element-type 'integer
182 :initial-contents (list absorbtion)))
185 (defparameter *xv+1a*
186 (make-matrix
188 :initial-contents #2A((1d0 1d0)
189 (1d0 3d0)
190 (1d0 2d0)
191 (1d0 4d0)
192 (1d0 3d0)
193 (1d0 5d0)
194 (1d0 4d0)
195 (1d0 6d0))))
197 (defparameter *xv+1b*
198 (bind2
199 (ones 8 1)
200 (make-matrix
202 :initial-contents '((1d0)
203 (3d0)
204 (2d0)
205 (4d0)
206 (3d0)
207 (5d0)
208 (4d0)
209 (6d0)))
210 :by :column))
212 (m= *xv+1a* *xv+1b*) ; => T
214 (princ "Data Set up"))
219 (progn
220 ;; REVIEW: general Lisp use guidance
222 (fdefinition 'make-matrix)
223 (documentation 'make-matrix 'function)
225 #| Examples from CLHS, a bit of guidance.
227 ;; This function assumes its callers have checked the types of the
228 ;; arguments, and authorizes the compiler to build in that assumption.
229 (defun discriminant (a b c)
230 (declare (number a b c))
231 "Compute the discriminant for a quadratic equation."
232 (- (* b b) (* 4 a c))) => DISCRIMINANT
233 (discriminant 1 2/3 -2) => 76/9
235 ;; This function assumes its callers have not checked the types of the
236 ;; arguments, and performs explicit type checks before making any assumptions.
237 (defun careful-discriminant (a b c)
238 "Compute the discriminant for a quadratic equation."
239 (check-type a number)
240 (check-type b number)
241 (check-type c number)
242 (locally (declare (number a b c))
243 (- (* b b) (* 4 a c)))) => CAREFUL-DISCRIMINANT
244 (careful-discriminant 1 2/3 -2) => 76/9
252 (progn ;; FIXME: read data from CSV file. To do.
255 ;; challenge is to ensure that we get mixed arrays when we want them,
256 ;; and single-type (simple) arrays in other cases.
259 (defparameter *csv-num*
260 (cybertiggyr-dsv::load-escaped
261 #p"/media/disk/Desktop/sandbox/CLS.git/Data/example-numeric.csv"
262 :field-separator #\,
263 :trace T))
265 (nth 0 (nth 0 *csv-num*))
267 (defparameter *csv-num*
268 (cybertiggyr-dsv::load-escaped
269 #p"/media/disk/Desktop/sandbox/CLS.git/Data/example-numeric2.dsv"
270 :field-separator #\:))
272 (nth 0 (nth 0 *csv-num*))
275 ;; The handling of these types should be compariable to what we do for
276 ;; matrices, but without the numerical processing. i.e. mref, bind2,
277 ;; make-dataframe, and the class structure should be similar.
279 ;; With numerical data, there should be a straightforward mapping from
280 ;; the data.frame to a matrix. With categorical data (including
281 ;; dense categories such as doc-strings, as well as sparse categories
282 ;; such as binary data), we need to include metadata about ordering,
283 ;; coding, and such. So the structures should probably consider
285 ;; Using the CSV file:
287 (defun parse-number (s)
288 (let* ((*read-eval* nil)
289 (n (read-from-string s)))
290 (if (numberp n) n)))
292 (parse-number "34")
293 (parse-number "34 ")
294 (parse-number " 34")
295 (parse-number " 34 ")
297 (+ (parse-number "3.4") 3)
298 (parse-number "3.4 ")
299 (parse-number " 3.4")
300 (+ (parse-number " 3.4 ") 3)
302 (parse-number "a")
304 ;; (coerce "2.3" 'number) => ERROR
305 ;; (coerce "2" 'float) => ERROR
307 (defparameter *csv-num*
308 (cybertiggyr-dsv::load-escaped
309 #p"/media/disk/Desktop/sandbox/CLS.git/Data/example-numeric.csv"
310 :field-separator #\,
311 :filter #'parse-number
312 :trace T))
314 (nth 0 (nth 0 *csv-num*))
316 (defparameter *csv-num*
317 (cybertiggyr-dsv::load-escaped
318 #p"/media/disk/Desktop/sandbox/CLS.git/Data/example-numeric2.dsv"
319 :field-separator #\:
320 :filter #'parse-number))
322 (nth 0 (nth 0 *csv-num*))
324 ;; now we've got the DSV code in the codebase, auto-loaded I hope:
325 cybertiggyr-dsv:*field-separator*
326 (defparameter *example-numeric.csv*
327 (cybertiggyr-dsv:load-escaped "Data/example-numeric.csv"
328 :field-separator #\,))
329 *example-numeric.csv*
331 ;; the following fails because we've got a bit of string conversion
332 ;; to do. 2 thoughts: #1 modify dsv package, but mucking with
333 ;; encapsulation. #2 add a coercion tool (better, but potentially
334 ;; inefficient).
335 #+nil(coerce (nth 3 (nth 3 *example-numeric.csv*)) 'double-float)
337 ;; cases, simple to not so
338 (defparameter *test-string1* "1.2")
339 (defparameter *test-string2* " 1.2")
340 (defparameter *test-string3* " 1.2 ")
344 #+nil
345 (progn ;; experiments with GSL and the Lisp interface.
346 (asdf:oos 'asdf:load-op 'gsll)
347 (asdf:oos 'asdf:load-op 'gsll-tests)
349 ;; the following should be equivalent
350 (setf *t1* (LIST 6.18d0 6.647777777777779d0 6.18d0))
351 (setf *t2* (MULTIPLE-VALUE-LIST
352 (LET ((VEC
353 (gsll:make-marray 'DOUBLE-FLOAT
354 :INITIAL-CONTENTS '(-3.21d0 1.0d0 12.8d0)))
355 (WEIGHTS
356 (gsll:MAKE-MARRAY 'DOUBLE-FLOAT
357 :INITIAL-CONTENTS '(3.0d0 1.0d0 2.0d0))))
358 (LET ((MEAN (gsll:MEAN VEC)))
359 (LIST (gsll:ABSOLUTE-DEVIATION VEC)
360 (gsll:WEIGHTED-ABSOLUTE-DEVIATION VEC WEIGHTS)
361 (gsll:ABSOLUTE-DEVIATION VEC MEAN))))))
362 (eql *t1* *t2*)
364 ;; from (gsll:examples 'gsll::numerical-integration) ...
365 (gsll:integration-qng gsll::one-sine 0.0d0 PI)
367 (gsll:defun-single axpb (x) (+ (* 2 x) 3)) ;; a<-2, b<-3
368 (gsll:integration-qng axpb 1d0 2d0)
370 (let ((a 2)
371 (b 3))
372 (defun-single axpb2 (x) (+ (* a x) b)))
373 (gsll:integration-qng axpb2 1d0 2d0)
375 ;; BAD
376 ;; (gsll:integration-qng
377 ;; (let ((a 2)
378 ;; (b 3))
379 ;; (defun-single axpb2 (x) (+ (* a x) b)))
380 ;; 1d0 2d0)
382 ;; right, but weird expansion...
383 (gsll:integration-qng
384 (let ((a 2)
385 (b 3))
386 (defun axpb2 (x) (+ (* a x) b))
387 (gsll:def-single-function axpb2)
388 axpb2)
389 1d0 2d0)
391 ;; Linear least squares
393 (gsll:gsl-lookup "gsl_linalg_LU_decomp") ; => gsll:lu-decomposition
394 (gsll:gsl-lookup "gsl_linalg_LU_solve") ; => gsll:lu-solve
399 #+nil
400 (progn ;; philosophy time
402 (setf my-model (model :name "ex1"
403 :data-slots (list w x y z)
404 :param-slots (list alpha beta gamma)
405 :math-form (regression-model :formula '(= w (+ (* beta x)
406 (* alpha y)
407 (* gamma z)
408 normal-error))
409 :centrality 'median ; 'mean
412 #| or:
413 #R"W ~ x+ y + z "
416 (setf my-dataset (statistical-table :table data-frame-contents
417 :metadata (list (:case-names (list ))
418 (:var-names (list ))
419 (:documentation "string of doc"))))
421 (setf my-analysis (analysis
422 :model my-model
423 :data my-dataset
424 :parameter-map (pairing (model-param-slots my-model)
425 (data-var-names my-dataset))))
427 ;; ontological implications -- the analysis is an abstract class of
428 ;; data, model, and mapping between the model and data. The fit is
429 ;; the instantiation of such. This provides a statistical object
430 ;; computation theory which can be realized as "executable
431 ;; statistics" or "computable statistics".
432 (setf my-analysis (analyze my-fit
433 :estimation-method 'linear-least-squares-regression))
435 ;; one of the tricks here is that one needs to provide the structure
436 ;; from which to consider estimation, and more importantly, the
437 ;; validity of the estimation.
440 (setf linear-least-squares-regression
441 (estimation-method-definition
442 :variable-defintions ((list
443 ;; from MachLearn: supervised,
444 ;; unsupervised
445 :data-response-vars list-drv ; nil if unsup
447 :param-vars list-pv
448 :data-predictor-vars list-dpv
449 ;; nil in this case. these
450 ;; describe "out-of-box" specs
451 :hyper-vars list-hv))
452 :form '(regression-additive-error
453 :central-form (linear-form drv pv dpv)
454 :error-form 'normal-error)
455 :resulting-decision '(point-estimation interval-estimation)
456 :philosophy 'frequentist
457 :documentation "use least squares to fit a linear regression
458 model to data."))
460 (defparameter *statistical-philosophies*
461 '(frequentist bayesian fiducial decision-analysis)
462 "can be combined to build decision-making approaches and
463 characterizations")
465 (defparameter *decisions*
466 '(estimation selection testing)
467 "possible results from a...")
468 ;; is this really true? One can embedded hypothesis testing within
469 ;; estimation, as the hypothesis estimated to select. And
470 ;; categorical/continuous rear their ugly heads, but not really in
471 ;; an essential way.
473 (defparameter *ontology-of-decision-procedures*
474 (list :decisions
475 (list :estimation
476 (list :point
477 (list :maximum-likelihood
478 :minimum-entropy
479 :least-squares
480 :method-of-moments)
481 :interval
482 (list :maximum-likelihood
484 :testing
485 (list :fisherian
486 :neyman-pearson
487 (list :traditional
488 :bioequivalence-inversion)
489 :selection
490 (list :ranking
491 :top-k-of-n-select))
492 :parametric
493 :partially-parametric))
494 "start of ontology"))
497 ;;;; LM
499 (progn
501 (defparameter *y*
502 (make-vector
504 :type :row
505 :initial-contents '((1d0 2d0 3d0 4d0 5d0 6d0 7d0 8d0))))
508 (defparameter *xv+1*
509 (make-matrix
511 :initial-contents '((1d0 1d0)
512 (1d0 3d0)
513 (1d0 2d0)
514 (1d0 4d0)
515 (1d0 3d0)
516 (1d0 5d0)
517 (1d0 4d0)
518 (1d0 6d0))))
521 ;; so something like (NOTE: matrices are transposed to begin with, hence the incongruety)
522 (defparameter *xtx-2* (m* (transpose *xv+1*) *xv+1*))
523 ;; #<LA-SIMPLE-MATRIX-DOUBLE 2 x 2
524 ;; 8.0d0 28.0d0
525 ;; 28.0d0 116.0d0>
527 (defparameter *xty-2* (m* (transpose *xv+1*) (transpose *y*)))
528 ;; #<LA-SIMPLE-VECTOR-DOUBLE (2 x 1)
529 ;; 36.0d0
530 ;; 150.0d0>
532 (defparameter *rcond-2* 0.000001)
533 (defparameter *betahat-2* (gelsy *xtx-2* *xty-2* *rcond-2*))
534 ;; *xtx-2* => "details of complete orthogonal factorization"
535 ;; according to man page:
536 ;; #<LA-SIMPLE-MATRIX-DOUBLE 2 x 2
537 ;; -119.33147112141039d0 -29.095426104883202d0
538 ;; 0.7873402682880205d0 -1.20672274167718d0>
540 ;; *xty-2* => output becomes solution:
541 ;; #<LA-SIMPLE-VECTOR-DOUBLE (2 x 1)
542 ;; -0.16666666666668312d0
543 ;; 1.333333333333337d0>
545 *betahat-2* ; which matches R, see below
547 (documentation 'gelsy 'function)
550 ;; (#<LA-SIMPLE-VECTOR-DOUBLE (2 x 1)
551 ;; -0.16666666666668312 1.333333333333337>
552 ;; 2)
554 ;; ## Test case in R:
555 ;; x <- c( 1.0, 3.0, 2.0, 4.0, 3.0, 5.0, 4.0, 6.0)
556 ;; y <- c( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0)
557 ;; lm(y~x)
558 ;; ## => Call: lm(formula = y ~ x)
560 ;; Coefficients: (Intercept) x
561 ;; -0.1667 1.3333
563 ;; summary(lm(y~x))
564 ;; ## =>
566 ;; Call:
567 ;; lm(formula = y ~ x)
569 ;; Residuals:
570 ;; Min 1Q Median 3Q Max
571 ;; -1.833e+00 -6.667e-01 -3.886e-16 6.667e-01 1.833e+00
573 ;; Coefficients:
574 ;; Estimate Std. Error t value Pr(>|t|)
575 ;; (Intercept) -0.1667 1.1587 -0.144 0.89034
576 ;; x 1.3333 0.3043 4.382 0.00466 **
577 ;; ---
578 ;; Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
580 ;; Residual standard error: 1.291 on 6 degrees of freedom
581 ;; Multiple R-squared: 0.7619, Adjusted R-squared: 0.7222
582 ;; F-statistic: 19.2 on 1 and 6 DF, p-value: 0.004659
586 ;; which suggests one might do (modulo ensuring correct
587 ;; orientations). When this is finalized, it should migrate to
588 ;; CLS.
592 (defparameter *n* 20) ; # rows = # obsns
593 (defparameter *p* 10) ; # cols = # vars
594 (defparameter *x-temp* (rand *n* *p*))
595 (defparameter *b-temp* (rand *p* 1))
596 (defparameter *y-temp* (m* *x-temp* *b-temp*))
597 ;; so Y=Xb + \eps
598 (defparameter *rcond* (* (coerce (expt 2 -52) 'double-float)
599 (max (nrows *x-temp*) (ncols *y-temp*))))
600 (defparameter *orig-x* (copy *x-temp*))
601 (defparameter *orig-b* (copy *b-temp*))
602 (defparameter *orig-y* (copy *y-temp*))
604 (defparameter *lm-result* (lm *x-temp* *y-temp*))
605 (princ (first *lm-result*))
606 (princ (second *lm-result*))
607 (princ (third *lm-result*))
608 (v= (third *lm-result*)
609 (v- (first (first *lm-result*))
610 (first (second *lm-result*))))
615 ;; Some issues exist in the LAPACK vs. LINPACK variants, hence R
616 ;; uses LINPACK primarily, rather than LAPACK. See comments in R
617 ;; source for issues.
620 ;; Goal is to start from X, Y and then realize that if
621 ;; Y = X \beta, then, i.e. 8x1 = 8xp px1 + 8x1
622 ;; XtX \hat\beta = Xt Y
623 ;; so that we can solve the equation W \beta = Z where W and Z
624 ;; are known, to estimate \beta.
626 ;; the above is known to be numerically instable -- some processing
627 ;; of X is preferred and should be done prior. And most of the
628 ;; transformation-based work does precisely that.
630 ;; recall: Var[Y] = E[(Y - E[Y])(Y-E[Y])t]
631 ;; = E[Y Yt] - 2 \mu \mut + \mu \mut
632 ;; = E[Y Yt] - \mu \mut
634 ;; Var Y = E[Y^2] - \mu^2
637 ;; For initial estimates of covariance of \hat\beta:
639 ;; \hat\beta = (Xt X)^-1 Xt Y
640 ;; with E[ \hat\beta ]
641 ;; = E[ (Xt X)^-1 Xt Y ]
642 ;; = E[(Xt X)^-1 Xt (X\beta)]
643 ;; = \beta
645 ;; So Var[\hat\beta] = ...
646 ;; (Xt X)
647 ;; and this gives SE(\beta_i) = (* (sqrt (mref Var i i)) adjustment)
650 ;; from docs:
652 (setf *temp-result*
653 (let ((*default-implementation* :foreign-array))
654 (let* ((m 10)
655 (n 10)
656 (a (rand m n))
657 (x (rand n 1))
658 (b (m* a x))
659 (rcond (* (coerce (expt 2 -52) 'double-float)
660 (max (nrows a) (ncols a))))
661 (orig-a (copy a))
662 (orig-b (copy b))
663 (orig-x (copy x)))
664 (list x (gelsy a b rcond))
665 ;; no applicable conversion?
666 ;; (m- (#<FA-SIMPLE-VECTOR-DOUBLE (10 x 1))
667 ;; (#<FA-SIMPLE-VECTOR-DOUBLE (10 x 1)) )
668 (v- x (first (gelsy a b rcond))))))
671 (princ *temp-result*)
673 (setf *temp-result*
674 (let ((*default-implementation* :lisp-array))
675 (let* ((m 10)
676 (n 10)
677 (a (rand m n))
678 (x (rand n 1))
679 (b (m* a x))
680 (rcond (* (coerce (expt 2 -52) 'double-float)
681 (max (nrows a) (ncols a))))
682 (orig-a (copy a))
683 (orig-b (copy b))
684 (orig-x (copy x)))
685 (list x (gelsy a b rcond))
686 (m- x (first (gelsy a b rcond)))
688 (princ *temp-result*)
691 (defparameter *xv*
692 (make-vector
694 :type :row ;; default, not usually needed!
695 :initial-contents '((1d0 3d0 2d0 4d0 3d0 5d0 4d0 6d0))))
697 (defparameter *y*
698 (make-vector
700 :type :row
701 :initial-contents '((1d0 2d0 3d0 4d0 5d0 6d0 7d0 8d0))))
703 ;; so something like (NOTE: matrices are transposed to begin with, hence the incongruety)
704 (defparameter *xtx-1* (m* *xv* (transpose *xv*)))
705 (defparameter *xty-1* (m* *xv* (transpose *y*)))
706 (defparameter *rcond-in* (* (coerce (expt 2 -52) 'double-float)
707 (max (nrows *xtx-1*)
708 (ncols *xty-1*))))
710 (defparameter *betahat* (gelsy *xtx-1* *xty-1* *rcond-in*))
712 ;; (#<LA-SIMPLE-VECTOR-DOUBLE (1 x 1)
713 ;; 1.293103448275862>
714 ;; 1)
716 ;; ## Test case in R:
717 ;; x <- c( 1.0, 3.0, 2.0, 4.0, 3.0, 5.0, 4.0, 6.0)
718 ;; y <- c( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0)
719 ;; lm(y~x-1)
720 ;; ## =>
721 ;; Call:
722 ;; lm(formula = y ~ x - 1)
724 ;; Coefficients:
725 ;; x
726 ;; 1.293
728 (first *betahat*))
732 #+nil
733 (progn
735 (asdf:oos 'asdf:load-op 'cl-plplot)
737 (plot-ex))
741 (type-of #2A((1 2 3 4 5)
742 (10 20 30 40 50)))
744 (type-of (rand 10 20))
746 (typep #2A((1 2 3 4 5)
747 (10 20 30 40 50))
748 'matrix-like)
750 (typep (rand 10 20) 'matrix-like)
752 (typep #2A((1 2 3 4 5)
753 (10 20 30 40 50))
754 'array)
756 (typep (rand 10 20) 'array)