[R] lm regression: estimate of a categorical variable without being broken into levels

Achim Zeileis Achim.Zeileis at wu-wien.ac.at
Tue Dec 21 21:42:26 CET 2004


On Tue, 21 Dec 2004 12:06:47 -0800 (PST) avneet singh wrote:

> Hello:
> 
> I am new to R and am going through the growing pains,
> wonder if you could help alleviate some.
> 
> I wished to find the estimate for a categorical
> variable without it being broken into levels but dont
> know how to.
> 
> if I use the following example:
> 
> $>data(iris)
> $>g=lm(Sepal.Length~.,iris)
> $>summary(g)
> 
> I get the estimate of the categorical variable
> "Species" broken up into levels.
> 
> $>anova(g)
> 
> Now i get values pertaining to the variable "Species"
> without the levels being broken but i do not get the
> estimate.

There is not "the estimate", there are two estimates (as reported in the
summary above), hence are 2 Df associated with Species.

> Question: Is there a formulae which provides the
> values that "summary" provides but doesnt break up the
> categorical variable into levels?

It is not at all clear to me what you really want. It is the nature of a
categorical variable to fall into different categories (aka levels). If
you want to treat it as if it were numeric, you can transform it to a
numeric variable (not that it would make much sense in this example).

It is also possible that what you are looking for are different
contrasts. See ?contrasts or the corresponding section in MASS4 (the
book).

hth,
Z

> Thank you
> 
> 
> =====
> There are lies, damned lies and statistics. 
> ~Mark Twain
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
>




More information about the R-help mailing list