comparison between groups by mixed effect model I would like to make a mixed effect model using "(g)lmer" in R and/or "fit(g)lme" in Matlab. However, I am not experienced with it. So please see whether I am doing right or wrong.
I need to compare behavioral outcomes (e.g., reaction times in response to stimulus onset) between two groups of subjects (e.g., 20 controls and 20 patients). 
The task subjects performed include the following parameters:


*

*Task difficulty (0: easy, 1: difficult)

*Duration before stimulus onset (continuous value)


Each subject performed the task multiple times (e.g., 100 trials). On each trial, task difficulty and duration were chosen randomly.
The following parameters are also necessary:


*

*Age of each subject (continuous value)

*Group (0: control, 1: patient)


So, I made the following formula:


*

*reaction time ~ (Task + Duration + Age)xGroup + (Task +
Duration | subject)


I want to say there are differences between controls and patients if the coefficients of variables containing "Group" (i.e., Group, Task:Group, Duration: Group, and Age:Group) are significant. 
Is the above formula correct to say that?
 A: The formula looks OK for your experimental question. You might even consider more complex models (e.g. with interaction Task:Duration). Note that the more complex is the model (with more parameters), the more likely you are to have convergence warnings. (A convergence warning might indicates that the model is too complex for your data, and if that happens you should probably go back to the simpler model.)
I would also suggest that you don't limit your analysis to simply checking whether a particular coefficient "is significant", but rather you estimate and report a 95% confidence interval for each coefficient. I don't know about Matlab, but in R it is pretty easy to estimate robust confidence intervals using bootstrap (check the 
confint.merMod function in the package lme4).
Finally, reaction times have usually a very asymmetrical distribution, which is can be a problem for a linear model. You should check the residuals of the model, for example with a normal quantile-quantile plot, and a scatterplot of residuals vs fitted values. If you see relevant deviations from normality in the distribution of residuals, you could try to transform your data (using for example a log, or a reciprocal transformation; have a look at this article by Kliegl and others for an example of this approach). Alternatively you could also use a generalized linear mixed-effects model (GLMM) instead of a linear one, and use a Gamma or an Inverse Gaussian link functions; have look at this other article for an example of this approach.
