3 ;;; Time-stamp: <2009-10-06 11:17:37 tony>
4 ;;; Creation: <2009-03-12 17:14:56 tony>
6 ;;; Author: AJ Rossini <blindglobe@gmail.com>
7 ;;; Copyright: (c)2009--, AJ Rossini. Currently licensed under MIT
8 ;;; license. See file LICENSE.mit in top-level directory
10 ;;; Purpose: Template header file for Statistical Procedures
12 ;;; What is this talk of 'release'? Klingons do not make software
13 ;;; 'releases'. Our software 'escapes', leaving a bloody trail of
14 ;;; designers and quality assurance people in its wake.
16 ;;; This organization and structure is new to the 21st Century
17 ;;; version.. Think, "21st Century Schizoid Man".
19 (in-package :cls-statproc
)
21 ;;; Set up the data and metadata requirements
22 (define-statistical-proc-metadata t-test
/metadata
()
23 '((verify :number-of-variables
2)
24 (verify :variable-exists
(discrete :levels
2) 'independent
'group
)
25 (verify :variable-exists
'continuous
'dependent
)))
27 ;;; Set up the t-test class. This should provide the code for processing.
28 (define-statistical-proc-class t-test
/class
())
30 ;;; Set up the class for the results. This should store the processed
31 ;;; results. i.e. instantiated proc:
32 ;;; data + analytic proc(s) => instantiated proc
34 (define-statistical-proc-results t-test
/results
()
35 ((:variables
'(group response
))
36 (:evaluate
'(defun t-test (group response
)
37 "Estimate t-test statistic from data."
38 (let ((2listsofdata (split response
:by group
))
39 (mean1 (mean (elt 2listsofdata
0)))
40 (mean2 (mean (elt 2listsofdata
1)))
41 (stddev1 (standard-deviation (elt 2listsofdata
0)))
42 (stddev2 (standard-deviation (elt 2listsofdata
1))))
44 (sqrt (* (/ stddev1 n1
) (/ stddev2 n2
) ))))))
45 (:result-form
'(test-statistic :following t-distribution
))
46 (:documentation
"...")))
48 ;;; Define how the generics should work with this
49 (defmethod print-object ((proc t-test
/class
)))
50 (defmethod print-object ((results t-test
/results
)))
51 (defmethod print-object ((metadata t-test
/metadata
)))
54 (defmethod proc-consistent-data-p ((metadata t-test
/metadata
)
55 (data dataframe-like
))
56 ;; verify only 2 variables.
57 ;; verify that one variable has the attributes response and continuous.
58 ;; verify that the other variable has the attributes dependent, discrete, group (2 levels).
61 (defmethod process-data ((obj t-test
/class
)
62 (data dataframe-like
)))
65 (defmethod display-results ((results t-test
/results
)))
67 (defmethod print-results ((results t-test
/results
)))
69 (defmethod visualize-results ((results t-test
/results
)))
71 (defmethod simulate-data-from-results ((results t-test
/results
)
72 &key
(newdata (obj2 t-test
/data
))))
74 (defmethod simulate-data-from-proc ((obj t-test
/results
)))