2 Time-stamp: <2010-11-30 18:01:26 tony>
3 Creation: <2008-09-08 08:06:30 tony>
8 Author: AJ Rossini <blindglobe@gmail.com>
9 Copyright: (c) 2007-2010, AJ Rossini <blindglobe@gmail.com>. BSD.
10 Purpose: Stuff that needs to be made working sits inside the
13 This file contains the current challenges to solve,
14 including a description of the setup and the work to
15 solve. Solutions welcome.
17 What is this talk of 'release'? Klingons do not make software
18 'releases'. Our software 'escapes', leaving a bloody trail of
19 designers and quality assurance people in its wake.
23 ** (Internal) Package and (External) System Hierarchy
24 *** Singletons (primary building blocks)
26 These are packages as well as
28 | asdf | common system loader |
29 | xarray | common access structure to array-like |
30 | | (matrix, vector) structures. |
31 | cls-config | initialization of Lisp state, variables, etc, |
32 | | localization to the particular lisp. |
33 | lift | unit-testing |
34 | cffi | foriegn function library |
40 *** Dependency structure
42 | lisp-matrix | general purpose matrix package, linking to lapack | |
43 | | for numerics. Depends on: | |
46 | | cl-blapack | cffi |
48 | cls-dataframe | in the same spirit as lisp-matrix, a means to | |
49 | | create tables. Perhaps better called datatables? | |
50 | cls-probability | depends on gsll, cl-variates, cl-? initially, | |
64 Usually, we need to load it before going on.
67 (asdf:oos 'asdf:load-op :cls)
70 - State "DONE" from "CURR" [2010-10-12 Tue 13:48] \\
71 setup is mostly complete
72 - State "CURR" from "TODO" [2010-10-12 Tue 13:47]
73 - State "TODO" from "" [2010-10-12 Tue 13:47]
74 This is an example of a custom setup, not really interesting at
75 this point except to remind Tony how to program.
80 (defun init-CLS (&key (compile 'nil))
81 (let ((packagesToLoad (list ;; core system
82 :lift :lisp-matrix :cls
85 ;; :cl-cairo2-x11 :iterate
88 :cl-pdf :cl-typesetting
90 :asdf-system-connections :xarray
92 :metatilities-base :anaphora :tinaa
93 :cl-ppcre :cl-markdown :docudown
94 ;; version and validate CLOS objects
95 ;; :versioned-objects :validations
98 ;; :cl-glu :cl-glut :cl-glut-examples
103 (mapcar #'(lambda (x)
105 (asdf:oos 'asdf:compile-op x :force T)
106 (asdf:oos 'asdf:load-op x)))
109 (init-CLS)) ;; vs (init-CLS :compile T)
113 | | #<PACKAGE "COMMON-LISP-USER"> |
115 ** TODO [#A] Integrate with quicklist support.
116 - State "TODO" from "" [2010-11-30 Tue 18:00]
118 important to merge with quicklisp system loader support.
119 ** CURR [#A] Testing: unit, regression, examples. [0/3]
120 - State "CURR" from "TODO" [2010-10-12 Tue 13:51]
121 - State "TODO" from "" [2010-10-12 Tue 13:51]
122 Testing consists of unit tests, which internally verify subsets of
123 code, regression tests, and functional tests (in increasing order
125 *** CURR [#B] Unit tests
126 - State "CURR" from "TODO" [2010-11-04 Thu 18:33]
127 - State "CURR" from "TODO" [2010-10-12 Tue 13:48]
128 - State "TODO" from "" [2010-10-12 Tue 13:48]
129 Unit tests have been started using LIFT. Need to consider some of
130 the other systems that provide testing, when people add them to the
131 mix of libraries that we need, along with examples of how to use.
134 (in-package :lisp-stat-unittests)
135 (run-tests :suite 'lisp-stat-ut)
136 ;; => tests = 78, failures = 7, errors = 20
137 (asdf:oos 'asdf:test-op 'cls)
138 ;; which runs (describe (run-tests :suite 'lisp-stat-ut))
140 and check documentation to see if it is useful.
143 (in-package :lisp-stat-unittests)
145 (describe 'lisp-stat-ut)
146 (documentation 'lisp-stat-ut 'type)
148 ;; FIXME: Example: currently not relevant, yet
149 ;; (describe (lift::run-test :test-case 'lisp-stat-unittests::create-proto
150 ;; :suite 'lisp-stat-unittests::lisp-stat-ut-proto))
152 (describe (lift::run-tests :suite 'lisp-stat-ut-dataframe))
153 (lift::run-tests :suite 'lisp-stat-ut-dataframe)
155 (describe (lift::run-test
156 :test-case 'lisp-stat-unittests::create-proto
157 :suite 'lisp-stat-unittests::lisp-stat-ut-proto))
160 *** TODO [#B] Regression Tests
161 - State "TODO" from "" [2010-10-12 Tue 13:54]
163 *** TODO [#B] Functional Tests
164 - State "TODO" from "" [2010-10-12 Tue 13:54]
166 ** CURR [#B] Functional Examples that need to work [1/2]
167 - State "CURR" from "TODO" [2010-11-30 Tue 17:57]
168 - State "TODO" from "" [2010-10-12 Tue 13:55]
170 These examples should be functional forms within CLS, describing
171 working functionality which is needed for work.
173 *** TODO [#B] Scoping with datasets
174 - State "TODO" from "" [2010-11-04 Thu 18:46]
176 The following needs to work, and a related syntax for resampling
177 and similar synthetic data approaches (bootstrapping, imputation)
178 ought to use similar syntax as well.
179 #+srcname: DataSetNameScoping
181 (in-package :ls-user)
183 ;; Syntax examples using lexical scope, closures, and bindings to
184 ;; ensure a clean communication of results
185 ;; This is actually a bit tricky, since we need to clarify whether
186 ;; it is line-at-a-time that we are considering or if there is
187 ;; another mapping strategy. In particular, one could imagine a
188 ;; looping-over-observations function, or a
189 ;; looping-over-independent-observations function which leverages a
190 ;; grouping variable which provides guidance for what is considered
191 ;; independent from the sampling frame being considered. The frame
192 ;; itself (definable via some form of metadata to clarify scope?)
193 ;; could clearly provide a bit of relativity for clarifying what
194 ;; statistical independence means.
196 (with-data dataset ((dsvarname1 [usevarname1])
197 (dsvarname2 [usevarname2]))
200 (looping-over-observations
201 dataset ((dsvarname1 [usevarname1])
202 (dsvarname2 [usevarname2]))
205 (looping-over-independent-observations
206 dataset independence-defining-variable
207 ((dsvarname1 [usevarname1])
208 (dsvarname2 [usevarname2]))
214 *** DONE [#B] Dataframe variable typing
215 - State "DONE" from "CURR" [2010-11-30 Tue 17:56] \\
216 check-type approach works, we would just have to throw a catchable
217 error if we want to use it in a reliable fashion.
218 - State "CURR" from "TODO" [2010-11-30 Tue 17:56]
219 - State "TODO" from "" [2010-11-04 Thu 18:48]
221 Seems to generally work, need to ensure that we use this for
224 #+srcname: DFvarTyping
226 (in-package :ls-user)
227 (defparameter *df-test*
228 (make-instance 'dataframe-array
229 :storage #2A (('a "test0" 0 0d0)
235 :case-labels (list "0" "1" 2 "3" "4")
236 :var-labels (list "symbol" "string" "integer" "double-float")
237 :var-types (list 'symbol 'string 'integer 'double-float)))
239 ;; with SBCL, ints become floats? Need to adjust output
240 ;; representation appropriately..
243 (defun check-var (df colnum)
244 (let ((nobs (xdim (dataset df) 0)))
246 (check-type (xref df i colnum) (elt (var-types df) i)))))
248 (xdim (dataset *df-test*) 1)
249 (xdim (dataset *df-test*) 0)
251 (check-var *df-test* 0)
254 (xref *df-test* 1 1))
256 (check-type (xref *df-test* 1 1)
257 string) ;; => nil, so good.
258 (check-type (xref *df-test* 1 1)
259 vector) ;; => nil, so good.
260 (check-type (xref *df-test* 1 1)
261 real) ;; => simple-error type thrown, so good.
263 ;; How to nest errors within errors?
264 (check-type (check-type (xref *df-test* 1 1) real) ;; => error thrown, so good.
268 (check-type *df-test*
269 dataframe-array) ; nil is good.
271 (integerp (xref *df-test* 1 2))
272 (floatp (xref *df-test* 1 2))
273 (integerp (xref *df-test* 1 3))
274 (type-of (xref *df-test* 1 3))
275 (floatp (xref *df-test* 1 3))
277 (type-of (vector 1 1d0))
283 (xref *df-test* 1 '*)
286 ** CURR [#A] Random Numbers [2/6]
287 - State "CURR" from "TODO" [2010-11-05 Fri 15:41]
288 - State "TODO" from "" [2010-10-14 Thu 00:12]
290 Need to select and choose a probability system (probability
291 functions, random numbers). Goal is to have a general framework
292 for representing probability functions, functionals on
293 probabilities, and reproducible random streams based on such
295 *** CURR [#B] CL-VARIATES system evaluation [2/3]
296 - State "CURR" from "TODO" [2010-11-05 Fri 15:40]
297 - State "TODO" from "" [2010-10-12 Tue 14:16]
299 CL-VARIATES is a system developed by Gary W King. It uses streams
300 with seeds, and is hence reproducible. (Random comment: why do CL
301 programmers as a class ignore computational reproducibility?)
302 **** DONE [#B] load and verify
303 - State "DONE" from "CURR" [2010-11-04 Thu 18:59] \\
304 load, init, and verify performance.
305 - State "CURR" from "TODO" [2010-11-04 Thu 18:58]
306 - State "TODO" from "" [2010-11-04 Thu 18:58]
308 <2010-11-30 Tue> : just modified cls.asd to ensure that we load
309 as appropriate the correct random variate package.
311 #+srcname: Loading-CL-VARIATES
313 (in-package :cl-user)
314 (asdf:oos 'asdf:load-op 'cl-variates)
315 (asdf:oos 'asdf:load-op 'cl-variates-test)
319 #+srcname: CL-VARIATES-UNITTESTS
321 (in-package :cl-variates-test)
323 (run-tests :suite 'cl-variates-test)
324 (describe (run-tests :suite 'cl-variates-test))
328 **** DONE [#B] Examples of use
329 - State "DONE" from "CURR" [2010-11-05 Fri 15:39] \\
330 basic example of reproducible draws from the uniform and normal random
332 - State "CURR" from "TODO" [2010-11-05 Fri 15:39]
333 - State "TODO" from "" [2010-11-04 Thu 19:01]
335 #+srcname: CL-VARIATES-EXAMPLE-USE
337 (in-package :cl-variates-user)
339 (defparameter state (make-random-number-generator))
340 (setf (random-seed state) 44)
342 (loop for i from 1 to 10 collect
343 (random-range state 0 10))
344 ;; => (1 5 1 0 7 1 2 2 8 10)
345 (setf (random-seed state) 44)
346 (loop for i from 1 to 10 collect
347 (random-range state 0 10))
348 ;; => (1 5 1 0 7 1 2 2 8 10)
350 (setf (random-seed state) 44)
352 (loop for i from 1 to 10 collect
353 (normal-random state 0 1))
355 ;; (-1.2968656102820426 0.40746363934173213 -0.8594712469518473 0.8795681301148328
356 ;; 1.0731526250004264 -0.8161629082481728 0.7001813608754809 0.1078045427044097
357 ;; 0.20750134211656893 -0.14501914108452274)
359 (setf (random-seed state) 44)
360 (loop for i from 1 to 10 collect
361 (normal-random state 0 1))
363 ;; (-1.2968656102820426 0.40746363934173213 -0.8594712469518473 0.8795681301148328
364 ;; 1.0731526250004264 -0.8161629082481728 0.7001813608754809 0.1078045427044097
365 ;; 0.20750134211656893 -0.14501914108452274)
368 **** CURR [#B] Full example of general usage
369 - State "CURR" from "TODO" [2010-11-05 Fri 15:40]
370 - State "TODO" from "" [2010-11-05 Fri 15:40]
372 What we want to do here is describe the basic available API that
373 is present. So while the previous work describes what the
374 *** TODO [#B] CL-RANDOM system evaluation
375 - State "TODO" from "" [2010-11-05 Fri 15:40]
378 1. no seed setting for random numbers
379 2. contamination of a probability support with optimization and
384 2. nice design for generics.
386 *** TODO [#B] Native CLS (from XLS)
387 - State "TODO" from "" [2010-11-05 Fri 15:40]
389 ** TODO [#B] Numerical Linear Algebra
390 - State "TODO" from "" [2010-10-14 Thu 00:12]
392 *** TODO [#B] LLA evaluation
393 - State "TODO" from "" [2010-10-12 Tue 14:13]
394 ;;; experiments with LLA
395 (in-package :cl-user)
396 (asdf:oos 'asdf:load-op 'lla)
397 (in-package :lla-user)
399 *** CURR [#B] Lisp-Matrix system evaluation
400 - State "CURR" from "TODO" [2010-10-12 Tue 14:13]
401 - State "TODO" from "" [2010-10-12 Tue 14:13]
403 *** TODO [#B] LispLab system evaluation
404 - State "TODO" from "" [2010-10-12 Tue 14:13]
406 ** TODO [#B] Statistical Procedures to implement
407 - State "TODO" from "" [2010-10-14 Thu 00:12]
410 (in-package :cls-user)
415 ;; population design eval and opt
423 number of samples/cost of lab analysis and collection
427 (defun pfim (&key model ( constraints ( summary-function )
429 (list num-subjects num-times list-times))))
433 Each individal has a deisgn psi_i
434 nubmer of samples n_i and sampling times t_{i{1}} t_{i{n_1}}
435 individuals can differ
439 individual-level model
442 (=model y_i (+ (f \theta_i \psi_i) epsilion_i ))
443 (=var \epsilion_i \sigma_between \sigma_within )
445 ;; Information Matrix for pop deisgn
447 (defparameter IM (sum (i 1 N) (MF \psi_i \phi_i)))
450 For nonlinear structureal models, expand around RE=0
452 Cramer-Rao : MF^{-1} is lower bound for estimation variance.
456 - smallest SE, but is a matrix, so
457 - criteria for matrix comparison
458 -- D-opt, (power (determinant MF) (/ 1 P))
461 find design maxing D opt, (power (determinant MF) (/ 1 P))
463 -- contin vars for smapling times within interval or set -- number of groups for cat vars
465 Stat in Med 2009, expansion around post-hoc RE est, not necessarily zero.
467 Example binary covariate C
470 (if (= i reference-class)
475 (=model (log \theta) ( ))
482 PFIM provides for a given design and values of \beta:
484 SE/RSE for \beta of each class of each covar
485 eval influence of design on SE(\beta)
487 inter-occassion variability (IOV)
488 - patients sampled more than once, H occassions
490 - additional vars to estimate
494 ;;; comparison criteria
496 functional of conc/time curve which is used for comparison, i.e.
497 (AUC conc/time-curve)
498 (Cmax conc/time-curve)
499 (Tmax conc/time-curve)
503 (defun conc/time-curve (t)
506 (let ((conc (exp (* t \beta1))))
512 (url-get "www.pfim.biostat.fr")
515 ;;; Thinking of generics...
516 (information-matrix model parameters)
517 (information-matrix variance-matrix)
518 (information-matrix model data)
519 (information-matrix list-of-individual-IMs)
522 (defun IM (loglikelihood parameters times)
523 "Does double work. Sum up the resulting IMs to form a full IM."
524 (let ((IM (make-matrix (length parameters)
526 :initial-value 0.0d0)))
527 (dolist (parameterI parameters)
528 (dolist (parameterJ parameters)
530 (differentiate (differentiate loglikelihood parameterI) parameterJ))))))
532 *** difference between empirical, fisherian, and ...? information.
533 *** Example of Integration with CL-GENOMIC
534 - State "TODO" from "" [2010-10-12 Tue 14:03]
536 CL-GENOMIC is a very interesting data-structure strategy for
537 manipulating sequence data.
541 (in-package :cl-user)
542 (asdf:oos 'asdf:compile-op :ironclad)
543 (asdf:oos 'asdf:load-op :cl-genomic)
545 (in-package :bio-sequence)
546 (make-dna "agccg") ;; fine
547 (make-aa "agccg") ;; fine
548 (make-aa "agc9zz") ;; error expected
551 ** TODO [#B] Documentation and Examples [0/3]
552 - State "TODO" from "" [2010-10-14 Thu 00:12]
554 *** TODO [#B] Docudown
555 - State "TODO" from "" [2010-11-05 Fri 15:34]
558 - State "TODO" from "" [2010-11-05 Fri 15:34]
560 *** TODO [#B] CLPDF, and literate data analysis
561 - State "TODO" from "" [2010-11-05 Fri 15:34]