Learn R Programming

itsadug (version 0.8)

get_difference: Get model predictions for differences between conditions.

Description

Get model predictions for differences between conditions.

Usage

get_difference(model, cond1, cond2, cond = NULL, se = TRUE, f = 1.96,
  print.summary = TRUE)

Arguments

model
A gam object, produced by gam or bam.
cond1
A named list with the values to use for the first difference condition.
cond2
A named list with the values to use for the second difference condition.
cond
A named list of the values to use for the other predictor terms. Variables omitted from this list will have the closest observed value to the median for continuous variables, or the reference level for factors.
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.
print.summary
Logical: whether or not to print a summary of the values selected for each predictor. Defaults to TRUE.

Value

  • Returns a data frame with the estimates of the difference and optionally the confidence intervals around that estimate.

See Also

Other functions for model predictions: get_modelterm; get_predictions; get_random

Examples

Run this code
data(simdat)

# first fit a simple model:
m1 <- bam(Y ~ Group+te(Time, Trial, by=Group), data=simdat)

# get difference estimates:
diff <- get_difference(m1, cond1=list(Group='Adults'),
cond2=list(Group='Children'), cond=list(Time=seq(0,500,length=100)))
head(diff)

Run the code above in your browser using DataLab