[R-sig-ME] A strange design; impossible to model using mixed models?
Mike Lawrence
Mike.Lawrence at dal.ca
Sun Jun 6 03:22:55 CEST 2010
Hi folks,
This is likely a case of an experimentalist (not me!) failing to
consult a statistician before applying an experimental design. I have
data where I'm interested in 3 theoretical variables derived from 2
manipulated variables, all measured within-Ss:
#set up the design
a = expand.grid(
s = 1:100 #subjects
, x = 1:4 #one predictor variable
, y = 1:3 #second predictor variable
)
a$z = rnorm(nrow(a)) #fake data
#recode predictor variables
a$v1 = ifelse(a$x==1,-.5,ifelse(a$x==2,.5,NA)) #based on x
a$v2 = ifelse(a$x==3,-.5,ifelse(a$x==4,.5,NA)) #based on x
a$v3 = ifelse(a$y==1,-.5,ifelse(a$y==2,.5,NA)) #based on y
Now, obviously with such formulation, it's impossible to compute an
interaction between v1 and v2 because they're non-orthogonal, but it
is possible to compute the interactions between v1 & v3, and between
v2 and v3:
fit1 = lmer(
z ~ v1 * v3 + ( 1 | s )
, data = a
)
fit2 = lmer(
z ~ v2 * v3 + ( 1 | s )
, data = a
)
But I feel like it should be possible to do both above models
simultaneously (gaining accuracy in the estimation of the main effect
of v3), as:
fit = lmer(
z ~
v1 +
v2 +
v3 +
v1:v3 +
v2:v3 +
( 1 | s )
, data = a
)
However, I get the error:
Error in function (fr, FL, start, REML, verbose) :
Number of levels of a grouping factor for the random effects
must be less than the number of observations
Is it simply impossible to model the three variables simultaneously?
Mike
--
Mike Lawrence
Graduate Student
Department of Psychology
Dalhousie University
Looking to arrange a meeting? Check my public calendar:
http://tr.im/mikes_public_calendar
~ Certainty is folly... I think. ~
More information about the R-sig-mixed-models
mailing list