hints on directory standards.
[CommonLispStat.git] / TODO.lisp
blob6953af6bcd94f4c4c9a25ec38db87617f061b055
1 ;;; -*- mode: lisp -*-
3 ;;; Time-stamp: <2010-01-27 17:31:07 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)
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 df 0)))
124 (dotimes (i nobs)
125 (check-type (xref df i colnum) (elt (var-types df) i)))))
127 (check-var *df-test* 0)
129 (xref *df-test* 1 2)
131 (integerp (xref *df-test* 1 2))
132 (floatp (xref *df-test* 1 2))
133 (integerp (xref *df-test* 1 3))
134 (type-of (xref *df-test* 1 3))
135 (floatp (xref *df-test* 1 3))
137 (type-of (vector 1 1d0))
141 (loop )
143 (xref *df-test* 2 1)
144 (xref *df-test* 0 0)
145 (xref *df-test* 1 0)
146 (xref *df-test* 1 '*)
148 ;;; Experiments with cl-variates
150 ;; (asdf:oos 'asdf:compile-op 'cl-variates :force t)
151 ;; (asdf:oos 'asdf:compile-op 'cl-variates-test :force t)
152 ;; (asdf:oos 'asdf:load-op 'lift)
153 ;; (asdf:oos 'asdf:load-op 'cl-variates)
154 (asdf:oos 'asdf:load-op 'cl-variates-test)
156 (in-package :cl-variates-test)
157 ;; check tests
158 (run-tests :suite 'cl-variates-test)
159 (describe (run-tests :suite 'cl-variates-test))
161 (in-package :cl-variates-user)
162 ;; example usage
163 (defparameter state (make-random-number-generator))
164 (setf (random-seed state) 44)
165 (random-seed state)
166 (loop for i from 1 to 10 collect
167 (random-range state 0 10))
168 ;; => (1 5 1 0 7 1 2 2 8 10)
169 (setf (random-seed state) 44)
170 (loop for i from 1 to 10 collect
171 (random-range state 0 10))
172 ;; => (1 5 1 0 7 1 2 2 8 10)
174 (setf (random-seed state) 44)
175 (random-seed state)
176 (loop for i from 1 to 10 collect
177 (normal-random state 0 1))
178 ;; =>
179 ;; (-1.2968656102820426 0.40746363934173213 -0.8594712469518473 0.8795681301148328
180 ;; 1.0731526250004264 -0.8161629082481728 0.7001813608754809 0.1078045427044097
181 ;; 0.20750134211656893 -0.14501914108452274)
183 (setf (random-seed state) 44)
184 (loop for i from 1 to 10 collect
185 (normal-random state 0 1))
186 ;; =>
187 ;; (-1.2968656102820426 0.40746363934173213 -0.8594712469518473 0.8795681301148328
188 ;; 1.0731526250004264 -0.8161629082481728 0.7001813608754809 0.1078045427044097
189 ;; 0.20750134211656893 -0.14501914108452274)
192 ;;; experiments with LLA
193 (in-package :cl-user)
194 (asdf:oos 'asdf:load-op 'lla)
195 (in-package :lla-user)
199 (in-package :cls-user)
200 ;;;; PFIM notes
202 ;; PFIM 3.2
204 ;; population design eval and opt
206 issues:
207 - # individuals
208 - # sampling times
209 - sampling times?
211 constraints:
212 number of samples/cost of lab analysis and collection
213 expt constraints
216 (defun pfim (&key model ( constraints ( summary-function )
218 (list num-subjects num-times list-times))))
221 N individuals i
222 Each individal has a deisgn psi_i
223 nubmer of samples n_i and sampling times t_{i{1}} t_{i{n_1}}
224 individuals can differ
226 Model:
228 individual-level model
231 (=model y_i (+ (f \theta_i \psi_i) epsilion_i ))
232 (=var \epsilion_i \sigma_between \sigma_within )
234 ;; Information Matrix for pop deisgn
236 (defparameter IM (sum (i 1 N) (MF \psi_i \phi_i)))
239 For nonlinear structureal models, expand around RE=0
241 Cramer-Rao : MF^{-1} is lower bound for estimation variance.
243 Design comparisons:
245 - smallest SE, but is a matrix, so
246 - criteria for matrix comparison
247 -- D-opt, (power (determinant MF) (/ 1 P))
250 find design maxing D opt, (power (determinant MF) (/ 1 P))
251 Design varialables
252 -- contin vars for smapling times within interval or set
253 -- number of groups for cat vars
255 Stat in Med 2009, expansion around post-hoc RE est, not necessarily zero.
257 Example binary covariate C
260 (if (= i reference-class)
261 (setf (aref C i) 0)
262 (setf (aref C i) 1))
264 ;; Exponential RE,
265 (=model (log \theta) ( ))
267 ;; extensions
269 ;; outputs
272 PFIM provides for a given design and values of \beta:
273 compute extended FIM
274 SE/RSE for \beta of each class of each covar
275 eval influence of design on SE(\beta)
277 inter-occassion variability (IOV)
278 - patients sampled more than once, H occassions
279 - RE for IOV
280 - additional vars to estimate
284 ;;; comparison criteria
286 functional of conc/time curve which is used for comparison, i.e.
287 (AUC conc/time-curve)
288 (Cmax conc/time-curve)
289 (Tmax conc/time-curve)
291 where
293 (defun conc/time-curve (t)
294 ;; computation
296 (let ((conc (exp (* t \beta1))))
297 conc)
301 ;;See
302 (url-get "www.pfim.biostat.fr")
304 ;;; Thinking of generics...
305 (information-matrix model parameters)
306 (information-matrix variance-matrix)
307 (information-matrix model data)
308 (information-matrix list-of-individual-IMs)
311 (defun IM (loglikelihood parameters times)
312 "Does double work. Sum up the resulting IMs to form a full IM."
313 (let ((IM (make-matrix (length parameters)
314 (length parameters)
315 :initial-value 0.0d0)))
316 (dolist (parameterI parameters)
317 (dolist (parameterJ parameters)
318 (setf (aref IM I J)
319 (differentiate (differentiate loglikelihood parameterI) parameterJ))))))
323 ;; difference between empirical, fisherian, and ...? information.
325 ;;; Docudown...