[R] overall comparison of an ordered categorical in a multiple regression
David Winsemius
dwinsemius at comcast.net
Thu Feb 21 16:17:21 CET 2008
"Angelo Passalacqua" <apassala at gmail.com> wrote in
news:d484d1550802210625i6b49868ct325d5623c6e6c9f2 at mail.gmail.com:
> I entered the following:
>
> formula<-nst~age+soc+inc+reg+imp
>
> pnstlm<-lm(formula,nst)
>
> summary(pnstlm)
>
> imp and soc are ordered categorical variables but the summary does
> not give an output of the overall p-values, just individual
> comparisons. I can't find help for this in the manual. Is there a
> command or option change in the summary to find out the overall
> p-value?
Simpson's suggestion is far simpler than my solution, and probably
answers your question more accurately, but here is another way of looking
at regression with ordered independent variables:
If the levels of the factor are ordered as you expect them (and even if
the factor is not of class "ordered factor"), rather than some default
alpha ordering, then you could try:
pnstlm2 <- lm(nst ~ age +
as.numeric(soc) +
inc +
reg +
as.numeric(imp), data=nst)
They won't be centered, but in this simple model, that will only change
the intercept. The coefficients will be the change in nst$nst per single
factor increase in "soc" or "imp". The difference in deviance between
your first model and the one you have now will be a test of joint
linearity of "imp" and "soc" in relation to "nst". (You probably want to
construct them individually.)
(Personally, I think it is a bad practice to create a variable with the
same name as a dataframe.)
--
David Winsemius
More information about the R-help
mailing list