Learn R Programming

itsadug (version 2.5)

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"))

Value

The coefficients of the random intercepts and slopes.

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

Author

Jacolien van Rij

See Also

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

Examples

Run this code
data(simdat)

if (FALSE) {
# 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')))
}

Run the code above in your browser using DataLab