X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=tests%2Flanguage%2Fstats%2Fregression.at;h=70f598ae36414988e46869fb5bd8f62c8466fc80;hb=d84c9fab98875caf8fea1d870bf2a6bceeb36bdc;hp=e520bb1138fe534dfeeb84c365bab3a492b27107;hpb=ccc28b2989e313e79407ed174ec0ebb2302f0b32;p=pspp diff --git a/tests/language/stats/regression.at b/tests/language/stats/regression.at index e520bb1138..70f598ae36 100644 --- a/tests/language/stats/regression.at +++ b/tests/language/stats/regression.at @@ -1,3 +1,19 @@ +dnl PSPP - a program for statistical analysis. +dnl Copyright (C) 2017 Free Software Foundation, Inc. +dnl +dnl This program is free software: you can redistribute it and/or modify +dnl it under the terms of the GNU General Public License as published by +dnl the Free Software Foundation, either version 3 of the License, or +dnl (at your option) any later version. +dnl +dnl This program is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +dnl GNU General Public License for more details. +dnl +dnl You should have received a copy of the GNU General Public License +dnl along with this program. If not, see . +dnl AT_BANNER([LINEAR REGRESSION]) AT_SETUP([LINEAR REGRESSION - basic]) @@ -22,24 +38,26 @@ list. ]) AT_CHECK([pspp -O format=csv regression.sps], [0], [dnl -regression.sps:16: warning: REGRESSION: REGRESSION with SAVE ignores FILTER. All cases will be processed. +"regression.sps:16.82-16.96: warning: REGRESSION: REGRESSION with SAVE ignores FILTER. All cases will be processed. + 16 | regression /variables=v0 v1 v2 /statistics defaults /dependent=v2 /method=enter /save=pred resid. + | ^~~~~~~~~~~~~~~" Table: Model Summary (v2) -,R,R Square,Adjusted R Square,Std. Error of the Estimate -,.971,.942,.925,1.337 +R,R Square,Adjusted R Square,Std. Error of the Estimate +.971,.942,.925,1.337 Table: ANOVA (v2) -,,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,,, +,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) -,,Unstandardized Coefficients,,Standardized Coefficients,, -,,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 +,Unstandardized Coefficients,,Standardized Coefficients,t,Sig. +,B,Std. Error,Beta,, +(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 Table: Data List v0,v1,v2,RES1,PRED1 @@ -80,38 +98,38 @@ list. AT_CHECK([pspp -O format=csv regression.sps], [0], [dnl Table: Model Summary (v2) -,R,R Square,Adjusted R Square,Std. Error of the Estimate -,.971,.942,.925,1.337 +R,R Square,Adjusted R Square,Std. Error of the Estimate +.971,.942,.925,1.337 Table: ANOVA (v2) -,,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,,, +,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) -,,Unstandardized Coefficients,,Standardized Coefficients,, -,,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 +,Unstandardized Coefficients,,Standardized Coefficients,t,Sig. +,B,Std. Error,Beta,, +(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 Table: Model Summary (v2) -,R,R Square,Adjusted R Square,Std. Error of the Estimate -,.971,.942,.925,1.337 +R,R Square,Adjusted R Square,Std. Error of the Estimate +.971,.942,.925,1.337 Table: ANOVA (v2) -,,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,,, +,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) -,,Unstandardized Coefficients,,Standardized Coefficients,, -,,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 +,Unstandardized Coefficients,,Standardized Coefficients,t,Sig. +,B,Std. Error,Beta,, +(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 Table: Data List v0,v1,v2,RES1,PRED1 @@ -160,7 +178,7 @@ data list notable file='regdata.txt' list /g x0 x1 y err *. select if (g = 0). -regression +regression /variables = x0 x1 /dependent = y /statistics = all @@ -181,7 +199,7 @@ data list notable file='regdata.txt' list /g x0 x1 y err *. select if (g = 1). -regression +regression /variables = x0 x1 /dependent = y /statistics = all @@ -202,7 +220,7 @@ data list notable file='regdata.txt' list /g x0 x1 y err *. split file by g. -regression +regression /variables = x0 x1 /dependent = y /statistics = all @@ -238,7 +256,7 @@ end loop. end file. end input program. -regression +regression /variables = x0 x1 /dependent = y ycopy /statistics = default. @@ -1770,20 +1788,20 @@ v0,F8.0 v1,F8.0 Table: Model Summary (v0) -,R,R Square,Adjusted R Square,Std. Error of the Estimate -,.05,.00,.00,8.11 +R,R Square,Adjusted R Square,Std. Error of the Estimate +.05,.00,.00,8.11 Table: ANOVA (v0) -,,Sum of Squares,df,Mean Square,F,Sig. -,Regression,235.23,1,235.23,3.58,.059 -,Residual,98438.40,1498,65.71,, -,Total,98673.63,1499,,, +,Sum of Squares,df,Mean Square,F,Sig. +Regression,235.23,1,235.23,3.58,.059 +Residual,98438.40,1498,65.71,, +Total,98673.63,1499,,, Table: Coefficients (v0) -,,Unstandardized Coefficients,,Standardized Coefficients,, -,,B,Std. Error,Beta,t,Sig. -,(Constant),1.24,.42,.00,2.95,.003 -,v1,1.37,.72,.05,1.89,.059 +,Unstandardized Coefficients,,Standardized Coefficients,t,Sig. +,B,Std. Error,Beta,, +(Constant),1.24,.42,.00,2.95,.003 +v1,1.37,.72,.05,1.89,.059 ]) AT_CLEANUP @@ -1889,7 +1907,7 @@ AT_CHECK([pspp ss.sps], [1], [ignore]) AT_CLEANUP -dnl The following example comes from +dnl The following example comes from dnl http://www.ats.ucla.edu/stat/spss/output/reg_spss%28long%29.htm AT_SETUP([LINEAR REGRESSION coefficient confidence interval]) @@ -2104,28 +2122,28 @@ regression /variables = math female socst read /statistics = coeff r anova ci (95) /dependent = science - /method = enter + /method = enter ]) AT_CHECK([pspp -O format=csv conf.sps], [0], [dnl Table: Model Summary (science) -,R,R Square,Adjusted R Square,Std. Error of the Estimate -,.699,.489,.479,7.148 +R,R Square,Adjusted R Square,Std. Error of the Estimate +.699,.489,.479,7.148 Table: ANOVA (science) -,,Sum of Squares,df,Mean Square,F,Sig. -,Regression,9543.721,4,2385.930,46.695,.000 -,Residual,9963.779,195,51.096,, -,Total,19507.500,199,,, +,Sum of Squares,df,Mean Square,F,Sig. +Regression,9543.721,4,2385.930,46.695,.000 +Residual,9963.779,195,51.096,, +Total,19507.500,199,,, Table: Coefficients (science) -,,Unstandardized Coefficients,,Standardized Coefficients,,,95% Confidence Interval for B, -,,B,Std. Error,Beta,t,Sig.,Lower Bound,Upper Bound -,(Constant),12.325,3.194,.000,3.859,.000,6.027,18.624 -,math,.389,.074,.368,5.252,.000,.243,.535 -,female,-2.010,1.023,-.101,-1.965,.051,-4.027,.007 -,socst,.050,.062,.054,.801,.424,-.073,.173 -,read,.335,.073,.347,4.607,.000,.192,.479 +,Unstandardized Coefficients,,Standardized Coefficients,t,Sig.,95% Confidence Interval for B, +,B,Std. Error,Beta,,,Lower Bound,Upper Bound +(Constant),12.325,3.194,.000,3.859,.000,6.027,18.624 +math,.389,.074,.368,5.252,.000,.243,.535 +female,-2.010,1.023,-.101,-1.965,.051,-4.027,.007 +socst,.050,.062,.054,.801,.424,-.073,.173 +read,.335,.073,.347,4.607,.000,.192,.479 ]) @@ -2157,27 +2175,27 @@ LIST. AT_CHECK([pspp -o pspp.csv regression.sps]) AT_CHECK([cat pspp.csv], [0], [dnl Table: Model Summary (X1) -,R,R Square,Adjusted R Square,Std. Error of the Estimate -,.95,.89,.84,15.08 +R,R Square,Adjusted R Square,Std. Error of the Estimate +.95,.89,.84,15.08 Table: ANOVA (X1) -,,Sum of Squares,df,Mean Square,F,Sig. -,Regression,3820.45,1,3820.45,16.81,.055 -,Residual,454.55,2,227.27,, -,Total,4275.00,3,,, +,Sum of Squares,df,Mean Square,F,Sig. +Regression,3820.45,1,3820.45,16.81,.055 +Residual,454.55,2,227.27,, +Total,4275.00,3,,, Table: Coefficients (X1) -,,Unstandardized Coefficients,,Standardized Coefficients,, -,,B,Std. Error,Beta,t,Sig. -,(Constant),85.45,10.16,.00,8.41,.004 -,Y,-3.73,.91,-.95,-4.10,.055 +,Unstandardized Coefficients,,Standardized Coefficients,t,Sig. +,B,Std. Error,Beta,, +(Constant),85.45,10.16,.00,8.41,.004 +Y,-3.73,.91,-.95,-4.10,.055 Table: Data List text,Y,X1,RES1 -V00276601 ,.00,90.00,4.55 -V00292909 ,10.00,30.00,-18.18 -V00291204 ,20.00,20.00,9.09 -V00300070 ,.00,90.00,4.55 +V00276601,.00,90.00,4.55 +V00292909,10.00,30.00,-18.18 +V00291204,20.00,20.00,9.09 +V00300070,.00,90.00,4.55 ]) AT_CLEANUP @@ -2203,7 +2221,7 @@ regression AT_CHECK([pspp -o pspp.csv empty-parens.sps], [1], [ignore]) -AT_CLEANUP +AT_CLEANUP @@ -2214,25 +2232,25 @@ SET FORMAT=F10.3. DATA LIST notable LIST /number * value *. BEGIN DATA - 16 7.25 - 0 .00 - 1 .10 - 9 27.9 - 0 .00 - 7 3.65 - 14 16.8 - 24 9.15 - 0 .00 - 24 19.0 - 7 4.05 - 12 7.90 - 6 .75 - 11 1.40 - 0 .00 - 3 2.30 - 12 7.60 - 11 6.80 - 16 8.65 + 16 7.25 + 0 .00 + 1 .10 + 9 27.9 + 0 .00 + 7 3.65 + 14 16.8 + 24 9.15 + 0 .00 + 24 19.0 + 7 4.05 + 12 7.90 + 6 .75 + 11 1.40 + 0 .00 + 3 2.30 + 12 7.60 + 11 6.80 + 16 8.65 END DATA. REGRESSION @@ -2244,20 +2262,263 @@ REGRESSION AT_CHECK([pspp -O format=csv regression.sps], [0], [dnl Table: Model Summary (value) -,R,R Square,Adjusted R Square,Std. Error of the Estimate -,.612,.374,.338,6.176 +R,R Square,Adjusted R Square,Std. Error of the Estimate +.612,.374,.338,6.176 + +Table: ANOVA (value) +,Sum of Squares,df,Mean Square,F,Sig. +Regression,388.065,1,388.065,10.173,.005 +Residual,648.498,17,38.147,, +Total,1036.563,18,,, + +Table: Coefficients (value) +,Unstandardized Coefficients,,Standardized Coefficients,t,Sig. +,B,Std. Error,Beta,, +(Constant),.927,2.247,.000,.413,.685 +number,.611,.192,.612,3.189,.005 +]) + +AT_CLEANUP + + + +AT_SETUP([LINEAR REGRESSION /ORIGIN]) +AT_DATA([regression-origin.sps], [dnl +SET FORMAT=F10.3. + +DATA LIST notable LIST /number * value *. +BEGIN DATA + 16 7.25 + 0 .00 + 1 .10 + 9 27.9 + 0 .00 + 7 3.65 + 14 16.8 + 24 9.15 + 0 .00 + 24 19.0 + 7 4.05 + 12 7.90 + 6 .75 + 11 1.40 + 0 .00 + 3 2.30 + 12 7.60 + 11 6.80 + 16 8.65 +END DATA. + +REGRESSION + /STATISTICS COEFF R ANOVA + /DEPENDENT value + /ORIGIN + /METHOD=ENTER number. +]) + + +AT_CHECK([pspp -O format=csv regression-origin.sps], [0], [dnl +Table: Model Summary (value) +R,R Square,Adjusted R Square,Std. Error of the Estimate +.802,.643,.622,6.032 Table: ANOVA (value) -,,Sum of Squares,df,Mean Square,F,Sig. -,Regression,388.065,1,388.065,10.173,.005 -,Residual,648.498,17,38.147,, -,Total,1036.563,18,,, +,Sum of Squares,df,Mean Square,F,Sig. +Regression,1181.726,1,1181.726,32.475,.000 +Residual,654.989,18,36.388,, +Total,1836.715,19,,, Table: Coefficients (value) -,,Unstandardized Coefficients,,Standardized Coefficients,, -,,B,Std. Error,Beta,t,Sig. -,(Constant),.927,2.247,.000,.413,.685 -,number,.611,.192,.612,3.189,.005 +,Unstandardized Coefficients,,Standardized Coefficients,t,Sig. +,B,Std. Error,Beta,, +number,.672,.118,.802,5.699,.000 +]) + +AT_CLEANUP + +dnl This is an example from doc/tutorial.texi +dnl So if the results of this have to be changed in any way, +dnl make sure to update that file. +AT_SETUP([REGRESSION tutorial example]) +cp $top_srcdir/examples/repairs.sav . +AT_DATA([regression.sps], [dnl +GET FILE='repairs.sav'. +REGRESSION /VARIABLES=mtbf duty_cycle /DEPENDENT=mttr. +REGRESSION /VARIABLES=mtbf /DEPENDENT=mttr. ]) -AT_CLEANUP +AT_CHECK([pspp -O format=csv regression.sps], [0], [dnl +Table: Model Summary (Mean time to repair (hours) ) +R,R Square,Adjusted R Square,Std. Error of the Estimate +.94,.89,.88,6.54 + +Table: ANOVA (Mean time to repair (hours) ) +,Sum of Squares,df,Mean Square,F,Sig. +Regression,9576.26,2,4788.13,111.94,.000 +Residual,1154.94,27,42.78,, +Total,10731.20,29,,, + +Table: Coefficients (Mean time to repair (hours) ) +,Unstandardized Coefficients,,Standardized Coefficients,t,Sig. +,B,Std. Error,Beta,, +(Constant),10.59,3.11,.00,3.40,.002 +Mean time between failures (months) ,3.02,.20,.95,14.88,.000 +Ratio of working to non-working time,-1.12,3.69,-.02,-.30,.763 + +Table: Model Summary (Mean time to repair (hours) ) +R,R Square,Adjusted R Square,Std. Error of the Estimate +.94,.89,.89,6.43 + +Table: ANOVA (Mean time to repair (hours) ) +,Sum of Squares,df,Mean Square,F,Sig. +Regression,9572.30,1,9572.30,231.28,.000 +Residual,1158.90,28,41.39,, +Total,10731.20,29,,, + +Table: Coefficients (Mean time to repair (hours) ) +,Unstandardized Coefficients,,Standardized Coefficients,t,Sig. +,B,Std. Error,Beta,, +(Constant),9.90,2.10,.00,4.71,.000 +Mean time between failures (months) ,3.01,.20,.94,15.21,.000 +]) + +AT_CLEANUP + + +AT_SETUP([LINEAR REGRESSION vif]) +AT_DATA([regression-vif.sps], [dnl +SET FORMAT=F10.3. + +data list notable list /competence_x1 motivation_x2 performance_y. +begin data +32 34 36 +35 37 39 +38 45 49 +31 41 41 +36 40 38 +32 38 36 +33 39 37 +31 40 41 +30 37 40 +35 37 43 +31 34 36 +34 32 35 +31 42 34 +25 36 40 +35 42 40 +36 41 44 +30 38 32 +34 41 41 +34 41 44 +22 27 26 +27 26 33 +30 30 35 +30 35 37 +37 39 44 +29 35 36 +31 35 29 +31 45 41 +29 30 32 +29 35 36 +31 37 37 +36 45 42 +32 44 39 +27 26 31 +33 39 35 +20 25 28 +30 36 39 +27 37 39 +25 39 36 +32 38 38 +32 38 35 +end data. + +regression /variables=competence_x1 motivation_x2 + /statistics=defaults tol + /dependent=performance_y + . +]) + + +AT_CHECK([pspp -O format=csv regression-vif.sps], [0], [dnl +Table: Model Summary (performance_y) +R,R Square,Adjusted R Square,Std. Error of the Estimate +.785,.616,.595,2.980 + +Table: ANOVA (performance_y) +,Sum of Squares,df,Mean Square,F,Sig. +Regression,526.494,2,263.247,29.641,.000 +Residual,328.606,37,8.881,, +Total,855.100,39,,, + +Table: Coefficients (performance_y) +,Unstandardized Coefficients,,Standardized Coefficients,t,Sig.,Collinearity Statistics, +,B,Std. Error,Beta,,,Tolerance,VIF +(Constant),7.220,4.020,.000,1.796,.080,, +competence_x1,.432,.166,.358,2.609,.013,.552,1.812 +motivation_x2,.453,.125,.499,3.636,.001,.552,1.812 +]) + +AT_CLEANUP + +AT_SETUP([REGRESSION syntax errors]) +AT_DATA([regression.sps], [dnl +DATA LIST LIST NOTABLE /x y z. +REGRESSION VARIABLES=**. +REGRESSION METHOD=ENTER x/VARIABLES. +REGRESSION DEPENDENT=x/VARIABLES. +REGRESSION DEPENDENT=**. +REGRESSION METHOD=**. +REGRESSION METHOD=ENTER **. +REGRESSION STATISTICS=**. +REGRESSION STATISTICS=CI(**). +REGRESSION STATISTICS=CI(1 **). +REGRESSION SAVE=**. +REGRESSION **. +]) +AT_CHECK([pspp -O format=csv regression.sps], [1], [dnl +"regression.sps:2.22-2.23: error: REGRESSION: Syntax error expecting variable name. + 2 | REGRESSION VARIABLES=**. + | ^~" + +"regression.sps:3.27-3.35: error: REGRESSION: VARIABLES may not appear after METHOD. + 3 | REGRESSION METHOD=ENTER x/VARIABLES. + | ^~~~~~~~~" + +"regression.sps:4.24-4.32: error: REGRESSION: VARIABLES may not appear after DEPENDENT. + 4 | REGRESSION DEPENDENT=x/VARIABLES. + | ^~~~~~~~~" + +"regression.sps:5.22-5.23: error: REGRESSION: Syntax error expecting variable name. + 5 | REGRESSION DEPENDENT=**. + | ^~" + +"regression.sps:6.19-6.20: error: REGRESSION: Syntax error expecting ENTER. + 6 | REGRESSION METHOD=**. + | ^~" + +"regression.sps:7.25-7.26: error: REGRESSION: Syntax error expecting variable name. + 7 | REGRESSION METHOD=ENTER **. + | ^~" + +"regression.sps:8.23-8.24: error: REGRESSION: Syntax error expecting ALL, DEFAULTS, R, COEFF, ANOVA, BCOV, TOL, or CI. + 8 | REGRESSION STATISTICS=**. + | ^~" + +"regression.sps:9.26-9.27: error: REGRESSION: Syntax error expecting number. + 9 | REGRESSION STATISTICS=CI(**). + | ^~" + +"regression.sps:10.28-10.29: error: REGRESSION: Syntax error expecting `@:}@'. + 10 | REGRESSION STATISTICS=CI(1 **). + | ^~" + +"regression.sps:11.17-11.18: error: REGRESSION: Syntax error expecting PRED or RESID. + 11 | REGRESSION SAVE=**. + | ^~" + +"regression.sps:12.12-12.13: error: REGRESSION: Syntax error expecting VARIABLES, DEPENDENT, ORIGIN, NOORIGIN, METHOD, STATISTICS, or SAVE. + 12 | REGRESSION **. + | ^~" +]) +AT_CLEANUP \ No newline at end of file