[R] simple question about contrasts, lm and factors
Dieter Menne
dieter.menne at menne-biomed.de
Mon Apr 12 08:42:11 CEST 2010
David.Epstein wrote:
>
> I have a data frame with two variables that are factors. One is actually a
> TRUE/FALSE factor, and I have coded it as 1/0, a continuous variable, but
> I could turn it back into a factor. The second is an ordered factor and
> consists of five timepoints. There are several continuous variables as
> well. Now I want to fit a linear model to my data, using lm (or another R
> procedure if recommended).
>
> Question: should I use polynomial contrasts? My timepoints are very far
> from being evenly spaced, so ordinary R contrasts seem more natural.
>
My first choice would be to use time as continuous, and do a plot(lm(...))
of the simple linear regression to check if the residuals are reasonable. In
the majority of case (in medicine/biology), variance is so large with 5 data
points that the linearity assumption is reasonable.
David.Epstein wrote:
>
> I also want to choose my base value. In the first call to lm, I want to
> choose base value equal to FirstTimePoint.
> In my second call to lm, I want to choose base value to be the interaction
> term FirstTimePoint:FALSE or FirstTimePoint:0.
>
If you have something like a growth curve of a plant that starts near zero,
and zero has a useful meaning in the context, use the original data.
Interpretation is easier.
If you have data of patients in the age range of 50 to 80, age zero makes no
sense, and using the original data can lead to nasty correlations between
estimates of slope an intercept. You could use age-median(age) or
age-mean(age) as the new variable. Since the assumption is not very
critical, I tend to use a nearby nice value instead; so if the median is 63
year, use 65, which give the (Intercept) a nice-to-remember meaning.
Dieter
--
View this message in context: http://n4.nabble.com/simple-question-about-contrasts-lm-and-factors-tp1835964p1836729.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list