Skip to content
Prev 300970 / 398506 Next

marginal effect lmer

Dear Andigo,

On Mon, 23 Jul 2012 07:42:49 -0700 (PDT)
Andigo <Andreas.Goldberg at unige.ch> wrote:
It's hard to know where to begin, particularly since you deleted the earlier discussion. Retrieving that from my reply to you, the model you fit was
I don't really know what these variables are but I'll assume that all are numeric variables and not, e.g., 0/1 dummy regressors that you put in the model instead of factors in the same way that you generated the quadratic regressor for Catholicproportion -- both of these are bad ideas in R because they disguise the structure of the model. 

Anyway, I suppose that what you want in the fixed-effects part of the model is

logthreshold + West + (Catholic + Attendance)*poly(Catholicproportion, 2)

This will give you an orthogonal quadradic in Catholicproportion that interacts both with Catholic and Attendance and will allow effect() to figure out the structure of the model; if you want a raw quadratic (which would provide the same fit to the data but be somewhat less numerically stable), you could substitute poly(Catholicproportion, 2, raw=TRUE).
I'm not sure what you read, but what you got is what you asked for; with the respecified model, you could ask for the "Catholic:poly(Catholicproportion, 2)" effect, or more simply plot(allEffects(m1)) to plot all high-order fixed-effects terms in the model.
Catholic and Catholicproportion are presumably numeric variables, and as documented in ?effect, each will by default be set to 10 levels spanning the range of the variable. There are then 10*10 == 100 combinations of values of these variables at which the effect will be estimated. That you expected one plot suggests to me that you don't quite understand what effect() computes (though all the lines could be put on one plot by setting the argument multiline=TRUE -- ?plot.eff). The lines are straight because effect() couldn't read your mind to know that Catholicproportion2 and Catholicproportion are related, which is why using poly() instead is a good idea.
I already explained that effect() doesn't compute marginal effects. There may well be an R package that does, but I'm not aware of one. It should, however, be a simple matter to compute marginal effects from the lmer() results if you find marginal effects interesting.

Best,
 John