crossvalidate: Cross-validation.

View source: R/cross_validation.R

crossvalidateR Documentation

Cross-validation.

Description

Performs cross-validation of a Gaussian process panel model.

Usage

crossvalidate(gpModel, foldVector)

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.

Value

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

Examples


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


gppm documentation built on Aug. 25, 2025, 9:50 a.m.

Related to crossvalidate in gppm...