Hulliger Beat

2017-04-25 07:39:45 UTC

Last week a student asked me whether he should eliminate the intercept in a simple linear regression when it is not significantly different from 0. Yes, I said: It is very simple to remove it in PSPP. How wrong was I! There is no option /NOORIGIN in the PSPP Regression procedure.

I have seen the discussions about this issue and the corresponding proposals. I tried GLM but no coefficients are output. I tried with dummies but a bit of algebra convinced me that this does not work. I thought the simplest thing is to delete the column of ones in the design matrix. I have downloaded the code and looked into linreg.c. Of course, things are a bit more complicated than it seems at first. Say, my knowledge of C is not enough to venture into the code.

So back to crude SPSS-Syntax for simple linear regression (say a ratio model): See the code below.

It would be nice to have a /noorigin option in the Regression procedure!

Beat

-------------

* Regression through the origin: Ratio model with PSPP.

* Assign y and x.

compute y = Balance.

compute x = ATM.

* Regression y=beta*x.

COMPUTE xx = x * x.

COMPUTE yx = y * x.

COMPUTE one = 1.

EXECUTE.

AGGREGATE OUTFILE=* MODE=ADDVARIABLES

/PRESORTED

/BREAK= one

/sumyx = SUM (yx)

/sumxx = SUM (xx)

/nsamp = sum(one).

COMPUTE beta = sumyx/sumxx.

COMPUTE resid = y - beta * x.

COMPUTE resid2 = resid * resid.

AGGREGATE OUTFILE=* MODE=ADDVARIABLES

/PRESORTED

/BREAK= one

/SSE = SUM (resid2).

COMPUTE SER = sqrt(SSE/(nsamp-1)).

EXECUTE.

LIST

/Variables beta SER

/cases = from 1 to 1.

delete variables y x one yx xx sumyx sumxx nsamp beta resid2 SSE SER.

I have seen the discussions about this issue and the corresponding proposals. I tried GLM but no coefficients are output. I tried with dummies but a bit of algebra convinced me that this does not work. I thought the simplest thing is to delete the column of ones in the design matrix. I have downloaded the code and looked into linreg.c. Of course, things are a bit more complicated than it seems at first. Say, my knowledge of C is not enough to venture into the code.

So back to crude SPSS-Syntax for simple linear regression (say a ratio model): See the code below.

It would be nice to have a /noorigin option in the Regression procedure!

Beat

-------------

* Regression through the origin: Ratio model with PSPP.

* Assign y and x.

compute y = Balance.

compute x = ATM.

* Regression y=beta*x.

COMPUTE xx = x * x.

COMPUTE yx = y * x.

COMPUTE one = 1.

EXECUTE.

AGGREGATE OUTFILE=* MODE=ADDVARIABLES

/PRESORTED

/BREAK= one

/sumyx = SUM (yx)

/sumxx = SUM (xx)

/nsamp = sum(one).

COMPUTE beta = sumyx/sumxx.

COMPUTE resid = y - beta * x.

COMPUTE resid2 = resid * resid.

AGGREGATE OUTFILE=* MODE=ADDVARIABLES

/PRESORTED

/BREAK= one

/SSE = SUM (resid2).

COMPUTE SER = sqrt(SSE/(nsamp-1)).

EXECUTE.

LIST

/Variables beta SER

/cases = from 1 to 1.

delete variables y x one yx xx sumyx sumxx nsamp beta resid2 SSE SER.