more slot-value to proto-slot-value fixes.
[CommonLispStat.git] / TODO.lisp
blob59e38cf6df7b6bf8a17b8ed6db9c4756a76edcc0
1 ;;; -*- mode: lisp -*-
3 ;;; Time-stamp: <2009-03-31 17:05:06 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 = 87, failures = 8, errors = 21
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 (make-dataframe #2A((1 2 3 4 5)
61 (10 20 30 40 50)))
63 (make-dataframe (rand 4 3))
66 (equalp (dataset
67 (make-instance 'dataframe-array
68 :storage #2A(('a 'b)
69 ('c 'd))))
70 #2A(('a 'b)
71 ('c 'd)) )
73 (equalp (dataset
74 (make-instance 'dataframe-array
75 :storage #2A((1 2)
76 (3 4))))
77 #2A((1 2)
78 (3 4)))
80 (equalp (dataset
81 (make-instance 'dataframe-array
82 :storage #2A((1d0 2d0)
83 (3d0 4d0))))
84 #2A((1d0 2d0)
85 (3d0 4d0)))
88 (defparameter *my-df-1*
89 (make-dataframe #2A((1 2 3 4 5)
90 (10 20 30 40 50))
91 :caselabels (list "x" "y")
92 :varlabels (list "a" "b" "c" "d" "e")
93 :doc "This is an interesting dataframe-array"))
95 (caselabels *my-df-1*)
96 (varlabels *my-df-1*)
99 (defparameter *my-df-2*
100 (make-instance 'dataframe-array
101 :storage
102 (make-array-from-listoflists
103 (cybertiggyr-dsv::load-escaped
104 "/media/disk/Desktop/sandbox/CLS.git/Data/example-mixed.csv"))
105 :doc "This is an interesting dataframe-array"))
106 #| :case-labels (list "x" "y")
107 :var-labels (list "a" "b" "c" "d" "e")
113 (progn ;; Data setup
115 (describe 'make-matrix)
117 (defparameter *indep-vars-2-matrix*
118 (make-matrix (length iron) 2
119 :initial-contents
120 (mapcar #'(lambda (x y)
121 (list (coerce x 'double-float)
122 (coerce y 'double-float)))
123 iron aluminum)))
126 (defparameter *dep-var*
127 (make-vector (length absorbtion)
128 :type :row
129 :initial-contents
130 (list
131 (mapcar #'(lambda (x) (coerce x 'double-float))
132 absorbtion))))
134 (make-dataframe *dep-var*)
135 (make-dataframe (transpose *dep-var*))
137 (defparameter *dep-var-int*
138 (make-vector (length absorbtion)
139 :type :row
140 :element-type 'integer
141 :initial-contents (list absorbtion)))
144 (defparameter *xv+1a*
145 (make-matrix
147 :initial-contents #2A((1d0 1d0)
148 (1d0 3d0)
149 (1d0 2d0)
150 (1d0 4d0)
151 (1d0 3d0)
152 (1d0 5d0)
153 (1d0 4d0)
154 (1d0 6d0))))
156 (defparameter *xv+1b*
157 (bind2
158 (ones 8 1)
159 (make-matrix
161 :initial-contents '((1d0)
162 (3d0)
163 (2d0)
164 (4d0)
165 (3d0)
166 (5d0)
167 (4d0)
168 (6d0)))
169 :by :column))
171 (m= *xv+1a* *xv+1b*) ; => T
173 (princ "Data Set up"))
178 (progn
179 ;; REVIEW: general Lisp use guidance
181 (fdefinition 'make-matrix)
182 (documentation 'make-matrix 'function)
184 #| Examples from CLHS, a bit of guidance.
186 ;; This function assumes its callers have checked the types of the
187 ;; arguments, and authorizes the compiler to build in that assumption.
188 (defun discriminant (a b c)
189 (declare (number a b c))
190 "Compute the discriminant for a quadratic equation."
191 (- (* b b) (* 4 a c))) => DISCRIMINANT
192 (discriminant 1 2/3 -2) => 76/9
194 ;; This function assumes its callers have not checked the types of the
195 ;; arguments, and performs explicit type checks before making any assumptions.
196 (defun careful-discriminant (a b c)
197 "Compute the discriminant for a quadratic equation."
198 (check-type a number)
199 (check-type b number)
200 (check-type c number)
201 (locally (declare (number a b c))
202 (- (* b b) (* 4 a c)))) => CAREFUL-DISCRIMINANT
203 (careful-discriminant 1 2/3 -2) => 76/9
208 #+nil
209 (progn ;; FIXME: Regression modeling
211 ;; data setup in previous FIXME
212 (defparameter *m* nil
213 "holding variable.")
214 ;; need to make vectors and matrices from the lists...
216 ;; BROKEN
217 (def *m* (regression-model (list->vector-like iron)
218 (list->vector-like absorbtion)))
220 (def m (regression-model (list->vector-like iron)
221 (list->vector-like absorbtion) :print nil))
222 ;;Good
223 (send m :print)
224 (send m :own-slots)
225 (send m :own-methods)
226 ;; (lsos::ls-objects-methods m) ; bogus?
227 (send m :show)
229 (def m (regression-model (list->vector-like iron)
230 (list->vector-like absorbtion)))
232 (def m (regression-model (listoflists->matrix-like (list iron aluminum))
233 (list->vector-like absorbtion) :print nil))
236 (send m :compute)
237 (send m :sweep-matrix)
238 (format t "~%~A~%" (send m :sweep-matrix))
240 ;; need to get multiple-linear regression working (simple linear regr
241 ;; works)... to do this, we need to redo the whole numeric structure,
242 ;; I'm keeping these in as example of brokenness...
244 (send m :basis) ;; this should be positive?
245 (send m :coef-estimates) )
247 #+nil
248 (progn ;; FIXME: Need to clean up data examples, licenses, attributions, etc.
249 ;; The following breaks because we should use a package to hold
250 ;; configuration details, and this would be the only package outside
251 ;; of packages.lisp, as it holds the overall defsystem structure.
252 (load-data "iris.lsp") ;; (the above partially fixed).
253 (variables)
254 diabetes )
259 (progn ;; FIXME: read data from CSV file. To do.
262 ;; challenge is to ensure that we get mixed arrays when we want them,
263 ;; and single-type (simple) arrays in other cases.
266 (defparameter *csv-num*
267 (cybertiggyr-dsv::load-escaped
268 #p"/media/disk/Desktop/sandbox/CLS.git/Data/example-numeric.csv"
269 :field-separator #\,
270 :trace T))
272 (nth 0 (nth 0 *csv-num*))
274 (defparameter *csv-num*
275 (cybertiggyr-dsv::load-escaped
276 #p"/media/disk/Desktop/sandbox/CLS.git/Data/example-numeric2.dsv"
277 :field-separator #\:))
279 (nth 0 (nth 0 *csv-num*))
282 ;; The handling of these types should be compariable to what we do for
283 ;; matrices, but without the numerical processing. i.e. mref, bind2,
284 ;; make-dataframe, and the class structure should be similar.
286 ;; With numerical data, there should be a straightforward mapping from
287 ;; the data.frame to a matrix. With categorical data (including
288 ;; dense categories such as doc-strings, as well as sparse categories
289 ;; such as binary data), we need to include metadata about ordering,
290 ;; coding, and such. So the structures should probably consider
292 ;; Using the CSV file:
294 (defun parse-number (s)
295 (let* ((*read-eval* nil)
296 (n (read-from-string s)))
297 (if (numberp n) n)))
299 (parse-number "34")
300 (parse-number "34 ")
301 (parse-number " 34")
302 (parse-number " 34 ")
304 (+ (parse-number "3.4") 3)
305 (parse-number "3.4 ")
306 (parse-number " 3.4")
307 (+ (parse-number " 3.4 ") 3)
309 (parse-number "a")
311 ;; (coerce "2.3" 'number) => ERROR
312 ;; (coerce "2" 'float) => ERROR
314 (defparameter *csv-num*
315 (cybertiggyr-dsv::load-escaped
316 #p"/media/disk/Desktop/sandbox/CLS.git/Data/example-numeric.csv"
317 :field-separator #\,
318 :filter #'parse-number
319 :trace T))
321 (nth 0 (nth 0 *csv-num*))
323 (defparameter *csv-num*
324 (cybertiggyr-dsv::load-escaped
325 #p"/media/disk/Desktop/sandbox/CLS.git/Data/example-numeric2.dsv"
326 :field-separator #\:
327 :filter #'parse-number))
329 (nth 0 (nth 0 *csv-num*))
331 ;; now we've got the DSV code in the codebase, auto-loaded I hope:
332 cybertiggyr-dsv:*field-separator*
333 (defparameter *example-numeric.csv*
334 (cybertiggyr-dsv:load-escaped "Data/example-numeric.csv"
335 :field-separator #\,))
336 *example-numeric.csv*
338 ;; the following fails because we've got a bit of string conversion
339 ;; to do. 2 thoughts: #1 modify dsv package, but mucking with
340 ;; encapsulation. #2 add a coercion tool (better, but potentially
341 ;; inefficient).
342 #+nil(coerce (nth 3 (nth 3 *example-numeric.csv*)) 'double-float)
344 ;; cases, simple to not so
345 (defparameter *test-string1* "1.2")
346 (defparameter *test-string2* " 1.2")
347 (defparameter *test-string3* " 1.2 ")
351 #+nil
352 (progn ;; experiments with GSL and the Lisp interface.
353 (asdf:oos 'asdf:load-op 'gsll)
354 (asdf:oos 'asdf:load-op 'gsll-tests)
356 ;; the following should be equivalent
357 (setf *t1* (LIST 6.18d0 6.647777777777779d0 6.18d0))
358 (setf *t2* (MULTIPLE-VALUE-LIST
359 (LET ((VEC
360 (gsll:make-marray 'DOUBLE-FLOAT
361 :INITIAL-CONTENTS '(-3.21d0 1.0d0 12.8d0)))
362 (WEIGHTS
363 (gsll:MAKE-MARRAY 'DOUBLE-FLOAT
364 :INITIAL-CONTENTS '(3.0d0 1.0d0 2.0d0))))
365 (LET ((MEAN (gsll:MEAN VEC)))
366 (LIST (gsll:ABSOLUTE-DEVIATION VEC)
367 (gsll:WEIGHTED-ABSOLUTE-DEVIATION VEC WEIGHTS)
368 (gsll:ABSOLUTE-DEVIATION VEC MEAN))))))
369 (eql *t1* *t2*)
371 ;; from (gsll:examples 'gsll::numerical-integration) ...
372 (gsll:integration-qng gsll::one-sine 0.0d0 PI)
374 (gsll:defun-single axpb (x) (+ (* 2 x) 3)) ;; a<-2, b<-3
375 (gsll:integration-qng axpb 1d0 2d0)
377 (let ((a 2)
378 (b 3))
379 (defun-single axpb2 (x) (+ (* a x) b)))
380 (gsll:integration-qng axpb2 1d0 2d0)
382 ;; BAD
383 ;; (gsll:integration-qng
384 ;; (let ((a 2)
385 ;; (b 3))
386 ;; (defun-single axpb2 (x) (+ (* a x) b)))
387 ;; 1d0 2d0)
389 ;; right, but weird expansion...
390 (gsll:integration-qng
391 (let ((a 2)
392 (b 3))
393 (defun axpb2 (x) (+ (* a x) b))
394 (gsll:def-single-function axpb2)
395 axpb2)
396 1d0 2d0)
398 ;; Linear least squares
400 (gsll:gsl-lookup "gsl_linalg_LU_decomp") ; => gsll:lu-decomposition
401 (gsll:gsl-lookup "gsl_linalg_LU_solve") ; => gsll:lu-solve
406 #+nil
407 (progn ;; philosophy time
409 (setf my-model (model :name "ex1"
410 :data-slots (list w x y z)
411 :param-slots (list alpha beta gamma)
412 :math-form (regression-model :formula '(= w (+ (* beta x)
413 (* alpha y)
414 (* gamma z)
415 normal-error))
416 :centrality 'median ; 'mean
419 #| or:
420 #R"W ~ x+ y + z "
423 (setf my-dataset (statistical-table :table data-frame-contents
424 :metadata (list (:case-names (list ))
425 (:var-names (list ))
426 (:documentation "string of doc"))))
428 (setf my-analysis (analysis
429 :model my-model
430 :data my-dataset
431 :parameter-map (pairing (model-param-slots my-model)
432 (data-var-names my-dataset))))
434 ;; ontological implications -- the analysis is an abstract class of
435 ;; data, model, and mapping between the model and data. The fit is
436 ;; the instantiation of such. This provides a statistical object
437 ;; computation theory which can be realized as "executable
438 ;; statistics" or "computable statistics".
439 (setf my-analysis (analyze my-fit
440 :estimation-method 'linear-least-squares-regression))
442 ;; one of the tricks here is that one needs to provide the structure
443 ;; from which to consider estimation, and more importantly, the
444 ;; validity of the estimation.
447 (setf linear-least-squares-regression
448 (estimation-method-definition
449 :variable-defintions ((list
450 ;; from MachLearn: supervised,
451 ;; unsupervised
452 :data-response-vars list-drv ; nil if unsup
454 :param-vars list-pv
455 :data-predictor-vars list-dpv
456 ;; nil in this case. these
457 ;; describe "out-of-box" specs
458 :hyper-vars list-hv))
459 :form '(regression-additive-error
460 :central-form (linear-form drv pv dpv)
461 :error-form 'normal-error)
462 :resulting-decision '(point-estimation interval-estimation)
463 :philosophy 'frequentist
464 :documentation "use least squares to fit a linear regression
465 model to data."))
467 (defparameter *statistical-philosophies*
468 '(frequentist bayesian fiducial decision-analysis)
469 "can be combined to build decision-making approaches and
470 characterizations")
472 (defparameter *decisions*
473 '(estimation selection testing)
474 "possible results from a...")
475 ;; is this really true? One can embedded hypothesis testing within
476 ;; estimation, as the hypothesis estimated to select. And
477 ;; categorical/continuous rear their ugly heads, but not really in
478 ;; an essential way.
480 (defparameter *ontology-of-decision-procedures*
481 (list :decisions
482 (list :estimation
483 (list :point
484 (list :maximum-likelihood
485 :minimum-entropy
486 :least-squares
487 :method-of-moments)
488 :interval
489 (list :maximum-likelihood
491 :testing
492 (list :fisherian
493 :neyman-pearson
494 (list :traditional
495 :bioequivalence-inversion)
496 :selection
497 (list :ranking
498 :top-k-of-n-select))
499 :parametric
500 :partially-parametric))
501 "start of ontology"))
504 ;;;; LM
506 (progn
508 (defparameter *y*
509 (make-vector
511 :type :row
512 :initial-contents '((1d0 2d0 3d0 4d0 5d0 6d0 7d0 8d0))))
515 (defparameter *xv+1*
516 (make-matrix
518 :initial-contents '((1d0 1d0)
519 (1d0 3d0)
520 (1d0 2d0)
521 (1d0 4d0)
522 (1d0 3d0)
523 (1d0 5d0)
524 (1d0 4d0)
525 (1d0 6d0))))
528 ;; so something like (NOTE: matrices are transposed to begin with, hence the incongruety)
529 (defparameter *xtx-2* (m* (transpose *xv+1*) *xv+1*))
530 ;; #<LA-SIMPLE-MATRIX-DOUBLE 2 x 2
531 ;; 8.0d0 28.0d0
532 ;; 28.0d0 116.0d0>
534 (defparameter *xty-2* (m* (transpose *xv+1*) (transpose *y*)))
535 ;; #<LA-SIMPLE-VECTOR-DOUBLE (2 x 1)
536 ;; 36.0d0
537 ;; 150.0d0>
539 (defparameter *rcond-2* 0.000001)
540 (defparameter *betahat-2* (gelsy *xtx-2* *xty-2* *rcond-2*))
541 ;; *xtx-2* => "details of complete orthogonal factorization"
542 ;; according to man page:
543 ;; #<LA-SIMPLE-MATRIX-DOUBLE 2 x 2
544 ;; -119.33147112141039d0 -29.095426104883202d0
545 ;; 0.7873402682880205d0 -1.20672274167718d0>
547 ;; *xty-2* => output becomes solution:
548 ;; #<LA-SIMPLE-VECTOR-DOUBLE (2 x 1)
549 ;; -0.16666666666668312d0
550 ;; 1.333333333333337d0>
552 *betahat-2* ; which matches R, see below
554 (documentation 'gelsy 'function)
557 ;; (#<LA-SIMPLE-VECTOR-DOUBLE (2 x 1)
558 ;; -0.16666666666668312 1.333333333333337>
559 ;; 2)
561 ;; ## Test case in R:
562 ;; x <- c( 1.0, 3.0, 2.0, 4.0, 3.0, 5.0, 4.0, 6.0)
563 ;; y <- c( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0)
564 ;; lm(y~x)
565 ;; ## => Call: lm(formula = y ~ x)
567 ;; Coefficients: (Intercept) x
568 ;; -0.1667 1.3333
570 ;; summary(lm(y~x))
571 ;; ## =>
573 ;; Call:
574 ;; lm(formula = y ~ x)
576 ;; Residuals:
577 ;; Min 1Q Median 3Q Max
578 ;; -1.833e+00 -6.667e-01 -3.886e-16 6.667e-01 1.833e+00
580 ;; Coefficients:
581 ;; Estimate Std. Error t value Pr(>|t|)
582 ;; (Intercept) -0.1667 1.1587 -0.144 0.89034
583 ;; x 1.3333 0.3043 4.382 0.00466 **
584 ;; ---
585 ;; Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
587 ;; Residual standard error: 1.291 on 6 degrees of freedom
588 ;; Multiple R-squared: 0.7619, Adjusted R-squared: 0.7222
589 ;; F-statistic: 19.2 on 1 and 6 DF, p-value: 0.004659
593 ;; which suggests one might do (modulo ensuring correct
594 ;; orientations). When this is finalized, it should migrate to
595 ;; CLS.
599 (defparameter *n* 20) ; # rows = # obsns
600 (defparameter *p* 10) ; # cols = # vars
601 (defparameter *x-temp* (rand *n* *p*))
602 (defparameter *b-temp* (rand *p* 1))
603 (defparameter *y-temp* (m* *x-temp* *b-temp*))
604 ;; so Y=Xb + \eps
605 (defparameter *rcond* (* (coerce (expt 2 -52) 'double-float)
606 (max (nrows *x-temp*) (ncols *y-temp*))))
607 (defparameter *orig-x* (copy *x-temp*))
608 (defparameter *orig-b* (copy *b-temp*))
609 (defparameter *orig-y* (copy *y-temp*))
611 (defparameter *lm-result* (lm *x-temp* *y-temp*))
612 (princ (first *lm-result*))
613 (princ (second *lm-result*))
614 (princ (third *lm-result*))
615 (v= (third *lm-result*)
616 (v- (first (first *lm-result*))
617 (first (second *lm-result*))))
622 ;; Some issues exist in the LAPACK vs. LINPACK variants, hence R
623 ;; uses LINPACK primarily, rather than LAPACK. See comments in R
624 ;; source for issues.
627 ;; Goal is to start from X, Y and then realize that if
628 ;; Y = X \beta, then, i.e. 8x1 = 8xp px1 + 8x1
629 ;; XtX \hat\beta = Xt Y
630 ;; so that we can solve the equation W \beta = Z where W and Z
631 ;; are known, to estimate \beta.
633 ;; the above is known to be numerically instable -- some processing
634 ;; of X is preferred and should be done prior. And most of the
635 ;; transformation-based work does precisely that.
637 ;; recall: Var[Y] = E[(Y - E[Y])(Y-E[Y])t]
638 ;; = E[Y Yt] - 2 \mu \mut + \mu \mut
639 ;; = E[Y Yt] - \mu \mut
641 ;; Var Y = E[Y^2] - \mu^2
644 ;; For initial estimates of covariance of \hat\beta:
646 ;; \hat\beta = (Xt X)^-1 Xt Y
647 ;; with E[ \hat\beta ]
648 ;; = E[ (Xt X)^-1 Xt Y ]
649 ;; = E[(Xt X)^-1 Xt (X\beta)]
650 ;; = \beta
652 ;; So Var[\hat\beta] = ...
653 ;; (Xt X)
654 ;; and this gives SE(\beta_i) = (* (sqrt (mref Var i i)) adjustment)
657 ;; from docs:
659 (setf *temp-result*
660 (let ((*default-implementation* :foreign-array))
661 (let* ((m 10)
662 (n 10)
663 (a (rand m n))
664 (x (rand n 1))
665 (b (m* a x))
666 (rcond (* (coerce (expt 2 -52) 'double-float)
667 (max (nrows a) (ncols a))))
668 (orig-a (copy a))
669 (orig-b (copy b))
670 (orig-x (copy x)))
671 (list x (gelsy a b rcond))
672 ;; no applicable conversion?
673 ;; (m- (#<FA-SIMPLE-VECTOR-DOUBLE (10 x 1))
674 ;; (#<FA-SIMPLE-VECTOR-DOUBLE (10 x 1)) )
675 (v- x (first (gelsy a b rcond))))))
678 (princ *temp-result*)
680 (setf *temp-result*
681 (let ((*default-implementation* :lisp-array))
682 (let* ((m 10)
683 (n 10)
684 (a (rand m n))
685 (x (rand n 1))
686 (b (m* a x))
687 (rcond (* (coerce (expt 2 -52) 'double-float)
688 (max (nrows a) (ncols a))))
689 (orig-a (copy a))
690 (orig-b (copy b))
691 (orig-x (copy x)))
692 (list x (gelsy a b rcond))
693 (m- x (first (gelsy a b rcond)))
695 (princ *temp-result*)
698 (defparameter *xv*
699 (make-vector
701 :type :row ;; default, not usually needed!
702 :initial-contents '((1d0 3d0 2d0 4d0 3d0 5d0 4d0 6d0))))
704 (defparameter *y*
705 (make-vector
707 :type :row
708 :initial-contents '((1d0 2d0 3d0 4d0 5d0 6d0 7d0 8d0))))
710 ;; so something like (NOTE: matrices are transposed to begin with, hence the incongruety)
711 (defparameter *xtx-1* (m* *xv* (transpose *xv*)))
712 (defparameter *xty-1* (m* *xv* (transpose *y*)))
713 (defparameter *rcond-in* (* (coerce (expt 2 -52) 'double-float)
714 (max (nrows *xtx-1*)
715 (ncols *xty-1*))))
717 (defparameter *betahat* (gelsy *xtx-1* *xty-1* *rcond-in*))
719 ;; (#<LA-SIMPLE-VECTOR-DOUBLE (1 x 1)
720 ;; 1.293103448275862>
721 ;; 1)
723 ;; ## Test case in R:
724 ;; x <- c( 1.0, 3.0, 2.0, 4.0, 3.0, 5.0, 4.0, 6.0)
725 ;; y <- c( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0)
726 ;; lm(y~x-1)
727 ;; ## =>
728 ;; Call:
729 ;; lm(formula = y ~ x - 1)
731 ;; Coefficients:
732 ;; x
733 ;; 1.293
735 (first *betahat*))
739 #+nil
740 (progn
742 (asdf:oos 'asdf:load-op 'cl-plplot)
744 (plot-ex))
748 (type-of #2A((1 2 3 4 5)
749 (10 20 30 40 50)))
751 (type-of (rand 10 20))
753 (typep #2A((1 2 3 4 5)
754 (10 20 30 40 50))
755 'matrix-like)
757 (typep (rand 10 20) 'matrix-like)
759 (typep #2A((1 2 3 4 5)
760 (10 20 30 40 50))
761 'array)
763 (typep (rand 10 20) 'array)