[R] Plotting log transformed predicted values from lme

Alina Vodonos Zilberg alina.vodonos at gmail.com
Wed Aug 9 17:24:52 CEST 2017


Hi,

I am performing meta-regression using linear mixed-effect model with the
lme() function  that has two fixed effect variables;one as a log
transformed variable (x)  and one as factor (y) variable, and two nested
random intercept terms.

I want to save the predicted values from that model and show the log curve
in a plot ; predicted~log(x)

mod<-lme(B~log(x)+as.factor(y), random=~1|cohort/Study,
weights=varFixed(~I(SE^2)), na.action=na.omit, data=subset(meta),
          control = lmeControl(sigma = 1, apVar = FALSE))
summary(mod)

newdat <- data.frame(x=seq(min(meta$x), max(meta$x),,118))  # I have 118
observations. #How do I add the factor variable to my newdat?
newdat$pred <- predict(mod, newdat,level = 0,type="response")

plot(B ~ x, data=meta)
lines(B ~ x, data=newdat)

Can you please assist me ?

Thank you!

Alina

	[[alternative HTML version deleted]]



More information about the R-help mailing list