Learn R Programming

itsadug (version 2.4.1)

get_random: Get coefficients for the random intercepts and random slopes.

Description

Get coefficients for the random intercepts and random slopes.

Usage

get_random(model, cond = NULL, print.summary = getOption("itsadug_print"))

Arguments

model

A gam object, produced by gam or bam.

cond

A named list of the values to restrict the estimates for the random predictor terms. When NULL (default) all levels are returned. Only relevant for complex interactions, which involve more than two dimensions.

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

The coefficients of the random intercepts and slopes.

See Also

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

Examples

Run this code
# 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