[R] How to plot 3-D surface graph from lmer mixed models?

willow1980 jianghua.liu at shef.ac.uk
Thu Aug 13 15:34:48 CEST 2009


Dear Professor Murdoch,
That is exactly the difficulty for me. I don't know how to make a prediction
with lmer using "expand.grid"; at the moment, I can use
“model at X%*%fixef(model)” to get predicted values for existing observational
data, but not data by "expand.grid". Actually, if I know this, I can then
use "persp" or "wireframe" to plot 3-D surface graph. Do you know or have
available code for this aim?
Sorry, this request must sound very lazy or stupid.
Thank you very much for helping!
Best regards,



Duncan Murdoch-2 wrote:
> 
> 
> I only see two explanatory variables:  afr_c, byear_c.  If you have more 
> than two, you can't use a surface plot:  surfaces are two dimensional.
> 
> All of the 3D surface functions want basically the same thing:  a matrix 
> giving evaluations of a function at locations of the explanatory 
> variables.  So you need to calculate that.  I'd do it by using 
> expand.grid to create a large set of combinations of values of the 
> explanatory variables, ask your model to do predictions at all of those 
> locations, and then reshape the result into a matrix.
> 
> Duncan Murdoch
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
> 

-- 
View this message in context: http://www.nabble.com/How-to-plot-3-D-surface-graph-from-lmer-mixed-models--tp24952273p24954438.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list