set up to work on regression modeling. Regression models work, BUT WRONG.
[CommonLispStat.git] / src / stat-models / model-fit.lisp
blob8ec388027da69e8608c1d3068395cae3b3e03a95
1 ;;; -*- mode: lisp -*-
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
9 ;;; on how it arrives.
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.
27 (in-package :cl-user)
29 (defpackage :lisp-stat-model-fit
30 (:documentation "Model fitting theory.")
31 (:nicknames :ls-model-fit)
32 (:use :common-lisp
33 :lisp-stat-config
34 :lisp-stat-object-system
35 :lisp-stat-types
36 :lisp-stat-compound-data
37 #|
38 :lisp-stat-matrix
39 :lisp-stat-linalg
42 (:shadowing-import-from :lisp-stat-object-system
43 slot-value call-method call-next-method)
44 (:export fit))
46 (in-package :lisp-stat-model)
48 (defclass fit ()
49 ((criteria-functin-name :initform nil
50 :initarg :name
51 :accessor name
52 :reader model-name)
53 (criteria-function :initform nil
54 :initarg :formula
55 :accessor function
56 :reader fit-criteria)
57 (parameter-vars :initform nil
58 :initarg :parameter-vars
59 :accessor param-vars
60 :reader model-formula)
61 (data-vars :initform nil
62 :initarg :data-vars
63 :accessor data-vars
64 :reader model-formula)
65 (fixed-vars :initform nil
66 :initarg :fixed-vars
67 :accessor fixed-vars
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?
96 (setf my-regr-model-1
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.