# NOT RUN {
data(simdat)
# }
# NOT RUN {
# Condition as factor, to have a random intercept
# for illustration purposes:
simdat$Condition <- as.factor(simdat$Condition)
# Model with random effect and interactions:
m2 <- bam(Y ~ s(Time) + s(Trial)
+ ti(Time, Trial)
+ s(Condition, bs='re')
+ s(Time, Subject, bs='re'),
data=simdat)
# extract all random effects combined:
newd <- get_random(m2)
head(newd)
# extract coefficients for the random intercept for Condition:
# Make bar plot:
barplot(newd[[1]])
abline(h=0)
# or select:
get_random(m2, cond=list(Condition=c('2','3')))
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab