Predict function
Usage
# S3 method for class '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`.
Examples
## 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)
#> x ypred se
#> 1 0.000000000 0.2051355 0.09713998
#> 2 0.003344482 0.2170841 0.08941911
#> 3 0.006688963 0.2290119 0.08248844
#> 4 0.010033445 0.2409332 0.07639899
#> 5 0.013377926 0.2528619 0.07117904
#> 6 0.016722408 0.2648123 0.06680933