[R] regression function for categorical predictor data

Peng, C cpeng.usm at gmail.com
Thu Sep 9 05:12:22 CEST 2010


Sorry, result is not the same, since our datasets are different. I also run
lm() based on the dataset that used in glm(). THe results are exactly the
same:

> summary(lm(Y ~ X + F)) 

Call:
lm(formula = Y ~ X + F)

Residuals:
     Min       1Q   Median       3Q      Max 
-0.53796 -0.16201 -0.08087  0.15080  0.47363 

Coefficients:
            Estimate Std. Error t value Pr(>|t|)    
(Intercept)  0.03723    0.08457   0.440 0.662267    
X            0.51009    0.13036   3.913 0.000365 ***
FB           1.82578    0.15429  11.833  2.6e-14 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 

Residual standard error: 0.2469 on 38 degrees of freedom
Multiple R-squared: 0.9612,     Adjusted R-squared: 0.9592 
F-statistic: 471.1 on 2 and 38 DF,  p-value: < 2.2e-16 


===============
The dataset is given below:

> cbind(Y,X,F)
                Y     X F
 [1,] -0.28473266 -1.00 1
 [2,] -0.59041310 -0.95 1
 [3,] -0.50431754 -0.90 1
 [4,] -0.60095969 -0.85 1
 [5,] -0.45849905 -0.80 1
 [6,] -0.48287208 -0.75 1
 [7,] -0.49598666 -0.70 1
 [8,] -0.08746758 -0.65 1
 [9,] -0.18665177 -0.60 1
[10,] -0.01007210 -0.55 1
[11,] -0.45765308 -0.50 1
[12,] -0.27318684 -0.45 1
[13,]  0.07638855 -0.40 1
[14,]  0.27043727 -0.35 1
[15,]  0.26926216 -0.30 1
[16,] -0.43047783 -0.25 1
[17,]  0.40884468 -0.20 1
[18,] -0.14638563 -0.15 1
[19,] -0.31374179 -0.10 1
[20,] -0.15028159 -0.05 1
[21,] -0.12540519  0.00 1
[22,]  1.58015611  0.05 2
[23,]  1.68200774  0.10 2
[24,]  2.02821901  0.15 2
[25,]  2.02359285  0.20 2
[26,]  2.14133171  0.25 2
[27,]  2.06931685  0.30 2
[28,]  2.05561726  0.35 2
[29,]  2.35720999  0.40 2
[30,]  1.96134404  0.45 2
[31,]  2.26144356  0.50 2
[32,]  2.24454620  0.55 2
[33,]  2.55707426  0.60 2
[34,]  2.18732022  0.65 2
[35,]  1.90950697  0.70 2
[36,]  2.10371010  0.75 2
[37,]  2.18266009  0.80 2
[38,]  2.18490441  0.85 2
[39,]  2.45248295  0.90 2
[40,]  2.79851838  0.95 2
[41,]  1.83514341  1.00 2


-- 
View this message in context: http://r.789695.n4.nabble.com/regression-function-for-categorical-predictor-data-tp2532045p2532305.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list