Hi Paul,

Changing the factor levels will work (as you saw).  In this case, you
could also edit the contrast matrix.

## look at default contrasts
contrasts(gad$dosegrp)
model1 <- lm(hama ~ dosegrp, data = gad)
summary(model1)

## choose group 3 as base (comparison)
contrasts(gad$dosegrp) <- contr.treatment(n = 3, base = 3)
model1 <- lm(hama ~ dosegrp, data = gad)
summary(model1)

If you have MASS 4th ed., I believe a discussion of contrast matrices
starts on page 146.

As far as improvements, in general, I think it would be preferable to
let R's method dispatch system choose the method for summary rather
than specifying summary.aov() yourself.  You might also consider more
spaces (e.g., between arguments).

Cheers,

Josh

On Tue, Mar 1, 2011 at 3:45 PM, Paul Miller <pjmiller...@yahoo.com> wrote:
> Hello Everyone,
>
> Figured out one part of the code. Setting the reference level for a factor is 
> accomplished using the relevel funtion (pg. 383 of MASS; pg. 70 of Data 
> Manipulation with R):
>
> gad$dosegrp <- relevel(gad$dosegrp,3)
>
> This works very well. Much better than using a format in SAS procedures that 
> don't allow the "ref=" option for instance.
>
> Does anyone have suggestions about how to improve other aspects of my code?
>
> Thanks,
>
> Paul

> ______________________________________________
> R-help@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@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.

Reply via email to