How to estimate Variance Components in a mixed linear model ?

Hello,
How do I fit a mixed linear model to my data using Mathematica? The model contains random and fixed effects. In addition, I am interested in estimating variance components for each random effect used in my model!

Any hints that steer me into the right direct are appreciated!

Martin

Start by reading up on LinearModelFit, then add questions about how to separate effects.

I don’t think that Mathematica has built in functionality for mixed linear models. You may have to program this yourself. Alternatively, you could use R to do so. If you want to do it via Mathematica, you have RLink that may come in useful.

Bruce and Asim, many thanks for your advice and suggestions!
I hope that in the future the Mathematica staff addresses this gap!

RLink seems to be very promissing!

I started to work with RLink and this is actually the way to go! So far it works flawlessly running mixed linear models and estimating variance components using R package “lme4” within Mathematica.

Hi Martin

It would be great for the community if you can post the details of a small working example, i.e, some simple data and code.

Asim

Blog Post: Jon McLoone, Why Would a Mathematica User Care about R?
http://blog.wolfram.com/2013/05/22/why-would-a-mathematica-user-care-about-r/

CRAN package repository
http://cran.cnr.berkeley.edu/web/packages/

As Asim suggested, I used R via RLink to estimate variance componets.

Needs["RLink`"]
InstallR[ ]

REvaluate["
  {
  FAC1=as.factor(example$Fac1)
  FAC2=as.factor(example$Fac2)
  FAC3=as.factor(example$Fac3)
  FAC4=as.factor(example$Fac4)
  VAR1=as.numeric(example$Var1)
  }
  "];
REvaluate["hist(VAR1)"]

StringJoin@Riffle[#, "\n"] &@
 REvaluate[" 
  {
  library(lme4)
  fit2 = lmer(formula= VAR1 ~ (1|FAC1) + (1|FAC2%in%FAC1) + (1|FAC4) + (1|FAC1:FAC4))
  summary.text = capture.output(print( summary(fit2)))
  }
  "]

Wondering if M10 will have anything in it for these mixed linear models.

Wondering if M12.1 will have anything in it for these mixed linear models.

How about mixed models in M12.2?