[R-sig-ME] Output and post-hoc comparisons for lme with splines specification of fixed effects

Lenth, Russell V russell-lenth at uiowa.edu
Tue Apr 5 18:31:02 CEST 2016


There are all kinds of ways to plot the predictions. All you need to do is create a data.frame, say 'new.df', with the desired combinations of Location and Disease, then obtain the predictions using

	predict(model, newdata = new.df)

and plot the results using whatever plotting functions you like.

To do post hoc comparisons, note that your model specifies an interaction between the factors, so the comparison will be different at each Location. The lsmeans package produces predictions, or averages thereof, over a regular grid of values, and facilitates the kind of analysis you want.(These results are called "predicted marginal means", or PMMs.) It would go something like this:

	library("lsmeans")
	model.pmm <- pmmeans(model, ~ Disease | Location, at = list(Location = 1:10))   
			#### but probably change the Location values

	# comparisons of predictions at each Location specified:
	pairs(model.pmm)

	# Plot of predictions, separately for each Disease
	pmmip(model.pmm, Disease ~ Location)

If you don't like the style of the plot, you can do

	new.df <- summary(model.pmm)

which produces a data.frame with the values of Disease, Location, and predictions (named "pmmeans"), which you can plot using whatever methods you like.

If you prefer the terminology "least-squares means" to "predicted marginal means", you get the same results using the functions 'lsmeans' and 'lsmip'. 

--
Russell V. Lenth  -  Professor Emeritus
Department of Statistics and Actuarial Science   
The University of Iowa  -  Iowa City, IA 52242  USA   
Voice (319)335-0712  -  FAX (319)335-3017
russell-lenth at uiowa.edu  -  http://www.stat.uiowa.edu/~rlenth/ 


-------
Gabriela Czanner wrote:

Dear R-users,

I am attempting to estimate a difference in damage across space (at 24
locations) for two disease types of patients (defined as a factor, 0
disease absent, 1 disease present). Examining the plots of the damage
across the 24 locations in space it appears that the damage increases then
decreases and it is best described by a spline specification like this:

model<- lme( Damage ~ bs( Location , degree=1, df=5) * Disease,
              random=~1| PatientID,
              data=my.data,na.action=na.omit,method="ML")

I wonder if any one can advice with my questions: How can I plot the
predicted mean profiles of the damage for the two groups? How can I make
post-hoc comparison of mean damage across the two disease groups of
patients?

I did tried many online searches but did not find a good answer. So I will
really appreciate your advice!

Gabriela

--
Gabriela Czanner, PhD
Lecturer
Department of Biostatistics
Department of Eye and Vision Science
University of Liverpool



More information about the R-sig-mixed-models mailing list