[R] difference in results from R vs SPSS
(Ted Harding)
Ted.Harding at nessie.mcc.ac.uk
Sun Jun 25 12:34:38 CEST 2006
On 24-Jun-06 Fiona Sammut wrote:
> Thanks for the reply. The mistake in 1 resulted to be due to using a
> different number of decimal places in the data.
If using a different number of decimal places results in such
a large difference, you need to seriously consider whether a
regression can give meaningful results at all with your data.
What do the SEs of the coefficients look like? In R, do
summary(lm(y ~ x))
For example, I tried the following (in R):
x<-0.1*(0:10)
y<-x + rnorm(11)
y3<-round(y,3)
y1<-round(y,1)
so
y3:
0.058 0.165 1.329 -0.964 -0.896 0.888
-1.124 0.630 -0.544 0.702 0.944
y1:
0.1 0.2 1.3 -1.0 -0.9 0.9
-1.1 0.6 -0.5 0.7 0.9
and then:
summary(lm(y3~x))
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -0.07014 0.51113 -0.137 0.894
x 0.35627 0.86396 0.412 0.690
summary(lm(y1~x))
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -0.05455 0.50562 -0.108 0.916
x 0.32727 0.85465 0.383 0.711
so here too there are differences between y3~x and y1~x
not unlike yours (23% in intercept compared with your 29%,
8% in x-coefficient compared with your 9%) purely as a
result of rounding. But the SEs of intercept and x-coeff
are large, so there is very little information about what
their values should be: in round figures, a 95%CI for the
intercept would be -0.06 +/- 2.26*0.5 = (-1.19, 1.07), and
for the x-coeff 0.34 +/- 2.26*0.86 = (-1.60, 2.28). Compared
with this, the distinction between the regressions y3~x and
y1~x is at the limit of subtlety -- otherwise put, it wouldn't
matter a lot what the data were!
Best wishes,
Ted.
> As regards 2, will check it out again.
>
> Thanks again.
>
>> Fiona Sammut wrote:
>>> Hi all,
>>>
>>> 1. I am doing some data analysis using both R and SPSS, to get used
>>> to both software packages. I had performed linear regression in R
>>> and SPSS for a number of times before this last one and the resulting
>>> coefficient values always matched. However, this last data set I was
>>> analyzing using simple linear regression and using the command
>>> lm(y~x), gave me different readings from R and SPSS:
>>>
>>> R: y= 33.803 + 6.897x
>>>
>>> SPSS: y= 47.589 + 6.263x
>>>
>>> I have no doubts regarding the procedure employed in SPSS and I am
>>> sure I am using the same dataset for both software packages.
>>> [...]
--------------------------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at nessie.mcc.ac.uk>
Fax-to-email: +44 (0)870 094 0861
Date: 25-Jun-06 Time: 11:34:30
------------------------------ XFMail ------------------------------
More information about the R-help
mailing list