[R] How to intepret a factor response model?

Prof Brian Ripley ripley at stats.ox.ac.uk
Wed May 4 10:37:54 CEST 2005


On Wed, 4 May 2005, Maciej [iso-8859-2] BliziDski wrote:

> I'd like to create a model with a factor-type response variable. This is
> an example:

What you have done here is to fit a logistic regression.  The 
interpretation of that is covered in many good books: for example there 
are plots of the predicted values in MASS4.

I do wonder if that is what you intended, though.  You have fitted a model 
of 'two or three' vs 'one'.  You may have intended a multinomial logistic 
model: again MASS4 has details of such models.

>> mydata <- data.frame(factor_var = as.factor(c(rep('one', 100), rep('two', 100), rep('three', 100))), real_var = c(rnorm(150), rnorm(150) + 5))
>> summary(mydata)
> factor_var     real_var
> one  :100   Min.   :-2.742877
> three:100   1st Qu.:-0.009493
> two  :100   Median : 2.361669
>             Mean   : 2.490411
>             3rd Qu.: 4.822394
>             Max.   : 6.924588
>> mymodel = glm(factor_var ~ real_var, family = 'binomial', data = mydata)
>> summary(mymodel)
>
> Call:
> glm(formula = factor_var ~ real_var, family = "binomial", data = mydata)
>
> Deviance Residuals:
>    Min       1Q   Median       3Q      Max
> -1.7442  -0.6774   0.1849   0.3133   2.1187
>
> Coefficients:
>            Estimate Std. Error z value Pr(>|z|)
> (Intercept)  -0.6798     0.1882  -3.613 0.000303 ***
> real_var      0.8971     0.1066   8.417  < 2e-16 ***
> ---
> Signif. codes:  0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1
>
> (Dispersion parameter for binomial family taken to be 1)
>
>    Null deviance: 381.91  on 299  degrees of freedom
> Residual deviance: 213.31  on 298  degrees of freedom
> AIC: 217.31
>
> Number of Fisher Scoring iterations: 6
>
> ---------------------------------------------------------------------
>
> For models with real-type response variable it's easy to figure out,
> what's the equation for the response variable (in the model). But here
> - how do I interpret the model?

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595




More information about the R-help mailing list