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

willow1980 jianghua.liu at shef.ac.uk
Sat Aug 15 15:51:59 CEST 2009

```Hi, First of all, I thank Professor Murdoch and Dr Sarkar for providing
important information. Now, this problem has been basically solved. The
package "akima" helps to fultil the objective originally resorting to
"expand.grid". Now, I can use contour or perspective 3-D plot. Hopefully,
this experience can do some help to other users with similar problems.
However, I am still trying to use the method suggested by Dr Sarkar, since I
think wireframe or levelplot may produce more beautiful pictures.
Thank you again!
Cheers!

willow1980 wrote:
>
> Dear R users,
> I have a problem in plotting 3 dimensional graph using mixed models.
> My model is
> sur_prop ~
> afr_c+I(afr_c^2)+I(afr_c^3)+byear_c+I(byear_c^2)+I(byear_c^3)+I(byear_c^4)+(1|Studyparish)+afr_c:byear_c
> +afr_c:I(byear_c^2)+afr_c:I(byear_c^3)+afr_c:I(byear_c^4)+I(afr_c^2):byear_c+I(afr_c^2):I(byear_c^2)+I(afr_c^2):I(byear_c^3)+I(afr_c^2):I(byear_c^4)
> This is a study on the effect of mothers' age and cohort year on
> children's survival.
> I  can extract predicted value using a suggested method from website:
> model at X%*%fixef(model). To my knowledge, this method is reasonable. It is
> a bit alike matrix representation in multiple regression.
> However, I cannot use such predicted values together with age and cohort
> values to plot a 3-D surface plot. Since my dataset is very large, it is
> certainly useless to plot 3-D points scatter plot, which is very difficult
> to discern the pattern. By the way, I have tried "plot3d", "scatterplot"
> and "regr2.plot" to give scatter plot.
> So, do you have any suggestion on how to plot a surface plot given above
> information? For example, how to use "persp" or "wireframe" in case of
> lmer with more than two explanatory variables?
> Thank you very much for helping!
> Best wishes!
>

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

```