[R] Within factor & random factor
細田弘吉
khosoda at med.kobe-u.ac.jp
Wed Aug 26 14:28:48 CEST 2009
Hi,
I am quite new to R and trying to analyze the following data. I have 28
controls and 25 patients. I measured X values of 4 different locations
(A,B,C,D) in the brain image of each subject. And X ranges from 0 to 1.
I think "control or patient" is a between subject factor and location is
a within subject factor. So,
controls: 28
patients: 25 (unbalanced data set)
respone measure: X values (ranging 0 to 1)
fixed factor: control vs. patient (between subject factor)
random factor: location (level: A,B,C,D ;no order) (within subject factor)
random factor: subjectID 1-53
My data looks like this;
CorP X location subjectID
control 0.708 A 1
control 0.648 A 2
patient 0.638 C 3
control 0.547 D 4
patient 0.632 B 5
control 0.723 C 6
...........
I want to know
(a) if there is a significant difference between controls and patients
in X values.
(b) where (A,B,C,D?) the difference is between controls and patients in
X values. (There may be an interaction)
I constructed linear mixed model with lme as followings;
(1) model1 <- lme(X ~ CorP*location, random= ~ 1| subjectID, mydata)
(2) model2 <- lme(X ~ CorP*location, random= ~ location| subjectID, mydata)
I am not familiar with lme syntax. I'm just wondering which formula
[(1) or (2)] is appropriate for my model to know answers of (a) and (b)
questions. Or may be both of the formulas are wrong.
I would appreciate it very much if somebody could help me.
Sincerely,
Kohkichi Hosoda
More information about the R-help
mailing list