Learn R Programming

MixedPsy (version 1.3.0)

MixInterpolate: Interpolate Predictions from a GLMM

Description

This function generates an interpolated dataset by predicting values across a range of an independent variable for a GLMM.

Usage

MixInterpolate(xplode.obj, n_points = 100)

Value

A data frame containing the interpolated independent variable, the corresponding predicted values from the fitted GLMM, and columns for the independent factors.

Arguments

xplode.obj

an object of class xplode.

n_points

An integer number. It specifies the number of points to interpolate along the independent variable range. Default is 100.

See Also

xplode, predict.

Examples

Run this code
mod.simul = lme4::glmer(formula = cbind(Longer, Total - Longer) ~ X + (1 | Subject), 
family = binomial(link = "probit"), data = simul_data)
xplode.mod = xplode(model = mod.simul, name.cont = "X")

longData <- MixInterpolate(xplode.mod)

# use the interpolated dataset to plot model:
library(ggplot2)
ggplot(longData, aes(X, prediction, color = Subject)) +
geom_line() +
geom_point(data = simul_data, aes(X, Longer/Total))

Run the code above in your browser using DataLab