From bba80ff78a289cb042dd0598ff545c0db09b9385 Mon Sep 17 00:00:00 2001 From: AJ Rossini Date: Sat, 8 Dec 2007 18:09:26 +0100 Subject: [PATCH] model.lisp starting to take shape, similar to conversation on R-devel on mle approaches. --- model.lisp | 140 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 140 insertions(+) diff --git a/model.lisp b/model.lisp index 6bbc8a6..8c69d1d 100644 --- a/model.lisp +++ b/model.lisp @@ -37,3 +37,143 @@ (in-package :lisp-stat-model) +(defclass model () + ((name :initform nil + :initarg :name + :accessor name + :reader model-name) + (form :initform nil + :initarg :formula + :accessor form + :reader model-formula) + (parameter-vars :initform nil + :initarg :parameter-vars + :accessor param-vars + :reader model-formula) + (data-vars :initform nil + :initarg :data-vars + :accessor data-vars + :reader model-formula) + (fixed-vars :initform nil + :initarg :fixed-vars + :accessor fixed-vars + :reader model-formula) + (solution :initform nil + :initarg :criteriaFunction + :accessor critFcn-vars + :reader model-formula) + + (done-solution? :initform nil :reader done-setup?) + (prototypes-initialized? :initform nil :reader prototypes-initialized?) + (current-values :initform nil :accessor current-values) + + (log-file :initform nil :initarg :log-file :reader log-file) + (test-data :initform nil :accessor test-data) + (expected-failure-p :initform nil :initarg :expected-failure-p + :reader expected-failure-p) + (expected-error-p :initform nil :initarg :expected-error-p + :reader expected-error-p) + (expected-problem-p :initform nil :initarg :expected-problem-p + :reader expected-problem-p)) + (:documentation "Mathematical Model")) + +(defclass result (model) + ((param-values ) + (param-uncertainity ) + (param-characterization )) + +;; The following are types of models -- in particular, we can consider +;; that these models + +(defclass statistical-model (model) ) + +(defclass ode-model (model )) + +(defclass linear-regression-model (statistical-mode)) + +(defclass generalized-linear-regression-model (statistical-model)) + +(defclass nonlinear-linear-regression-model (statistical-model)) + + +;;; garbage follows + + +;; modelType + +root +opt (min / max) + +diffeqn + +diffeqn + solve + +;; dataType + +varExtract +tableExtract +relationExtract + + +;; mappingType + +(setf myFirstModel + (defineModel normalLikelihood '((* (/ 1 (sqrt (* 2 (pi) sigma))) + (exp (/ (- x mu) + sigma)))) + :fixed '() + :param '(mu sigma) + :data '(x) + :critFcnSoln '(:max (one-of bfgs nelder-mead conjugate-gradient)))) + +(defclass model () + ((name ) + (vars-fixed :initarg nil :arg fixed) + (vars-param :initarg nil :arg param) + (vars-data :initarg nil :arg data) + (critFcn )) + +(de + + + + +(defclass meanModel (model) ... ) ;; a macro to map onto Model +(defclass meanVarModel (model) ... ) +(defclass regressionModel (meanModel) ) +(defclass mixedModel (regressionModel) ... ) +(defclass bayesianModel (model) ... ) +(defclass diffintgleqnModel (model) ) ;;(ODE, PDF, integral equations) + + + +(setf modX + (solveModel :model myFirstModel + :data myVar + :mapping '((x . myVar)))) + +;; result structure + +(:solution + :params + :params-characterisation + :paradigm '(bayesian frequentist) + :dataname + :modelname ) + + +(with-mapping map :model mymod :data mydata + (bootstrap mymod mydata)) + + +;; solution should inherit from model and data (and be recomputable) +;; func args override embedded args +;; +;; (solveModel firstSoln) "=" firstSoln +;; +;; unless stoch approx used. + +;; + +(defclass + \ No newline at end of file -- 2.11.4.GIT