Dear Jinsong, Why do you say that the coefficients are wrong? The slope is 1 and the intercept 0 (within rounding) -- Isn't this what you intended?
John On Fri, 6 Feb 2004 08:50:36 -0800 (PST) Jinsong Zhao <[EMAIL PROTECTED]> wrote: > Dear all, > > The following is a example that I run and hope to get a linear model. > However, I find the lm() can not give correct coefficients for the > linear model. > > I hope it's just my own mistake. Please help. TIA. > > Regards, > > Jinsong > > > x > [1] 3.760216 3.997288 3.208872 3.985417 3.265704 3.497505 2.923540 > 3.193937 > [9] 3.102787 3.419574 3.169374 2.928510 3.153821 3.100385 3.768770 > 3.610583 > [17] 3.588902 3.180961 3.415033 3.595447 2.826521 3.283875 3.125694 > 3.558275 > [25] 4.625191 3.735673 4.387571 4.884388 3.067845 2.993892 3.068684 > 4.166771 > [33] 4.680322 4.103344 4.340546 3.685950 4.026451 4.161470 3.696610 > 4.026815 > [41] 3.854591 3.399321 3.492201 3.479075 4.417633 3.579751 3.433551 > 3.248359 > [49] 2.874979 3.123579 3.131758 3.447368 3.086075 3.558168 4.537077 > > y > [1] 4.431 4.560 2.920 4.481 3.295 3.679 2.779 2.654 2.837 3.664 > 3.421 > 2.693 > [13] 2.624 3.057 4.633 3.807 3.886 3.011 3.873 3.717 2.077 3.324 > 2.064 > 3.390 > [25] 4.170 3.232 3.114 4.701 3.746 2.880 3.723 4.015 4.881 4.483 > 4.762 > 3.834 > [37] 4.321 3.837 3.624 4.306 3.466 3.492 3.502 3.510 4.236 3.286 > 3.657 > 3.218 > [49] 2.840 3.011 3.417 3.625 3.524 3.390 4.296 > > g <- lm(y ~ x) > > summary(g) > > Call: > lm(formula = y ~ x) > > Residuals: > Min 1Q Median 3Q Max > -1.2736 -0.2094 0.0098 0.2654 0.8642 > > Coefficients: > Estimate Std. Error t value Pr(>|t|) > (Intercept) -1.274e-15 4.027e-01 -3.16e-15 1 > x 1.000e+00 1.113e-01 8.982 3.13e-12 *** > --- > Signif. codes: 0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1 > > Residual standard error: 0.4179 on 53 degrees of freedom > Multiple R-Squared: 0.6035, Adjusted R-squared: 0.596 > F-statistic: 80.68 on 1 and 53 DF, p-value: 3.128e-12 > > > > __________________________________ > > Yahoo! Finance: Get your refund fast by filing online. > > ______________________________________________ > [EMAIL PROTECTED] mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html ______________________________________________ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
