2 ;;; Copyright (c) 2005--2007, by A.J. Rossini <blindglobe@gmail.com>
3 ;;; See COPYRIGHT file for any additional restrictions (BSD license).
4 ;;; Since 1991, ANSI was finally finished. Edited for ANSI Common Lisp.
7 ;;; Author: AJ Rossini <blindglobe@gmail.com>
8 ;;; Copyright: (c)2007, AJ Rossini. BSD, LLGPL, or GPLv2, depending
10 ;;; Purpose: models as a data summarization tools.
11 ;;; Time-stamp: <2006-05-19 12:33:41 rossini>
12 ;;; Creation: <2006-05-17 21:34:07 rossini>
14 ;;; What is this talk of 'release'? Klingons do not make software
15 ;;; 'releases'. Our software 'escapes', leaving a bloody trail of
16 ;;; designers and quality assurance people in its wake.
18 ;;; Work towards an object system with a comprehensive theory of data
19 ;;; summarization through models. The basic idea is that models are
20 ;;; used to summarize different aspects of a data generating process,
21 ;;; possibly realized by a dataset.
25 (defpackage :lisp-stat-model
26 (:documentation
"Model management and other mathematical technologies.")
30 :lisp-stat-object-system
32 :lisp-stat-compound-data
35 (:shadowing-import-from
:lisp-stat-object-system
36 slot-value call-method call-next-method
)
39 (in-package :lisp-stat-model
)
49 :reader model-formula
)
50 (parameter-vars :initform nil
51 :initarg
:parameter-vars
53 :reader model-formula
)
54 (data-vars :initform nil
57 :reader model-formula
)
58 (fixed-vars :initform nil
61 :reader model-formula
)
62 (solution :initform nil
63 :initarg
:criteriaFunction
64 :accessor critFcn-vars
65 :reader model-formula
)
67 (done-solution?
:initform nil
:reader done-setup?
)
68 (prototypes-initialized?
:initform nil
:reader prototypes-initialized?
)
69 (current-values :initform nil
:accessor current-values
)
71 (log-file :initform nil
:initarg
:log-file
:reader log-file
)
72 (test-data :initform nil
:accessor test-data
)
73 (expected-failure-p :initform nil
:initarg
:expected-failure-p
74 :reader expected-failure-p
)
75 (expected-error-p :initform nil
:initarg
:expected-error-p
76 :reader expected-error-p
)
77 (expected-problem-p :initform nil
:initarg
:expected-problem-p
78 :reader expected-problem-p
))
79 (:documentation
"Mathematical Model"))
81 (defclass result
(model)
84 (param-characterization ))
86 ;; The following are types of models -- in particular, we can consider
89 (defclass statistical-model
(model) )
91 (defclass ode-model
(model ))
93 (defclass linear-regression-model
(statistical-mode))
95 (defclass generalized-linear-regression-model
(statistical-model))
97 (defclass nonlinear-linear-regression-model
(statistical-model))
124 (defineModel normalLikelihood
'((* (/ 1 (sqrt (* 2 (pi) sigma
)))
130 :critFcnSoln
'(:max
(one-of bfgs nelder-mead conjugate-gradient
))))
134 (vars-fixed :initarg nil
:arg fixed
)
135 (vars-param :initarg nil
:arg param
)
136 (vars-data :initarg nil
:arg data
)
144 (defclass meanModel
(model) ...
) ;; a macro to map onto Model
145 (defclass meanVarModel
(model) ...
)
146 (defclass regressionModel
(meanModel) )
147 (defclass mixedModel
(regressionModel) ...
)
148 (defclass bayesianModel
(model) ...
)
149 (defclass diffintgleqnModel
(model) ) ;;(ODE, PDF, integral equations)
154 (solveModel :model myFirstModel
156 :mapping
'((x . myVar
))))
162 :params-characterisation
163 :paradigm
'(bayesian frequentist
)
168 (with-mapping map
:model mymod
:data mydata
169 (bootstrap mymod mydata
))
172 ;; solution should inherit from model and data (and be recomputable)
173 ;; func args override embedded args
175 ;; (solveModel firstSoln) "=" firstSoln
177 ;; unless stoch approx used.