# NOT RUN {
data(simdat)
# Convert Condition to factorial predictor for illustration purposes:
simdat$Condition <- as.factor(simdat$Condition)
infoMessages('on')
# }
# NOT RUN {
# some arbitrary model:
m1 <- bam(Y ~ Condition*Group
\t+ s(Time, by=Condition)
\t+ s(Time, by=Group)
\t+ s(Subject, bs='re'),
\tdata=simdat)
# print summary to inspect parametric terms:
summary(m1)
# return all contrasts:
wald_gam(m1)
# USE OF COMP
# return only contrasts for Adults:
wald_gam(m1, comp=list(Condition=levels(simdat$Condition)))
# return specific contrasts:
wald_gam(m1, comp=list(Condition=c('-1', '0', '1'),
Group=c('Adults', 'Children')))
# USE OF SELECT
# Specify contrast matrix.
# Note that intercept should be 0.
# Example: Compare Condition 0 with Conditions 2 and 3 for children.
# Method 1: matrix or vector:
R = matrix( c(0,-2,0,1,1,0,0,0,0,0,0,0), nrow=1)
wald_gam(m1, select=R)
wald_gam(m1, select=c(0,-2,0,1,1,0,0,0,0,0,0,0))
# Method 2: list
# first list element are reference coefficients,
# second list element are coefficients to compare
wald_gam(m1, select=list(2, c(4,5)))
# Replication of contrasts given in summary:
wald_gam(m1, select=c(0,1,0,0,0,0,0,0,0,0,0,0))
# USE OF T.TEST
# This option is not implemented for use with select
# Compare with second line of parametric summary:
wald_gam(m1, comp=list(Condition=c('-1', '0'),
Group='Children'), t.test=TRUE)
# Compare with Wald test:
wald_gam(m1, comp=list(Condition=c('-1', '0'),
Group='Children'))
# exclude significance stars:
wald_gam(m1, comp=list(Condition=c('-1', '0'),
Group='Children'), signif.stars=FALSE)
# do not print output, but save table for later use:
test <- wald_gam(m1, comp=list(Condition=c('-1', '0'),
Group='Children'), print.output=FALSE)
test
# alternative way:
infoMessages('off')
test2 <- wald_gam(m1, comp=list(Condition=c('-1', '0'),
Group='Children'))
infoMessages('on')
# }
Run the code above in your browser using DataLab