pspp-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Multiple Regression with no constant term


From: Ether Jones
Subject: Re: Multiple Regression with no constant term
Date: Tue, 14 Jul 2015 09:54:06 -0400



On Tue, Jul 14, 2015 at 12:23 AM, John Darrington <address@hidden> wrote:
On Mon, Jul 13, 2015 at 04:17:17PM -0400, Ether Jones wrote:
     On Mon, Jul 13, 2015 at 3:10 PM, John Darrington <
     address@hidden> wrote:

     > On Sun, Jul 12, 2015 at 10:45:14PM -0400, Ether Jones wrote:
     >      ???Can someone please post a small working example script using
     > GLM??? (with no
     >      constant term) .
     >
     > Here is one such example:
     >
     > begin data.
     > 1       4       332
     > 1       4       380
     > 1       4       371
     > 1       4       366
     > 1       4       354
     > 1       0       259.5
     > 1       0       302.5
     > 1       0       296
     > 1       0       349
     > 1       0       309
     > 2       4       354.67
     > 2       4       353.5
     > 2       4       304
     > 2       4       365
     > 2       4       339
     > 2       0       306
     > ??????
     > 2       0       339
     > 2       0       353
     > 2       0       351
     > 2       0       333
     > end data.
     >
     > ??????
     > ??????
     > ??????
     > glm points by Factor0 Factor1
     >   /intercept=exclude
     >   .
     >

     Thank you, but ???I ran that script with PSPP ???0.8.5 on Windows and got the
     following output:

Oops.   I dropped the first line when I pasted that code.  Here it is:

data list notable  list /Factor0 * Factor1 * points (F10).

Sorry about that.

​Thank you.  The script runs now.  Here is the output I got:

warning: GLM is experimental.  Do not rely on these results.

Tests of Between-Subjects Effects
#=================#=======================#==#===========#=======#====#
#      Source     #Type III Sum of Squares|df|Mean Square|   F   |Sig.#
#=================#=======================#==#===========#=======#====#
#Model            #             2264685.69| 4|  566171.42| 988.21|.000#
#Factor0          #             2256332.03| 2| 1128166.02|1969.12|.000#
#Factor1          #             2261176.15| 2| 1130588.07|1973.35|.000#
#Factor0 * Factor1#             2259214.79| 2| 1129607.40|1971.64|.000#
#Error            #                9166.87|16|     572.93|       |    #
#Total            #             2273852.56|20|           |       |    #
#=================#=======================#==#===========#=======#====#


 
... but I don't see the regression coefficients (least-squares model parameters) anywhere in the above report​.

I am trying to get PSPP to display the regression coefficients (with no intercept) and the standard error of the regression coefficients.

Here is the output from an Octave script showing what I am looking for:

+ Y = [332, 380, 371, 366, 354, 259.5, 302.5, 296, 349, 309, 354.67, 353.5, 304, 365, 339, 306, 339, 353, 351, 333]'
Y =

         332
         380
         371
         366
         354
       259.5
       302.5
         296
         349
         309
      354.67
       353.5
         304
         365
         339
         306
         339
         353
         351
         333

+ X = [[1, 4]; [1, 4]; [1, 4]; [1, 4]; [1, 4]; [1, 0]; [1, 0]; [1, 0]; [1, 0]; [1, 0]; [2, 4]; [2, 4]; [2, 4]; [2, 4]; [2, 4]; [2, 0]; [2, 0]; [2, 0]; [2, 0]; [2, 0]]
X =

           1           4
           1           4
           1           4
           1           4
           1           4
           1           0
           1           0
           1           0
           1           0
           1           0
           2           4
           2           4
           2           4
           2           4
           2           4
           2           0
           2           0
           2           0
           2           0
           2           0

+ [cases, predictors] = size (X)
cases =         20
predictors =          2
+ degrees_of_freedom = cases - predictors;
+ N = X' * X;
+ d = X' * Y;
+ ## (aka model parameters)
+ coefficients = N \ d
coefficients =

      175.88
      22.026


+ Ye = X * coefficients;
+ ## predicted Y values
+ residuals = Y - Ye;
+ SSres = residuals' * residuals;
+ MSE = SSres / degrees_of_freedom
MSE =      10264
+ standard_error_of_estimate = sqrt (MSE)
standard_error_of_estimate =     101.31
+ Ni = inv (N);
+ standard_error_of_coefficients = sqrt (diag (Ni) * MSE)
standard_error_of_coefficients =

       19.32
        10.8


+ ## actual, predicted, residuals
+ [Y, Ye, Y - Ye]
ans =

         332      263.98      68.021
         380      263.98      116.02
         371      263.98      107.02
         366      263.98      102.02
         354      263.98      90.021
       259.5      175.88      83.624
       302.5      175.88      126.62
         296      175.88      120.12
         349      175.88      173.12
         309      175.88      133.12
      354.67      439.85     -85.185
       353.5      439.85     -86.355
         304      439.85     -135.85
         365      439.85     -74.855
         339      439.85     -100.85
         306      351.75     -45.752
         339      351.75     -12.752
         353      351.75      1.2484
         351      351.75    -0.75164
         333      351.75     -18.752

+ exit ();



​Here is the output from ​Excel:

SUMMARY OUTPUT                               
                               
Regression Statistics                               
Multiple R    65535                           
R Square    -9.359947893                           
Adjusted R Square    -9.99105611                           
Standard Error    101.313174                           
Observations    20                           
                               
ANOVA                               
    df    SS    MS    F    Significance F           
Regression    2    -166924.5475    -83462.27374    -8.131269762    #NUM!           
Residual    18    184758.4659    10264.35922                   
Total    20    17833.91846                       
                               
    Coefficients    Standard Error    t Stat    P-value    Lower 95%    Upper 95%    Lower 95.0%    Upper 95.0%
Intercept    0    #N/A    #N/A    #N/A    #N/A    #N/A    #N/A    #N/A
X Variable 1    175.8758182    19.31966423    9.103461429    3.71387E-08    135.2866784    216.464958    135.2866784    216.464958
X Variable 2    22.02581818    10.80002063    2.039423713    0.056365119    -0.66420076    44.71583712    -0.66420076    44.71583712
                               
                               
                               
RESIDUAL OUTPUT                               
                               
Observation    Predicted Y    Residuals    Standard Residuals                   
1    263.9790909    68.02090909    0.707709876                   
2    263.9790909    116.0209091    1.207116227                   
3    263.9790909    107.0209091    1.113477536                   
4    263.9790909    102.0209091    1.061456041                   
5    263.9790909    90.02090909    0.936604453                   
6    175.8758182    83.62418182    0.87005099                   
7    175.8758182    126.6241818    1.317435847                   
8    175.8758182    120.1241818    1.249807903                   
9    175.8758182    173.1241818    1.80123575                   
10    175.8758182    133.1241818    1.38506379                   
11    439.8549091    -85.18490909    -0.886289264                   
12    439.8549091    -86.35490909    -0.898462293                   
13    439.8549091    -135.8549091    -1.413475093                   
14    439.8549091    -74.85490909    -0.778812855                   
15    439.8549091    -100.8549091    -1.049324629                   
16    351.7516364    -45.75163636    -0.476013704                   
17    351.7516364    -12.75163636    -0.132671837                   
18    351.7516364    1.248363636    0.012988349                   
19    351.7516364    -0.751636364    -0.007820249                   
20    351.7516364    -18.75163636    -0.195097631




Here is ​output from an R script showing what I am trying to do in PSPP
(regression coefficients without intercept, and standard error of coefficients):

​> x0=c(1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2)
> x1=c(4,4,4,4,4,0,0,0,0,0,4,4,4,4,4,0,0,0,0,0)
> points=c(332,380,371,366,354,259.5,302.5,296,349,309,354.67,353.5,304,365,339,306,339,353,351,333)
>
> Ab <- data.frame(points,x0,x1)
>
> LM <- lm(points ~ 0 + .,data="">>
> LM

Call:
lm(formula = points ~ 0 + ., data = "">
Coefficients:
    x0      x1 
175.88   22.03 


>
> summary(LM)

Call:
lm(formula = points ~ 0 + ., data = "">
Residuals:
    Min      1Q  Median      3Q     Max
-135.85  -53.03   34.63  109.27  173.12

Coefficients:
   Estimate Std. Error t value Pr(>|t|)   
x0   175.88      19.32   9.103 3.71e-08 ***
x1    22.03      10.80   2.039   0.0564 . 
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 101.3 on 18 degrees of freedom
Multiple R-squared:  0.9187,    Adjusted R-squared:  0.9097
F-statistic: 101.8 on 2 and 18 DF,  p-value: 1.544e-10

>
> sqrt(diag(vcov(LM)))
      x0       x1
19.31966 10.80002



reply via email to

[Prev in Thread] Current Thread [Next in Thread]