[R] regression function for categorical predictor data

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


glm() is another choice. Using glm(), you response variable can be a discrete
random bariable, however, you need to specify the distribution in the
argument: family = " distriubtion name"

Use Teds simulated data and glm(), you get the same result as that produced
in lm():

> summary(glm(Y ~ X + F, family="gaussian")) 

Call:
glm(formula = Y ~ X + F, family = "gaussian")

Deviance 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 

(Dispersion parameter for gaussian family taken to be 0.06096497)

    Null deviance: 59.7558  on 40  degrees of freedom
Residual deviance:  2.3167  on 38  degrees of freedom
AIC: 6.5418

Number of Fisher Scoring iterations: 2

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



More information about the R-help mailing list