proper loading.
[CommonLispStat.git] / TODO.lisp
blobc04634f5503d2011bcadf90680364f9def3a05ce
1 ;;; -*- mode: lisp -*-
3 ;;; Time-stamp: <2010-03-19 08:17:46 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:load-op 'cl-2d)
33 ;; doc reporting
34 (asdf:oos 'asdf:load-op 'cl-pdf)
35 (asdf:oos 'asdf:load-op 'cl-typesetting))
37 ;;INFRA
38 ;; (asdf:oos 'asdf:compile-op 'asdf-system-connections :force t)\x01
39 ;; (asdf:oos 'asdf:compile-op 'lisp-matrix)
40 ;; (asdf:oos 'asdf:load-op 'xarray)
42 ;;DOCS
43 ;;; (asdf:oos 'asdf:compile-op 'metatilities-base :force t)
44 ;;; (asdf:oos 'asdf:load-op 'metatilities-base)
45 ;;; (asdf:oos 'asdf:load-op 'anaphora)
46 ;;; (asdf:oos 'asdf:load-op 'tinaa)
47 ;;; (asdf:oos 'asdf:load-op 'cl-ppcre)
48 ;; (asdf:oos 'asdf:load-op 'cl-markdown) ;; just need this and the next...
49 ;; (asdf:oos 'asdf:load-op 'docudown)
51 ;;use of extension packages supporting versioning and validation of
52 ;;CLOS objects?
53 ;; (asdf:oos 'asdf:compile-op 'versioned-objects :force t)
54 ;; (asdf:oos 'asdf:load-op 'versioned-objects)
55 ;; (asdf:oos 'asdf:compile-op 'validations :force t)
56 ;; (asdf:oos 'asdf:load-op 'validations)
58 ;;VIZ
59 ;; (asdf:oos 'asdf:compile-op 'cffi :force t)
60 ;; (asdf:oos 'asdf:load-op 'cl-opengl)
61 ;; (asdf:oos 'asdf:load-op 'cl-glu)
62 ;; (asdf:oos 'asdf:load-op 'cl-glut)
63 ;; (asdf:oos 'asdf:load-op 'cl-glut-examples)
65 ;; (asdf:oos 'asdf:load-op 'cells)
66 (asdf:oos 'asdf:load-op 'bordeaux-threads)
67 ;; (asdf:oos 'asdf:load-op 'cells-gtk)
69 (init-CLS))
71 (in-package :lisp-stat-unittests)
73 ;; tests = 78, failures = 7, errors = 20
74 (run-tests :suite 'lisp-stat-ut)
76 (asdf:oos 'asdf:test-op 'cls)
77 ;; which runs (describe (run-tests :suite 'lisp-stat-ut))
79 (describe 'lisp-stat-ut)
80 (documentation 'lisp-stat-ut 'type)
82 ;; FIXME: Example: currently not relevant, yet
83 ;; (describe (lift::run-test :test-case 'lisp-stat-unittests::create-proto
84 ;; :suite 'lisp-stat-unittests::lisp-stat-ut-proto))
86 (describe (lift::run-tests :suite 'lisp-stat-ut-dataframe))
87 (lift::run-tests :suite 'lisp-stat-ut-dataframe)
89 (describe (lift::run-test
90 :test-case 'lisp-stat-unittests::create-proto
91 :suite 'lisp-stat-unittests::lisp-stat-ut-proto))
93 (in-package :ls-user)
95 ;;; Tasks working on...
97 #+nil
98 (progn )
100 #+nil
101 (progn
102 ;; Syntax examples using lexical scope, closures, and bindings to
103 ;; ensure a clean communication of results
104 (with-data dataset ((dsvarname1 [usevarname1])
105 (dsvarname2 [usevarname2]))
106 @body))
108 (defparameter *df-test*
109 (make-instance 'dataframe-array
110 :storage #2A (('a "test0" 0 0d0)
111 ('b "test1" 1 1d0)
112 ('c "test2" 2 2d0)
113 ('d "test3" 3 3d0)
114 ('e "test4" 4 4d0))
115 :doc "test reality"
116 :case-labels (list "0" "1" 2 "3" "4")
117 :var-labels (list "symbol" "string" "integer" "double-float")
118 :var-types (list 'symbol 'string 'integer 'double-float)))
120 *df-test* ; but with SBCL, ints become floats?
122 (defun check-var (df colnum)
123 (let ((nobs (xdim (dataset df) 0)))
124 (dotimes (i nobs)
125 (check-type (xref df i colnum) (elt (var-types df) i)))))
127 (xdim (dataset *df-test*) 1)
128 (xdim (dataset *df-test*) 0)
130 (check-var *df-test* 0)
132 (check-type (xref *df-test* 1 1) simple-character-string)
133 (xref *df-test* 1 2)
135 (class-of
136 (xref *df-test* 1 1) )
138 (check-type)
142 (integerp (xref *df-test* 1 2))
143 (floatp (xref *df-test* 1 2))
144 (integerp (xref *df-test* 1 3))
145 (type-of (xref *df-test* 1 3))
146 (floatp (xref *df-test* 1 3))
148 (type-of (vector 1 1d0))
152 (loop )
154 (xref *df-test* 2 1)
155 (xref *df-test* 0 0)
156 (xref *df-test* 1 0)
157 (xref *df-test* 1 '*)
159 ;;; Experiments with cl-variates
161 ;; (asdf:oos 'asdf:compile-op 'cl-variates :force t)
162 ;; (asdf:oos 'asdf:compile-op 'cl-variates-test :force t)
163 ;; (asdf:oos 'asdf:load-op 'lift)
164 ;; (asdf:oos 'asdf:load-op 'cl-variates)
165 (asdf:oos 'asdf:load-op 'cl-variates-test)
167 (in-package :cl-variates-test)
168 ;; check tests
169 (run-tests :suite 'cl-variates-test)
170 (describe (run-tests :suite 'cl-variates-test))
172 (in-package :cl-variates-user)
173 ;; example usage
174 (defparameter state (make-random-number-generator))
175 (setf (random-seed state) 44)
176 (random-seed state)
177 (loop for i from 1 to 10 collect
178 (random-range state 0 10))
179 ;; => (1 5 1 0 7 1 2 2 8 10)
180 (setf (random-seed state) 44)
181 (loop for i from 1 to 10 collect
182 (random-range state 0 10))
183 ;; => (1 5 1 0 7 1 2 2 8 10)
185 (setf (random-seed state) 44)
186 (random-seed state)
187 (loop for i from 1 to 10 collect
188 (normal-random state 0 1))
189 ;; =>
190 ;; (-1.2968656102820426 0.40746363934173213 -0.8594712469518473 0.8795681301148328
191 ;; 1.0731526250004264 -0.8161629082481728 0.7001813608754809 0.1078045427044097
192 ;; 0.20750134211656893 -0.14501914108452274)
194 (setf (random-seed state) 44)
195 (loop for i from 1 to 10 collect
196 (normal-random state 0 1))
197 ;; =>
198 ;; (-1.2968656102820426 0.40746363934173213 -0.8594712469518473 0.8795681301148328
199 ;; 1.0731526250004264 -0.8161629082481728 0.7001813608754809 0.1078045427044097
200 ;; 0.20750134211656893 -0.14501914108452274)
203 ;;; experiments with LLA
204 (in-package :cl-user)
205 (asdf:oos 'asdf:load-op 'lla)
206 (in-package :lla-user)
210 (in-package :cls-user)
211 ;;;; PFIM notes
213 ;; PFIM 3.2
215 ;; population design eval and opt
217 issues:
218 - # individuals
219 - # sampling times
220 - sampling times?
222 constraints:
223 number of samples/cost of lab analysis and collection
224 expt constraints
227 (defun pfim (&key model ( constraints ( summary-function )
229 (list num-subjects num-times list-times))))
232 N individuals i
233 Each individal has a deisgn psi_i
234 nubmer of samples n_i and sampling times t_{i{1}} t_{i{n_1}}
235 individuals can differ
237 Model:
239 individual-level model
242 (=model y_i (+ (f \theta_i \psi_i) epsilion_i ))
243 (=var \epsilion_i \sigma_between \sigma_within )
245 ;; Information Matrix for pop deisgn
247 (defparameter IM (sum (i 1 N) (MF \psi_i \phi_i)))
250 For nonlinear structureal models, expand around RE=0
252 Cramer-Rao : MF^{-1} is lower bound for estimation variance.
254 Design comparisons:
256 - smallest SE, but is a matrix, so
257 - criteria for matrix comparison
258 -- D-opt, (power (determinant MF) (/ 1 P))
261 find design maxing D opt, (power (determinant MF) (/ 1 P))
262 Design varialables
263 -- contin vars for smapling times within interval or set
264 -- number of groups for cat vars
266 Stat in Med 2009, expansion around post-hoc RE est, not necessarily zero.
268 Example binary covariate C
271 (if (= i reference-class)
272 (setf (aref C i) 0)
273 (setf (aref C i) 1))
275 ;; Exponential RE,
276 (=model (log \theta) ( ))
278 ;; extensions
280 ;; outputs
283 PFIM provides for a given design and values of \beta:
284 compute extended FIM
285 SE/RSE for \beta of each class of each covar
286 eval influence of design on SE(\beta)
288 inter-occassion variability (IOV)
289 - patients sampled more than once, H occassions
290 - RE for IOV
291 - additional vars to estimate
295 ;;; comparison criteria
297 functional of conc/time curve which is used for comparison, i.e.
298 (AUC conc/time-curve)
299 (Cmax conc/time-curve)
300 (Tmax conc/time-curve)
302 where
304 (defun conc/time-curve (t)
305 ;; computation
307 (let ((conc (exp (* t \beta1))))
308 conc)
312 ;;See
313 (url-get "www.pfim.biostat.fr")
315 ;;; Thinking of generics...
316 (information-matrix model parameters)
317 (information-matrix variance-matrix)
318 (information-matrix model data)
319 (information-matrix list-of-individual-IMs)
322 (defun IM (loglikelihood parameters times)
323 "Does double work. Sum up the resulting IMs to form a full IM."
324 (let ((IM (make-matrix (length parameters)
325 (length parameters)
326 :initial-value 0.0d0)))
327 (dolist (parameterI parameters)
328 (dolist (parameterJ parameters)
329 (setf (aref IM I J)
330 (differentiate (differentiate loglikelihood parameterI) parameterJ))))))
334 ;; difference between empirical, fisherian, and ...? information.
336 ;;; Docudown...