initial description of the SAVE subcommand
[pspp-builds.git] / doc / regression.texi
1 @node REGRESSION, , ONEWAY, Statistics
2 @section REGRESSION
3
4 The REGRESSION procedure fits linear models to data via least-squares
5 estimation. The procedure is appropriate for data which satisfy those
6 assumptions typical in linear regression:
7
8 @itemize @bullet
9 @item The data set contains n observations of a dependent variable, say
10 Y_1,...,Y_n, and n observations of one or more explanatory
11 variables. Let X_11, X_12, ..., X_1n denote the n observations of the
12 first explanatory variable; X_21,...,X_2n denote the n observations of the
13 second explanatory variable; X_k1,...,X_kn denote the n observations of the kth
14 explanatory variable.
15
16 @item The dependent variable Y has the following relationship to the 
17 explanatory variables:
18 @math{Y_i = b_0 + b_1 X_1i + ... + b_k X_ki + Z_i} 
19 where @math{b_0, b_1, ..., b_k} are unknown
20 coefficients, and @math{Z_1,...,Z_n} are independent, normally
21 distributed ``noise'' terms with common variance. The noise, or
22 ``error'' terms are unobserved. This relationship is called the
23 ``linear model.''
24 @end itemize
25
26 The REGRESSION procedure estimates the coefficients
27 @math{b_0,...,b_k} and produces output relevant to inferences for the
28 linear model. 
29
30 @c If you add any new commands, then don't forget to remove the entry in 
31 @c not-implemented.texi
32
33 @menu
34 * Syntax::                      Syntax definition.
35 * Examples::                    Using the REGRESSION procedure.
36 @end menu
37
38 @node Syntax, Examples, , REGRESSION
39 @subsection Syntax
40
41 @vindex REGRESSION
42 @display
43 REGRESSION
44         /VARIABLES=var_list
45         /DEPENDENT=var_list
46         /STATISTICS=@{ALL, DEFAULTS, R, COEFF, ANOVA, BCOV@}
47         /EXPORT ('file-name')
48         /SAVE
49 @end display
50
51 The @cmd{REGRESSION} procedure reads the active file and outputs
52 statistics relevant to the linear model specified by the user.
53
54 The VARIABLES subcommand, which is required, specifies the list of
55 variables to be analyzed.  Keyword VARIABLES is required. The
56 DEPENDENT subcommand specifies the dependent variable of the linear
57 model. The DEPENDENT subcommond is required. All variables listed in
58 the VARIABLES subcommand, but not listed in the DEPENDENT subcommand,
59 are treated as explanatory variables in the linear model.
60
61 All other subcommands are optional:
62
63 The STATISTICS subcommand specifies the statistics to be displayed:
64
65 @table @code
66 @item ALL
67 All of the statistics below.
68 @item R
69 The ratio of the sums of squares due to the model to the total sums of
70 squares for the dependent variable.
71 @item COEFF
72 A table containing the estimated model coefficients and their standard errors.
73 @item ANOVA
74 Analysis of variance table for the model.
75 @item BCOV
76 The covariance matrix for the estimated model coefficients.
77 @end table
78
79 The SAVE subcommand causes PSPP to save the residuals from the fitted
80 model to the active file. PSPP will store the residuals in a variable
81 called RES1 if no such variable exists, RES2 if RES1 already exists,
82 RES3 if RES1 and RES2 already exist, etc.
83
84 The EXPORT subcommand causes PSPP to write a C program containing
85 functions related to the model. One such function accepts values of
86 explanatory variables as arguments, and returns an estimate of the
87 corresponding new
88 value of the dependent variable. The generated program will also contain
89 functions that return prediction and confidence intervals related to
90 those new estimates. PSPP will write the program to the
91 'file-name' given by the user, and write declarations of functions
92 to a file called pspp_model_reg.h. The user can then compile the C
93 program and use it as part of another program. This subcommand is a
94 PSPP extension.
95
96 @node Examples, , Syntax, REGRESSION
97 @subsection Examples
98 The following PSPP code will generate the default output, and save the
99 linear model in a program called ``model.c.''
100
101 @example
102 title 'Demonstrate REGRESSION procedure'.
103 data list / v0 1-2 (A) v1 v2 3-22 (10).
104 begin data.
105 b  7.735648 -23.97588
106 b  6.142625 -19.63854
107 a  7.651430 -25.26557
108 c  6.125125 -16.57090
109 a  8.245789 -25.80001
110 c  6.031540 -17.56743
111 a  9.832291 -28.35977
112 c  5.343832 -16.79548
113 a  8.838262 -29.25689
114 b  6.200189 -18.58219
115 end data.
116 list.
117 regression /variables=v0 v1 v2 /statistics defaults /dependent=v2 /export (model.c) /method=enter.
118 @end example
119
120 The file pspp_model_reg.h contains these declarations:
121
122 @example
123 double pspp_reg_estimate (const double *, const char *[]);
124 double pspp_reg_variance (const double *var_vals, const char *[]);
125 double pspp_reg_confidence_interval_U (const double *var_vals, const char *var_names[], double p);
126 double pspp_reg_confidence_interval_L (const double *var_vals, const char *var_names[], double p);
127 double pspp_reg_prediction_interval_U (const double *var_vals, const char *var_names[], double p);
128 double pspp_reg_prediction_interval_L (const double *var_vals, const char *var_names[], double p);
129 @end example
130
131 The file model.c contains the definitions of the functions. 
132 @setfilename ignored