« first day (2255 days earlier)      last day (2756 days later) » 

3:50 PM
There is an interesting question about how to use predict() function if there are polynomials terms in the lm() model and one wants to "average" over them: stats.stackexchange.com/questions/221161 I posted an answer there, that explains (I believe) what is wrong with the OP's approach, but I don't know what's the best way to handle this (how does it work in the effects package, e.g.). Would appreciate any further insights/answers. Probably @Glen_b or @gung will know this?
The Q is formulated in terms of lmer() mixed models, but in fact this is unnecessary baggage: the same phenomenon occurs with lm().
 
 
5 hours later…
8:49 PM
@amoeba In what sense would one want to average over polynomial terms in lm?
But if the person is using poly there is an issue with say 'predict' since poly is based on the data. Frank Harrell wrote some functions to deal with that issue.
But once it comes to using lmer I'm roughly speaking a newb. I've used it a few times but I'm not really knowledgeable.
 
9:51 PM
Hi @Glen_b I think if you look at the question, it will become clearer. I don't think I formulated it very well here - partly because I am probably missing some standard terminology
It's unfortunate that this question is formulated with an lmer example. Everything there applies exactly the same to lm too.
Basically, the issue is very simple: imagine you have a model lm(Y~X+Z+I(Z^2)) and you want to predict Y for various X
It's like lsmeans or like what effects packages does (as far as I understand it): we should average over Z and compute the predicted Y|X
If there is no quadratic term, one can just plug mean(Z). The question is what to do when there is a a quadratic term. Or more generally, any polynomials terms of Z and maybe also of other variables etc.
In this example, one can think of Z as a confounder, and the real interest is in the Y|X relationship, hence the desire to compute/plot Y(X) prediction function
Hope this makes some sense. Cheers.
 
10:42 PM
Sounds like the question is simply one of being sufficiently precise about how you want to treat Z
 
Perhaps a more precise question can be as follows: what does effects package do when asked to predict Y from X alone (without providing any values for Z)?
Because this package seems to be doing the sensible thing, in the sense of producing the correct average effect of Z+Z^2
But I could not find a precise description of what it is doing
 

« first day (2255 days earlier)      last day (2756 days later) »