Learn R Programming

gppm (version 0.3.0)

crossvalidate: Cross-validation.

Description

Performs cross-validation of a Gaussian process panel model.

Usage

crossvalidate(gpModel, foldVector)

Value

Cross-validation estimates of the mean squared error (MSE) and the negative log-predictive probability (nLPP)

Arguments

gpModel

object of class GPPM.

foldVector

integer vector. Describes the foldstructure to use. For example, created by createLeavePersonsOutFolds.

Details

The fold vector, must be a vector of length nrow(getData(gpModel)) of integers from 1 to k. If foldVector[i]=j, then data point i is assigned to fold j.

Examples

Run this code
# \donttest{
data("demoLGCM")
lgcm <- gppm(
  "muI+muS*t", "varI+covIS*(t+t#)+varS*t*t#+(t==t#)*sigma",
  demoLGCM, "ID", "y"
)
theFolds <- createLeavePersonsOutFolds(lgcm, k = 2) # for speed, in practive rather use default k=10
crosRes <- crossvalidate(lgcm, theFolds)
crosRes$MSE # mean squared error
crosRes$nLPP # negative log-predictive probability
# }

Run the code above in your browser using DataLab