,.971,.942,.925,1.337
Table: ANOVA (v2)
-,,Sum of Squares,df,Mean Square,F,Significance
+,,Sum of Squares,df,Mean Square,F,Sig.
,Regression,202.753,2,101.376,56.754,.000
,Residual,12.504,7,1.786,,
,Total,215.256,9,,,
Table: Coefficients (v2)
-,,B,Std. Error,Beta,t,Significance
+,,B,Std. Error,Beta,t,Sig.
,(Constant),2.191,2.357,.000,.930,.380
,v0,1.813,1.053,.171,1.722,.129
,v1,-3.427,.332,-1.026,-10.334,.000
])
AT_CLEANUP
+
+# Test to ensure that the /SAVE subcommand works properly when SPLIT is active
+AT_SETUP([LINEAR REGRESSION - SAVE vs SPLITS])
+
+# Generate some test data based on a linear model
+AT_DATA([gen-data.sps], [dnl
+set seed = 1.
+input program.
+loop #c = 1 to 20.
+ compute x0 = rv.normal (0,1).
+ compute x1 = rv.normal (0,2).
+ compute err = rv.normal (0,0.1).
+ compute y = 4 - 2 * x0 + 3 * x1 + err.
+ compute g = (#c > 10).
+ end case.
+end loop.
+end file.
+end input program.
+
+print outfile='regdata.txt' /g x0 x1 y err *.
+execute.
+])
+
+AT_CHECK([pspp -O format=csv gen-data.sps], [0], [ignore])
+
+# Use our test data to create a predictor and a residual variable
+# for G == 0
+AT_DATA([regression0.sps], [dnl
+data list notable file='regdata.txt' list /g x0 x1 y err *.
+
+select if (g = 0).
+
+regression
+ /variables = x0 x1
+ /dependent = y
+ /statistics = all
+ /save = pred resid.
+ .
+
+print outfile='outdata-g0.txt' /g x0 x1 y err res1 pred1 *.
+execute.
+])
+
+
+AT_CHECK([pspp -O format=csv regression0.sps], [0], [ignore])
+
+# Use our test data to create a predictor and a residual variable
+# for G == 1
+AT_DATA([regression1.sps], [dnl
+data list notable file='regdata.txt' list /g x0 x1 y err *.
+
+select if (g = 1).
+
+regression
+ /variables = x0 x1
+ /dependent = y
+ /statistics = all
+ /save = pred resid.
+ .
+
+print outfile='outdata-g1.txt' /g x0 x1 y err res1 pred1 *.
+execute.
+])
+
+
+AT_CHECK([pspp -O format=csv regression1.sps], [0], [ignore])
+
+# Use our test data to create a predictor and a residual variable
+# The data is split on G
+AT_DATA([regression-split.sps], [dnl
+data list notable file='regdata.txt' list /g x0 x1 y err *.
+
+split file by g.
+
+regression
+ /variables = x0 x1
+ /dependent = y
+ /statistics = all
+ /save = pred resid.
+ .
+
+print outfile='outdata-split.txt' /g x0 x1 y err res1 pred1 *.
+execute.
+])
+
+AT_CHECK([pspp -O format=csv regression-split.sps], [0], [ignore])
+
+# The concatenation of G==0 and G==1 should be identical to the SPLIT data
+AT_CHECK([cat outdata-g0.txt outdata-g1.txt | diff outdata-split.txt - ], [0], [])
+
+AT_CLEANUP
+
+
+# Test that the procedure behaves sensibly when presented with
+# multiple dependent variables
+AT_SETUP([LINEAR REGRESSION multiple dependent variables])
+AT_DATA([regression.sps], [dnl
+set seed = 2.
+input program.
+loop #c = 1 to 200.
+ compute x0 = rv.normal (0, 1).
+ compute x1 = rv.normal (0, 2).
+ compute err = rv.normal (0, 0.8).
+ compute y = 2 - 1.5 * x0 + 8.4 * x1 + err.
+ compute ycopy = y.
+ end case.
+end loop.
+end file.
+end input program.
+
+regression
+ /variables = x0 x1
+ /dependent = y ycopy
+ /statistics = all
+])
+
+AT_CHECK([pspp -O format=csv regression.sps > output], [0], [ignore])
+
+
+AT_CHECK([head -16 output > first], [0], [])
+AT_CHECK([tail -16 output > second], [0], [])
+
+AT_CHECK([sed -e 's/ycopy/y/g' second | diff first -], [0], [])
+
+
+AT_CLEANUP
+
# Tests the QR decomposition used by the REGRESSION command.
AT_SETUP([LINEAR REGRESSION test of QR decomposition])
AT_DATA([regression.sps], [dnl
,.05,.00,.00,8.11
Table: ANOVA (v0)
-,,Sum of Squares,df,Mean Square,F,Significance
+,,Sum of Squares,df,Mean Square,F,Sig.
,Regression,235.23,1,235.23,3.58,.06
,Residual,98438.40,1498,65.71,,
,Total,98673.63,1499,,,
Table: Coefficients (v0)
-,,B,Std. Error,Beta,t,Significance
+,,B,Std. Error,Beta,t,Sig.
,(Constant),1.24,.42,.00,2.95,.00
,v1,1.37,.72,.05,1.89,.06
,,,,,,