# Error message when estimating group level interactions lmer

When estimating a group level interaction I get the following error:

 model <-lmer(rtln ~ + ifIncongruent + gender + ifIncongruent:gender + (1|subj:ifIncongruent), data=dataset)
Error in validObject(.Object) :
invalid class "mer" object: Slot Zt must by dims['q']  by dims['n']*dims['s']
1: In subj:ifIncongruent :
numerical expression has 1789 elements: only the first used
2: In subj:ifIncongruent :
numerical expression has 1789 elements: only the first used


I'm sure there is some obvious reason, I need to specify something. Does anyone know? thanks,

• Welcome! Having the ability to reproduce the error will improve your chances of getting advice on how to fix it. This question on SO gives great tips on such a topic: stackoverflow.com/questions/5963269/… – Chase Jul 13 '11 at 2:17
• Describe the data. Describe the model you want to make of the data. All of these codes for variables are useless to someone trying to assist you. – John Jul 17 '11 at 21:59

You're specifying ifIncongruent as both an effect and the grouping for the multi-level model. When you put ifIncongruent after the "|" that was telling it that your data is nested within it's interaction with subj. I doubt that's what you want. Even if it is, you can't also have it as an effect as well. Maybe you meant?

model <- lmer( rtln ~ ifIncongruent + gender + ifIncongruent:gender + (1 + ifIncongruent|subj), data=dataset )


EDIT: Looking at your Stata output you may have meant

model <- lmer( rtln ~ ifIncongruent + gender + ifIncongruent:gender + (1|subj) + (0 + ifIncongruent|subj), data=dataset )


or shorter

model <- lmer( rtln ~ gender * ifIncongruent + (1|subj) + (0 + ifIncongruent|subj), data=dataset )


You DO NOT have separate intercepts for your random effects in the output shown here for your Stata model. You'd need to print the random effects for that (in R that ranef(model)). You do have seperate estimates of the standard deviation of random subject and ifIncongruent effects.

You should really try to specify in regular language... not lmer... what you're trying to accomplish if this isn't it. Describe the complete model you're trying to test. At least describe the structure of your data or something. All of these arbitrary variables you keep posting in your questions don't mean anything. Craft a proper question and you can get a proper answer.

• thank you for your answer. Here's a link to the stata code and output i'm trying to replicate in R: dl.dropbox.com/u/22681355/output.docx basically I'm just trying to find the equivalent commands. The difference between your code and the state output is that your code treats subj as the intercept in the random effects, whereas in stata there is an intercept and both subj and ifincongruent are treated as independent. Do you know how to specify this? thanks – DBR Jul 17 '11 at 21:00
• @DBR Your previous account was unregistered, thus you lost control over it. Now it is merged with your current one, so everything should be OK. – user88 Jul 17 '11 at 23:11
• @John please see stats.stackexchange.com/questions/13220/… for a more detailed descriptions, datasets and outputs. Thank you for your help – DBR Jul 18 '11 at 23:35