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.
6 ;;; File: model-fit.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 ;;; The model class is used to map a partial or complete model
19 ;;; specification (partial specification made complete by assumptions
20 ;;; inherent in the type of model used, i.e. linear regression assumes
21 ;;; mean-zero and homoskedasticity) and the model-fit class is used to
22 ;;; complete the model specification into how the model instance and
23 ;;; type will then get computed. The approach tken is that we
24 ;;; definitiely want to be able to see how we can explicitly try to
25 ;;; characterize the work that we are trying to infere about the data.
29 (defpackage :lisp-stat-model-fit
30 (:documentation
"Model fitting theory.")
31 (:nicknames
:ls-model-fit
)
34 :lisp-stat-object-system
36 :lisp-stat-compound-data
42 (:shadowing-import-from
:lisp-stat-object-system
43 slot-value call-method call-next-method
)
46 (in-package :lisp-stat-model
)
49 ((criteria-functin-name :initform nil
53 (criteria-function :initform nil
57 (parameter-vars :initform nil
58 :initarg
:parameter-vars
60 :reader model-formula
)
61 (data-vars :initform nil
64 :reader model-formula
)
65 (fixed-vars :initform nil
68 :reader model-formula
)
70 (:documentation
"Mathematical Model Fit approach"))
72 (defclass optimization
(model-fit))
75 (defclass least-squares
(optimization))
76 (defclass weighted-least-squares
(least-squares))
78 (defclass maximum-likelihood
(optimization))
79 (defclass minimax
(optimization))
80 (defclass maximin
(optimization))
82 (defclass minimum-entropy
(optimization))
83 (defclass lq-norm
(optimization))
85 (defclass root-finding
(model-fit))
87 (defclass method-of-moments
(root-finding))
88 (defclass marginal-models
(method-of-moments))
89 (defclass gee
(marginal-models))
90 (defclass gee2
(marginal-models))
94 ;;; How would this be used?
97 (new 'least-squares
'(- y
(+ (* beta1 x1
) (* beta2 x2
)))))
99 ;; and there should be an approach which could provide a mapping to this, i.e.
101 (regression-model (list y
) (list x1 x2
))
103 ;; could map to the above via macros.