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
38 (:shadowing-import-from
:lisp-stat-object-system
39 slot-value call-method call-next-method
)
42 (in-package :lisp-stat-model
)
52 :reader model-formula
)
53 (parameter-vars :initform nil
54 :initarg
:parameter-vars
56 :reader model-formula
)
57 (data-vars :initform nil
60 :reader model-formula
)
61 (fixed-vars :initform nil
64 :reader model-formula
)
65 (solution :initform nil
66 :initarg
:criteriaFunction
67 :accessor critFcn-vars
68 :reader model-formula
)
70 (done-solution?
:initform nil
:reader done-setup?
)
71 (prototypes-initialized?
:initform nil
:reader prototypes-initialized?
)
72 (current-values :initform nil
:accessor current-values
)
74 (log-file :initform nil
:initarg
:log-file
:reader log-file
)
75 (test-data :initform nil
:accessor test-data
)
76 (expected-failure-p :initform nil
:initarg
:expected-failure-p
77 :reader expected-failure-p
)
78 (expected-error-p :initform nil
:initarg
:expected-error-p
79 :reader expected-error-p
)
80 (expected-problem-p :initform nil
:initarg
:expected-problem-p
81 :reader expected-problem-p
))
82 (:documentation
"Mathematical Model"))
84 (defclass result
(model)
87 (param-characterization ))
89 ;; The following are types of models -- in particular, we can consider
92 (defclass statistical-model
(model) )
94 (defclass ode-model
(model ))
96 (defclass linear-regression-model
(statistical-mode))
98 (defclass generalized-linear-regression-model
(statistical-model))
100 (defclass nonlinear-linear-regression-model
(statistical-model))
127 (defineModel normalLikelihood
'((* (/ 1 (sqrt (* 2 (pi) sigma
)))
133 :critFcnSoln
'(:max
(one-of bfgs nelder-mead conjugate-gradient
))))
137 (vars-fixed :initarg nil
:arg fixed
)
138 (vars-param :initarg nil
:arg param
)
139 (vars-data :initarg nil
:arg data
)
147 (defclass meanModel
(model) ...
) ;; a macro to map onto Model
148 (defclass meanVarModel
(model) ...
)
149 (defclass regressionModel
(meanModel) )
150 (defclass mixedModel
(regressionModel) ...
)
151 (defclass bayesianModel
(model) ...
)
152 (defclass diffintgleqnModel
(model) ) ;;(ODE, PDF, integral equations)
157 (solveModel :model myFirstModel
159 :mapping
'((x . myVar
))))
165 :params-characterisation
166 :paradigm
'(bayesian frequentist
)
171 (with-mapping map
:model mymod
:data mydata
172 (bootstrap mymod mydata
))
175 ;; solution should inherit from model and data (and be recomputable)
176 ;; func args override embedded args
178 ;; (solveModel firstSoln) "=" firstSoln
180 ;; unless stoch approx used.