Could somebody look at this? I'm new to ggplot, so any help would be greatly appreciated. I provided an example to facilitate. Thanks!
dadrivr wrote > > I'm fitting a lme growth curve model with two predictors and their > interaction as predictors. The multilevel model is nested so that level 1 > is time within the individual, and level 2 is the individual. I would > like to plot the mean group-level trajectories at plus and minus 1 SD from > the mean of the main effects composing the interaction term. Thus, the > plot should have 4 lines (mean trajectories) representing all combinations > of the two predictors (where LO = -1sd from its mean, and HI = +1sd from > its mean): > -LO predictor, LO moderator > -LO predictor, HI moderator > -HI predictor, LO moderator > -HI predictor, HI moderator > > They are growth curves, so the plot should have 'time' on the x-axis and > 'outcome' on the y-axis. Here's a sample model: > > library(nlme) > > set.seed(123) > > dataset <- NULL > dataset$id <- rep(1:100, each=10) > dataset$time <- rep(1:10,100) > dataset$outcome <- rnorm(1000, mean=100, sd=15) > dataset$predictor <- rnorm(1000, mean=10, sd=3) > dataset$moderator <- rnorm(1000, mean=5, sd=2) > > dataset <- as.data.frame(dataset) > dataset[sample(1:1000, 400, replace=F),"outcome"] <- NA > dataset[sample(1:1000, 400, replace=F),"predictor"] <- NA > dataset[sample(1:1000, 400, replace=F),"moderator"] <- NA > > model <- lme(outcome~ time + predictor + moderator + predictor*moderator, > random=~1 + time + predictor|id, data=dataset, na.action=na.omit) > > How can I plot the interaction on the mean group-level trajectories using > ggplot? Thanks in advance! > -- View this message in context: http://r.789695.n4.nabble.com/Plotting-interactions-from-lme-with-ggplot-tp4631454p4632141.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help@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.