semipred | R Documentation |
This function produces predicted means with graph for a semi paramatric model with new set of covariate values.
semipred(semireg, modelterm=NULL, covariate, sm_term=NULL, contr=NULL,
covariateV=NULL, boundary=NULL, level=0.05, trans=NULL, trellis=TRUE,
scales=c("fixed", "free", "free_x", "free_y"),
plotord=NULL, ci=TRUE, point=TRUE, jitterv=0, threeD=FALSE, prt=TRUE)
semireg |
A list object returned by |
modelterm |
Name (in "quotes") for indicating which factor term's predicted mean to be calculated.
The |
covariate |
Name (in "quotes") of one or two (for |
sm_term |
Names (in "quotes") of smooth terms (from |
contr |
A numeric vector with length of two (e.g. c(4, 1)) which indicates to produce predicted mean with CI for difference between |
covariateV |
A numeric vector or matrix, then semipred will produce the result for |
boundary |
A matrix or data frame of two columns, used to specify boundary of longitude and latitude, it is functional when the length of covariate is two. |
level |
A significant level for calculating confident interval. The default value is 0.05. |
trans |
A function object for calculating the back transformed means, e.g. |
trellis |
A logical scalar. If set to TRUE (default), a trellis plots of predicted means with CI will be drawn. |
scales |
Should scales be fixed ("fixed", the default), free ("free"), or free in one dimension ("free_x", "free_y") in a trellis graph? |
plotord |
A numeric vector specifying the order of plotting for two way interaction (e.g.
|
ci |
A logical scalar to indicate whether to print confidence interval. The default value is TRUE. |
point |
A logical scalar to indicate whether to print raw data points. The default value is TRUE. |
jitterv |
A degree of jitter in x and y direction in the graph. The default is zero. |
threeD |
A logical scalar to indicate whether to produce a 3-D plot or not. The default value is FALSE. |
prt |
A logical scalar to indicate whether to produce plots on the screen or not. The default value is TRUE. |
plt |
A ggplot object. |
pred_df |
A data.frame with predcted data. |
Dongwen Luo, Siva Ganesh and John Koolaard
# library(predictmeans)
# data(Dialyzer, package="nlme")
# help(Dialyzer)
# str(Dialyzer)
#
# library(ggplot2)
# ggplot(Dialyzer, aes(x=rate, y=pressure, col=QB)) +
# geom_line() +
# facet_wrap(vars(Subject))
#
# fm <- semireg(pressure ~ rate*QB+(rate|Subject),
# smoothZ=list(
# qb_grp=smZ(rate, by=QB, group=TRUE)
# ),
# data=Dialyzer)
# str(fm$data)
# summary(fm$semer)
# residplot(fm$semer)
# anova(fm$semer)
# ranova(fm$semer)
#
# ap_out1 <- semipred(fm, "QB", "rate")
# str(ap_out1$pred_df)
# ap_out2 <- semipred(fm, "QB", "rate", contr=c(1,2))
# str(ap_out2$pred_df)
#
# help(sleepstudy)
# str(sleepstudy)
# library(latticeExtra)
# x11()
# xyplot(Reaction ~ Days | Subject, sleepstudy, aspect = "xy",
# layout = c(9, 2), type = c("g", "p", "r"),
# index.cond = function(x, y) coef(lm(y ~ x))[2],
# xlab = "Days of sleep deprivation",
# ylab = "Average reaction time (ms)",
# as.table = TRUE)
#
# sleep.semi <- semireg(Reaction ~ Days*Subject,
# smoothZ=list(
# sub_grp=smZ(Days, by=Subject, group=TRUE)
# ),
# data=sleepstudy)
# residplot(sleep.semi$semer)
# summary(sleep.semi$semer)
# anova(sleep.semi$semer)
# ranova(sleep.semi$semer)
# x11()
# predout1 <- semipred(sleep.semi, "Subject", "Days")
# str(predout1$pred_df)
# x11()
# predout2 <- semipred(sleep.semi, "Subject", "Days", contr = c(6,1))
# str(predout2$pred_df)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.