Re: [R] Pairwise T-Tests and Dunnett's Test (possibly using multcomp)

From: Joshua Wiley <jwiley.psych_at_gmail.com>
Date: Tue, 01 Mar 2011 23:27:54 -0800

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_57_at_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_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 Wed 02 Mar 2011 - 07:30:25 GMT

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 Thu 03 Mar 2011 - 16:20:19 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