Learn R Programming

LMMsolver (version 1.0.9)

predict.LMMsolve: Predict function

Description

Predict function

Usage

# S3 method for LMMsolve
predict(object, ..., newdata, se.fit = FALSE)

Value

A data.frame with predictions for the smooth trend on the specified grid. The standard errors are saved if `se.fit=TRUE`.

Arguments

object

an object of class LMMsolve.

...

Unused.

newdata

A data.frame containing new points for which the smooth trend should be computed. Column names should include the names used when fitting the spline model.

se.fit

calculate standard errors, default FALSE.

Examples

Run this code
## simulate some data
f <- function(x) { 0.3 + 0.4*x + 0.2*sin(20*x) }
set.seed(12)
n <- 150
x <- seq(0, 1, length = n)
sigma2e <- 0.04
y <- f(x) + rnorm(n, sd = sqrt(sigma2e))
dat <- data.frame(x, y)

## fit the model
obj <- LMMsolve(fixed = y ~ 1,
         spline = ~spl1D(x, nseg = 50), data = dat)

## make predictions on a grid
newdat <- data.frame(x = seq(0, 1, length = 300))
pred <- predict(obj, newdata = newdat, se.fit = TRUE)
head(pred)

Run the code above in your browser using DataLab