change externals to be org-mode files
[CommonLispStat.git] / TODO.lisp
blobdbf6adae4e2dda3df5e7ec0c569ecff8cf61840f
1 ;;; -*- mode: lisp -*-
3 ;;; Time-stamp: <2010-06-15 09:59:40 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)
21 (progn
22 (defun init-CLS ()
24 ;; core system
25 ;;(asdf:oos 'asdf:load-op 'lisp-matrix)
26 ;;(asdf:oos 'asdf:compile-op 'cls :force t)
27 (asdf:oos 'asdf:load-op :cls)
29 ;; visualization
30 ;; (asdf:oos 'asdf:load-op 'cl-cairo2-x11)
31 ;; (asdf:oos 'asdf:compile-op 'iterate :force t)
32 (asdf:oos 'asdf:load-op 'iterate)
33 ;; (asdf:oos 'asdf:compile-op :cl-2d :force t)
34 (asdf:oos 'asdf:load-op 'cl-2d)
36 ;; doc reporting
37 (asdf:oos 'asdf:load-op 'cl-pdf)
38 (asdf:oos 'asdf:load-op 'cl-typesetting))
40 ;;INFRA
41 ;; (asdf:oos 'asdf:compile-op 'asdf-system-connections :force t)
42 ;; (asdf:oos 'asdf:compile-op 'lisp-matrix)
43 ;; (asdf:oos 'asdf:load-op 'xarray)
45 ;;DOCS
46 ;;; (asdf:oos 'asdf:compile-op 'metatilities-base :force t)
47 ;;; (asdf:oos 'asdf:load-op 'metatilities-base)
48 ;;; (asdf:oos 'asdf:load-op 'anaphora)
49 ;;; (asdf:oos 'asdf:load-op 'tinaa)
50 ;;; (asdf:oos 'asdf:load-op 'cl-ppcre)
51 ;; (asdf:oos 'asdf:load-op 'cl-markdown) ;; just need this and the next...
52 ;; (asdf:oos 'asdf:load-op 'docudown)
54 ;;use of extension packages supporting versioning and validation of
55 ;;CLOS objects?
56 ;; (asdf:oos 'asdf:compile-op 'versioned-objects :force t)
57 ;; (asdf:oos 'asdf:load-op 'versioned-objects)
58 ;; (asdf:oos 'asdf:compile-op 'validations :force t)
59 ;; (asdf:oos 'asdf:load-op 'validations)
61 ;;VIZ
62 ;; (asdf:oos 'asdf:compile-op 'cffi :force t)
63 ;; (asdf:oos 'asdf:load-op 'cl-opengl)
64 ;; (asdf:oos 'asdf:load-op 'cl-glu)
65 ;; (asdf:oos 'asdf:load-op 'cl-glut)
66 ;; (asdf:oos 'asdf:load-op 'cl-glut-examples)
68 ;; (asdf:oos 'asdf:load-op 'cells)
69 (asdf:oos 'asdf:load-op 'bordeaux-threads)
70 ;; (asdf:oos 'asdf:load-op 'cells-gtk)
72 (init-CLS))
74 (in-package :lisp-stat-unittests)
76 ;; tests = 78, failures = 7, errors = 20
77 (run-tests :suite 'lisp-stat-ut)
79 (asdf:oos 'asdf:test-op 'cls)
80 ;; which runs (describe (run-tests :suite 'lisp-stat-ut))
82 (describe 'lisp-stat-ut)
83 (documentation 'lisp-stat-ut 'type)
85 ;; FIXME: Example: currently not relevant, yet
86 ;; (describe (lift::run-test :test-case 'lisp-stat-unittests::create-proto
87 ;; :suite 'lisp-stat-unittests::lisp-stat-ut-proto))
89 (describe (lift::run-tests :suite 'lisp-stat-ut-dataframe))
90 (lift::run-tests :suite 'lisp-stat-ut-dataframe)
92 (describe (lift::run-test
93 :test-case 'lisp-stat-unittests::create-proto
94 :suite 'lisp-stat-unittests::lisp-stat-ut-proto))
96 (in-package :ls-user)
98 ;;; Tasks working on...
100 #+nil
101 (progn )
103 #+nil
104 (progn
105 ;; Syntax examples using lexical scope, closures, and bindings to
106 ;; ensure a clean communication of results
107 (with-data dataset ((dsvarname1 [usevarname1])
108 (dsvarname2 [usevarname2]))
109 @body))
111 (defparameter *df-test*
112 (make-instance 'dataframe-array
113 :storage #2A (('a "test0" 0 0d0)
114 ('b "test1" 1 1d0)
115 ('c "test2" 2 2d0)
116 ('d "test3" 3 3d0)
117 ('e "test4" 4 4d0))
118 :doc "test reality"
119 :case-labels (list "0" "1" 2 "3" "4")
120 :var-labels (list "symbol" "string" "integer" "double-float")
121 :var-types (list 'symbol 'string 'integer 'double-float)))
123 *df-test* ; but with SBCL, ints become floats?
125 (defun check-var (df colnum)
126 (let ((nobs (xdim (dataset df) 0)))
127 (dotimes (i nobs)
128 (check-type (xref df i colnum) (elt (var-types df) i)))))
130 (xdim (dataset *df-test*) 1)
131 (xdim (dataset *df-test*) 0)
133 (check-var *df-test* 0)
135 (class-of
136 (xref *df-test* 1 1))
138 (check-type (xref *df-test* 1 1)
139 string) ;; => nil, so good.
140 (check-type (xref *df-test* 1 1)
141 vector) ;; => nil, so good.
142 (check-type (xref *df-test* 1 1)
143 real) ;; => simple-error type thrown, so good.
145 ;; How to nest errors within errors?
146 (check-type (check-type (xref *df-test* 1 1) real) ;; => error thrown, so good.
147 simple-error)
148 (xref *df-test* 1 2)
151 (check-type)
154 (integerp (xref *df-test* 1 2))
155 (floatp (xref *df-test* 1 2))
156 (integerp (xref *df-test* 1 3))
157 (type-of (xref *df-test* 1 3))
158 (floatp (xref *df-test* 1 3))
160 (type-of (vector 1 1d0))
161 (type-of *df-test*)
164 (xref *df-test* 2 1)
165 (xref *df-test* 0 0)
166 (xref *df-test* 1 0)
167 (xref *df-test* 1 '*)
169 ;;; Experiments with cl-variates
171 ;; (asdf:oos 'asdf:compile-op 'cl-variates :force t)
172 ;; (asdf:oos 'asdf:compile-op 'cl-variates-test :force t)
173 ;; (asdf:oos 'asdf:load-op 'lift)
174 ;; (asdf:oos 'asdf:load-op 'cl-variates)
175 (asdf:oos 'asdf:load-op 'cl-variates-test)
177 (in-package :cl-variates-test)
178 ;; check tests
179 (run-tests :suite 'cl-variates-test)
180 (describe (run-tests :suite 'cl-variates-test))
182 (in-package :cl-variates-user)
183 ;; example usage
184 (defparameter state (make-random-number-generator))
185 (setf (random-seed state) 44)
186 (random-seed state)
187 (loop for i from 1 to 10 collect
188 (random-range state 0 10))
189 ;; => (1 5 1 0 7 1 2 2 8 10)
190 (setf (random-seed state) 44)
191 (loop for i from 1 to 10 collect
192 (random-range state 0 10))
193 ;; => (1 5 1 0 7 1 2 2 8 10)
195 (setf (random-seed state) 44)
196 (random-seed state)
197 (loop for i from 1 to 10 collect
198 (normal-random state 0 1))
199 ;; =>
200 ;; (-1.2968656102820426 0.40746363934173213 -0.8594712469518473 0.8795681301148328
201 ;; 1.0731526250004264 -0.8161629082481728 0.7001813608754809 0.1078045427044097
202 ;; 0.20750134211656893 -0.14501914108452274)
204 (setf (random-seed state) 44)
205 (loop for i from 1 to 10 collect
206 (normal-random state 0 1))
207 ;; =>
208 ;; (-1.2968656102820426 0.40746363934173213 -0.8594712469518473 0.8795681301148328
209 ;; 1.0731526250004264 -0.8161629082481728 0.7001813608754809 0.1078045427044097
210 ;; 0.20750134211656893 -0.14501914108452274)
213 ;;; experiments with LLA
214 (in-package :cl-user)
215 (asdf:oos 'asdf:load-op 'lla)
216 (in-package :lla-user)
220 (in-package :cls-user)
221 ;;;; PFIM notes
223 ;; PFIM 3.2
225 ;; population design eval and opt
227 issues:
228 - # individuals
229 - # sampling times
230 - sampling times?
232 constraints:
233 number of samples/cost of lab analysis and collection
234 expt constraints
237 (defun pfim (&key model ( constraints ( summary-function )
239 (list num-subjects num-times list-times))))
242 N individuals i
243 Each individal has a deisgn psi_i
244 nubmer of samples n_i and sampling times t_{i{1}} t_{i{n_1}}
245 individuals can differ
247 Model:
249 individual-level model
252 (=model y_i (+ (f \theta_i \psi_i) epsilion_i ))
253 (=var \epsilion_i \sigma_between \sigma_within )
255 ;; Information Matrix for pop deisgn
257 (defparameter IM (sum (i 1 N) (MF \psi_i \phi_i)))
260 For nonlinear structureal models, expand around RE=0
262 Cramer-Rao : MF^{-1} is lower bound for estimation variance.
264 Design comparisons:
266 - smallest SE, but is a matrix, so
267 - criteria for matrix comparison
268 -- D-opt, (power (determinant MF) (/ 1 P))
271 find design maxing D opt, (power (determinant MF) (/ 1 P))
272 Design varialables
273 -- contin vars for smapling times within interval or set
274 -- number of groups for cat vars
276 Stat in Med 2009, expansion around post-hoc RE est, not necessarily zero.
278 Example binary covariate C
281 (if (= i reference-class)
282 (setf (aref C i) 0)
283 (setf (aref C i) 1))
285 ;; Exponential RE,
286 (=model (log \theta) ( ))
288 ;; extensions
290 ;; outputs
293 PFIM provides for a given design and values of \beta:
294 compute extended FIM
295 SE/RSE for \beta of each class of each covar
296 eval influence of design on SE(\beta)
298 inter-occassion variability (IOV)
299 - patients sampled more than once, H occassions
300 - RE for IOV
301 - additional vars to estimate
305 ;;; comparison criteria
307 functional of conc/time curve which is used for comparison, i.e.
308 (AUC conc/time-curve)
309 (Cmax conc/time-curve)
310 (Tmax conc/time-curve)
312 where
314 (defun conc/time-curve (t)
315 ;; computation
317 (let ((conc (exp (* t \beta1))))
318 conc)
322 ;;See
323 (url-get "www.pfim.biostat.fr")
325 ;;; Thinking of generics...
326 (information-matrix model parameters)
327 (information-matrix variance-matrix)
328 (information-matrix model data)
329 (information-matrix list-of-individual-IMs)
332 (defun IM (loglikelihood parameters times)
333 "Does double work. Sum up the resulting IMs to form a full IM."
334 (let ((IM (make-matrix (length parameters)
335 (length parameters)
336 :initial-value 0.0d0)))
337 (dolist (parameterI parameters)
338 (dolist (parameterJ parameters)
339 (setf (aref IM I J)
340 (differentiate (differentiate loglikelihood parameterI) parameterJ))))))
344 ;; difference between empirical, fisherian, and ...? information.
346 ;;; Docudown...
348 ;;; CL-genomic
349 (asdf:oos 'asdf:compile-op :ironclad)
351 (in-package :cl-user)
352 (asdf:oos 'asdf:load-op :cl-genomic)
354 (in-package :bio-sequence)
355 (make-dna "agccg") ;; fine
356 (make-aa "agccg") ;; fine
357 (make-aa "agc9zz") ;; error