I have drawing data from 10 subjects drawing 8 shapes (and many repetitions of every shape). I fitted a model to this data Matlab, separately for each subject and each shapes, such that I have 2 model- parameters and an r^2 measure of the goodness of fit, in an 8x10 matrix (8 shapes, 10 subjects).

For each of these 3 variables I would like to know:

  1. Does the parameter differ between shapes?

  2. Do subjects differ in the parameter?

I think I need a linear mixed-model, where shapes are fixed and subjects are random, but I’m not sure (shapes are categorical, but this can still be modeled by linear models, right?).

I tried the following:

gamma.model = lmer(gamma ~ Shape + (1|Subject), data = gammatable, REML = FALSE)

summary(gamma.model) shows me a p-value for shape1 vs. every other shape, but not the relation between shape2 and shape 8 (for instance).

There is also no mentioning at all of random effects...?

Can someone please help me understand -

  1. If indeed I need a mixed-model (or if not – what do I need?)

  2. How to define it correctly in lme4 (or other)

  3. How to perform multiple comparisons and get p-values for fixed, as well as for random effects?

Thanks a lot!


1 Answer 1

  1. A mixed model would be sensible since you have repeated measures and enough subjects to estimate random intercepts for them. Alternatively a repeated measures ANOVA could suffice, if the outcome is continuous.

  2. The model specification looks OK, assuming that the outcome is continuous, but you should check the residuals and random intercepts to see if they are plausibly normally distributed. If the outcome is not continuous then you should use a generalized linear mixed model.

  3. You could use lsmeans to compare the fixed effects. The random effects (random intercept for Subject) is estimated as a standard deviation and variance in the output. You don't need a p-value for that.

Edit: To clarify, the model you should use depends, in part, on type of outcome/response variable you have. I mentioned continuous, though in reality there are different definitions of variable types, for example see here and here. For linear mixed models (such as lmer), one the main requirements is that the residuals are normally distributed. If the outcome variable is, for example a count, or an ordered categorical variable, it is highly likely that the residuals won't be normally distributed, and you should use a generalised linear mixed model instead.

  • $\begingroup$ Thank you very much for this answer! What do you mean "if the outcome is continuous"? (I'm not trying to relate the shapes to one another, I treat them as pure categories... is this related to that?) $\endgroup$
    – Irit Sella
    Jul 27, 2016 at 7:26
  • $\begingroup$ If the outcome is categorical, then you should be using a generalized linear mixed model $\endgroup$ Jul 27, 2016 at 8:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.