Hi Robert,
In R, the default treatment contrasts for factor class variables in
regression treats the first level as the reference group when creating
the contrast matrix for the regression, so it is not really a matter
of changing the formula.
This might provide some insight:
http://www.ats.ucla.edu/stat/r/library/contrast_coding.htm
There are many ways to handle categorical data, and without knowing
exactly what you want, it is difficult to give any sound suggestions.
It really depends on your question.
Cheers,
Josh
On Thu, Oct 14, 2010 at 12:34 PM, Robert Quinn <rquinn at fbr.org>
wrote:> I have the following formula for a linear model:
>
> z <- lm(y~x + factor(a) + factor(b), data=NT2010)
>
> where a (groups) and b (Sub-groups) are categorical variables (factors), x
> is a continuous covariate, and y the response variable. ?Since b is nested
> within a, the formula can also be written as:
>
> z <- lm(y~x + factor(a) + factor(a)/factor(b), data=NT2010)
>
> and the same output is achieved when summary(z) is called.
>
> How can I get the output to show all 3 groups that I have inputted? ?There
> are only group 2 and group 3 on the output, group 1 is missing. ?Also there
> is a subgroup (subgroup 1) of the total 9 subgroups missing. ?I would like
> to see the p-value of the missing group and missing sub-group even though
> I'm sure they are not significantly different (>0.05). ?How do I
change the
> original formula to get all groups and sub-groups outputted?
>
>
> ? ? ? ?[[alternative HTML version deleted]]
>
> ______________________________________________
> 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/