get_modelterm | R Documentation |
Get estimated for selected model terms.
get_modelterm( model, select, cond = NULL, n.grid = 30, se = TRUE, f = 1.96, as.data.frame = TRUE, print.summary = getOption("itsadug_print") )
model |
A gam object, produced by |
select |
A number, indicating the model term to be selected. |
cond |
A named list of the values to restrict the estimates for the predictor terms. When NULL (default) values are automatically selected. Only relevant for complex interactions, which involve more than two dimensions. |
n.grid |
Number of data points estimated for each random smooth. |
se |
Logical: whether or not to return the confidence interval or standard error around the estimates. |
f |
A number to scale the standard error. Defaults to 1.96, resulting in 95% confidence intervals. For 99% confidence intervals use a value of 2.58. |
as.data.frame |
Logical: whether or not to return a data.frame. Default is TRUE, and a list will be returned. |
print.summary |
Logical: whether or not to print a summary of the
values selected for each predictor.
Default set to the print info messages option
(see |
A data frame with estimates for the selected smooth term. Or a list with two or more elements:
fit
: Numeric vector with the fitted values;
se.fit
: Optionally, only with se=TRUE
.
Numeric vector with the error or confidence interval values (f*SE);
f
: The multiplication factor for generating
the confidence interval values;
terms
: Numeric vector (for 1-dimensional smooth)
or data frame (more 2- or more dimensional surfaces)
with values of the modelterms.
title
: String with name of the model term.
xlab
, ylab
, or labels
:
Labels for x-axis and optionally y-axis. Precise structure depends
on type of smooth term: for 1-dimensional smooth only x-label is provided,
for 2-dimensional smooths x-label and y-label are provided,
for more complex smooths a vector of of labels is provided.
Jacolien van Rij
Other Model predictions:
get_coefs()
,
get_difference()
,
get_fitted()
,
get_predictions()
,
get_random()
data(simdat) ## Not run: # Model with random effect and interactions: m1 <- bam(Y ~ s(Time) + s(Trial) +ti(Time, Trial) +s(Time, Subject, bs='fs', m=1), data=simdat) # Get data frame with predictions: p <- get_modelterm(m1, select=1) emptyPlot(range(p$terms), range(p$fit), h=0) plot_error(p$terms, p$fit, p$se.fit, shade=TRUE, xpd=TRUE) # Plot random effects in separate panels: pp <- get_modelterm(m1, select=4, as.data.frame=TRUE) require(lattice) lattice::xyplot(fit~Time|Subject, data=pp, type='l', xlab='Time', ylab='Partial effect') # Plot selection of subjects: pp <- get_modelterm(m1, select=4, cond=list(Subject=c('a01', 'a03', 'c16')), as.data.frame=TRUE) lattice::xyplot(fit~Time|Subject, data=pp, type='l', xlab='Time', ylab='Partial effect') # Or using the package ggplot2: require(ggplot2) pp <- get_modelterm(m1, select=4, as.data.frame=TRUE) pg <- ggplot2::qplot(Time, fit, data = pp, geom = c('point', 'line'), colour = Subject) pg + ggplot2::guides(col = guide_legend(nrow = 18)) ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.