Re: [R] Relevel() catagorical variables in a GLM

From: Joshua Wiley <jwiley.psych_at_gmail.com>
Date: Sat, 28 May 2011 23:48:16 -0700

Hi Ashley,

It does not look like you have done the wrong thing to me. The results will be different because eacho f the parameter estimates is now the change from SS to ___ instead of from HH to ____. In fact, from your first table, you can calculate all the parameters in the second. The intercept for SS as reference is:

(-5.2671) + (-18.2990) = -23.5661

the difference between SH and SS is:
> (-0.5736) - (-18.2990)

[1] 17.7254

which is now the parameter estimate for SH in the SS as reference model. You could go on in like fashion for the rest.

HTH, Josh

On Sat, May 28, 2011 at 4:27 PM, ashley <aknight_at_csumb.edu> wrote:
> Hello list readers,
>
> I am running a set of GLMs on fish spp presence/absence as a function of
> various habitat characteristics. My response is binomial and I have four
> predictors, three of which are categorical.
>
> So, R takes one of my predictor-variables away to use as the intercept (the
> first one alphabetically). However, I want to know the coefficient and SE of
> this predictor. I tried relevel() and reran the model. Abbreviated summary()
> results for each run are below. The results seem drastically different. Have
> I done the wrong thing?
>
> (Below is a result from the model with only one predictor, to save space and
> hassle.)
>
> Thanks,
> Ashley
>
> #Default reference level = HH:
>
>                                 Estimate Std. Error z value Pr(>|z|)
> (Intercept)                     -5.2671     0.2781 -18.942   <2e-16 ***
> raw.table$SubsComboHS    0.8127     0.6438   1.262    0.207
> raw.table$SubsComboSH  -0.5736     1.0393  -0.552    0.581
> raw.table$SubsComboSS -18.2990   923.6023  -0.020    0.984
>
> #Command used to change reference level:
>> raw.table$SubsCombo<-relevel(raw.table$SubsCombo, ref="SS")
>
> #New reference level = SS:
>
>                                   Estimate Std. Error z value Pr(>|z|)
> (Intercept)                     -23.57     923.60  -0.026    0.980
> raw.table$SubsComboHH    18.30     923.60   0.020    0.984
> raw.table$SubsComboHS    19.11     923.60   0.021    0.983
> raw.table$SubsComboSH    17.73     923.60   0.019    0.985
>
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Relevel-catagorical-variables-in-a-GLM-tp3558181p3558181.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help_at_r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

-- 
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.com/

______________________________________________
R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Sun 29 May 2011 - 06:50:10 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sun 29 May 2011 - 09:30:10 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive