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