get_modelterm {itsadug}R Documentation

Get estimated for selected model terms.

Description

Get estimated for selected model terms.

Usage

get_modelterm(
  model,
  select,
  cond = NULL,
  n.grid = 30,
  se = TRUE,
  f = 1.96,
  as.data.frame = TRUE,
  print.summary = getOption("itsadug_print")
)

Arguments

model

A gam object, produced by gam or bam.

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 infoMessages).

Value

A data frame with estimates for the selected smooth term. Or a list with two or more elements:

Author(s)

Jacolien van Rij

See Also

Other Model predictions: get_coefs(), get_difference(), get_fitted(), get_predictions(), get_random()

Examples

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)


[Package itsadug version 2.4.1 Index]