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 on how it arrives.
9 ;;; Purpose: models as a data summarization tools.
10 ;;; Time-stamp: <2006-05-19 12:33:41 rossini>
11 ;;; Creation: <2006-05-17 21:34:07 rossini>
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 ;;; Work towards an object system with a comprehensive theory of data
18 ;;; summarization through models. The basic idea is that models are
19 ;;; used to summarize different aspects of a data generating process,
20 ;;; possibly realized by a dataset.
24 (defpackage :lisp-stat-model
25 (:documentation
"Model management and other mathematical technologies.")
29 :lisp-stat-object-system
31 :lisp-stat-compound-data
34 (:shadowing-import-from
:lisp-stat-object-system
35 slot-value call-method call-next-method
)
38 (in-package :lisp-stat-model
)
48 :reader model-formula
)
49 (parameter-vars :initform nil
50 :initarg
:parameter-vars
52 :reader model-formula
)
53 (data-vars :initform nil
56 :reader model-formula
)
57 (fixed-vars :initform nil
60 :reader model-formula
)
61 (solution :initform nil
62 :initarg
:criteriaFunction
63 :accessor critFcn-vars
64 :reader model-formula
)
66 (done-solution?
:initform nil
:reader done-setup?
)
67 (prototypes-initialized?
:initform nil
:reader prototypes-initialized?
)
68 (current-values :initform nil
:accessor current-values
)
70 (log-file :initform nil
:initarg
:log-file
:reader log-file
)
71 (test-data :initform nil
:accessor test-data
)
72 (expected-failure-p :initform nil
:initarg
:expected-failure-p
73 :reader expected-failure-p
)
74 (expected-error-p :initform nil
:initarg
:expected-error-p
75 :reader expected-error-p
)
76 (expected-problem-p :initform nil
:initarg
:expected-problem-p
77 :reader expected-problem-p
))
78 (:documentation
"Mathematical Model"))
80 (defclass result
(model)
83 (param-characterization ))
85 ;; The following are types of models -- in particular, we can consider
88 (defclass statistical-model
(model) )
90 (defclass ode-model
(model ))
92 (defclass linear-regression-model
(statistical-mode))
94 (defclass generalized-linear-regression-model
(statistical-model))
96 (defclass nonlinear-linear-regression-model
(statistical-model))
121 (defineModel normalLikelihood
'((* (/ 1 (sqrt (* 2 (pi) sigma
)))
127 :critFcnSoln
'(:max
(one-of bfgs nelder-mead conjugate-gradient
))))
131 (vars-fixed :initarg nil
:arg fixed
)
132 (vars-param :initarg nil
:arg param
)
133 (vars-data :initarg nil
:arg data
)
141 (defclass meanModel
(model) ...
) ;; a macro to map onto Model
142 (defclass meanVarModel
(model) ...
)
143 (defclass regressionModel
(meanModel) )
144 (defclass mixedModel
(regressionModel) ...
)
145 (defclass bayesianModel
(model) ...
)
146 (defclass diffintgleqnModel
(model) ) ;;(ODE, PDF, integral equations)
151 (solveModel :model myFirstModel
153 :mapping
'((x . myVar
))))
159 :params-characterisation
160 :paradigm
'(bayesian frequentist
)
165 (with-mapping map
:model mymod
:data mydata
166 (bootstrap mymod mydata
))
169 ;; solution should inherit from model and data (and be recomputable)
170 ;; func args override embedded args
172 ;; (solveModel firstSoln) "=" firstSoln
174 ;; unless stoch approx used.