approx.Z: Interpolating in Smoothing Spline Z-Matrix Columns

View source: R/lmeSplines.R

approx.ZR Documentation

Interpolating in Smoothing Spline Z-Matrix Columns

Description

Interpolates the Z-matrix for LME smoothing spline fits from one set of time covariate values to another using linear interpolation of each column of the Z-matrix, regarded as a function of time.

Usage

approx.Z(Z, oldtimes, newtimes)

Arguments

Z

Z-matrix with rows corresponding to the sorted unique values of the time covariate (e.g., from smspline or smspline.v).

oldtimes

Numeric vector of original (sorted) time covariate values corresponding to the rows of Z.

newtimes

Numeric vector of new time covariate values to interpolate to.

Value

A matrix with the same number of columns as Z and rows corresponding to newtimes, containing the interpolated Z-matrix values. This can be used with smspline for fitting LME splines with random effects at different time points or as part of the newdata argument in predict.lme for predictions at new points.

Note

Linear interpolation works well because the spline basis functions are approximately piecewise linear.

Author(s)

Rod Ball <rod.ball@scionresearch.com>

See Also

smspline, lme, predict.lme

Examples

times1 <- 1:10
Zt1 <- smspline(~ times1)
times2 <- seq(1, 10, by = 0.1)
Zt2 <- approx.Z(Zt1, oldtimes = times1, newtimes = times2)


lmeSplines documentation built on Aug. 31, 2025, 5:08 p.m.