REGRESSION: Implement /ORIGIN subcommand.
[pspp] / doc / regression.texi
1 @node REGRESSION
2 @section REGRESSION
3
4 @cindex regression
5 @cindex linear regression
6 The @cmd{REGRESSION} procedure fits linear models to data via least-squares
7 estimation. The procedure is appropriate for data which satisfy those
8 assumptions typical in linear regression:
9
10 @itemize @bullet
11 @item The data set contains @math{n} observations of a dependent variable, say
12 @math{Y_1,@dots{},Y_n}, and @math{n} observations of one or more explanatory
13 variables.
14 Let @math{X_{11}, X_{12}}, @dots{}, @math{X_{1n}} denote the @math{n} observations
15 of the first explanatory variable;
16 @math{X_{21}},@dots{},@math{X_{2n}} denote the @math{n} observations of the second
17 explanatory variable;
18 @math{X_{k1}},@dots{},@math{X_{kn}} denote the @math{n} observations of 
19 the @math{k}th explanatory variable.
20
21 @item The dependent variable @math{Y} has the following relationship to the 
22 explanatory variables:
23 @math{Y_i = b_0 + b_1 X_{1i} + ... + b_k X_{ki} + Z_i}
24 where @math{b_0, b_1, @dots{}, b_k} are unknown
25 coefficients, and @math{Z_1,@dots{},Z_n} are independent, normally
26 distributed @dfn{noise} terms with mean zero and common variance.
27 The noise, or @dfn{error} terms are unobserved.
28 This relationship is called the @dfn{linear model}.
29 @end itemize
30
31 The @cmd{REGRESSION} procedure estimates the coefficients
32 @math{b_0,@dots{},b_k} and produces output relevant to inferences for the
33 linear model. 
34
35 @menu
36 * Syntax::                      Syntax definition.
37 * Examples::                    Using the REGRESSION procedure.
38 @end menu
39
40 @node Syntax
41 @subsection Syntax
42
43 @vindex REGRESSION
44 @display
45 REGRESSION
46         /VARIABLES=@var{var_list}
47         /DEPENDENT=@var{var_list}
48         /STATISTICS=@{ALL, DEFAULTS, R, COEFF, ANOVA, BCOV, CI[@var{conf}]@}
49         @{ /ORIGIN | /NOORIGIN @}
50         /SAVE=@{PRED, RESID@}
51 @end display
52
53 The @cmd{REGRESSION} procedure reads the active dataset and outputs
54 statistics relevant to the linear model specified by the user.
55
56 The @subcmd{VARIABLES} subcommand, which is required, specifies the list of
57 variables to be analyzed.  Keyword @subcmd{VARIABLES} is required. The
58 @subcmd{DEPENDENT} subcommand specifies the dependent variable of the linear
59 model. The @subcmd{DEPENDENT} subcommand is required. All variables listed in
60 the @subcmd{VARIABLES} subcommand, but not listed in the @subcmd{DEPENDENT} subcommand,
61 are treated as explanatory variables in the linear model.
62
63 All other subcommands are optional:
64
65 The @subcmd{STATISTICS} subcommand specifies which statistics are to be displayed.
66 The following keywords are accepted:
67
68 @table @subcmd
69 @item ALL
70 All of the statistics below.
71 @item R
72 The ratio of the sums of squares due to the model to the total sums of
73 squares for the dependent variable.
74 @item COEFF
75 A table containing the estimated model coefficients and their standard errors.
76 @item CI (@var{conf})
77 This item is only relevant if COEFF has also been selected.  It specifies that the
78 confidence interval for the coefficients should be printed.  The optional value @var{conf},
79 which must be in parentheses, is the desired confidence level expressed as a percentage.
80 @item ANOVA
81 Analysis of variance table for the model.
82 @item BCOV
83 The covariance matrix for the estimated model coefficients.
84 @item DEFAULT
85 The same as if R, COEFF, and ANOVA had been selected.
86 This is what you get if the /STATISTICS command is not specified,
87 or if it is specified without any parameters.
88 @end table
89
90 The @subcmd{ORIGIN} and @subcmd{NOORIGIN} subcommands are mutually
91 exclusive.  @subcmd{ORIGIN} indicates that the regression should be
92 performed through the origin.  You should use this option if, and
93 only if you have reason to believe that the regression does indeed
94 pass through the origin --- that is to say, the value @math{b_0} above,
95 is zero.  The default is @subcmd{NOORIGIN}.
96
97 The @subcmd{SAVE} subcommand causes @pspp{} to save the residuals or predicted
98 values from the fitted
99 model to the active dataset. @pspp{} will store the residuals in a variable
100 called @samp{RES1} if no such variable exists, @samp{RES2} if @samp{RES1} 
101 already exists,
102 @samp{RES3} if @samp{RES1} and @samp{RES2} already exist, etc. It will
103 choose the name of
104 the variable for the predicted values similarly, but with @samp{PRED} as a
105 prefix.
106 When @subcmd{SAVE} is used, @pspp{} ignores @cmd{TEMPORARY}, treating
107 temporary transformations as permanent.
108
109 @node Examples
110 @subsection Examples
111 The following @pspp{} syntax will generate the default output and save the
112 predicted values and residuals to the active dataset.
113
114 @example
115 title 'Demonstrate REGRESSION procedure'.
116 data list / v0 1-2 (A) v1 v2 3-22 (10).
117 begin data.
118 b  7.735648 -23.97588
119 b  6.142625 -19.63854
120 a  7.651430 -25.26557
121 c  6.125125 -16.57090
122 a  8.245789 -25.80001
123 c  6.031540 -17.56743
124 a  9.832291 -28.35977
125 c  5.343832 -16.79548
126 a  8.838262 -29.25689
127 b  6.200189 -18.58219
128 end data.
129 list.
130 regression /variables=v0 v1 v2 /statistics defaults /dependent=v2 
131            /save pred resid /method=enter.
132 @end example