Learn R Programming

NVCSSL (version 3.0)

NVC_predict: Prediction for nonparametric varying coefficient (NVC) models

Description

This is a function to predict the responses \(y(t_{new})\) for new subjects at new time points \(t_{new}\) with new covariates \(X_{new}\). The function accepts an estimated NVC model that was fit using either the NVC_SSL or NVC_frequentist functions and returns the predicted \(y(t)\)'s. This function can be used for either out-of-sample predictions or for in-sample predictions if the "new" subjects are the same as the ones used to obtain the fitted NVC model.

Usage

NVC_predict(NVC_mod, t_new, id_new, X_new)

Value

The function returns a list containing the following components:

id

vector of each \(i\)th subject's label

time

vector of each \(j\)th observation time for each \(i\)th subject

y_pred

vector of predicted responses corresponding to each \(j\)th observation time for each \(i\)th subject

Arguments

NVC_mod

an object with a fitted NVC model returned by the NVC_SSL or NVC_frequentist function

t_new

vector of new observation times

id_new

vector of new labels, where a label corresponds to one of the new subjects

X_new

new design matrix with columns \([X_1, \ldots, X_p]\) where the \(k\)th column corresponds to the \(k\)th covariate. X_new must have the \(p\) columns, i.e. the same number of varying coefficients estimated by NVC_mod.

References

Bai, R., Boland, M. R., and Chen, Y. (2023). "Scalable high-dimensional Bayesian varying coefficient models with unknown within-subject covariance." Journal of Machine Learning Research, 24:1-49.

Examples

Run this code
## Load simulated data
data(SimulatedData)
attach(SimulatedData)
y = SimulatedData$y
t = SimulatedData$t
id = SimulatedData$id
X = SimulatedData[,4:103]

## Fit frequentist penalized NVC model with the group lasso penalty. 
## No need to specify an 'id' argument when using NVC_frequentist() function.

NVC_gLASSO_mod = NVC_frequentist(y=y, t=t, X=X, penalty="gLASSO")

## Make in-sample predictions. Here, we DO need to specify 'id' argument

NVC_gLASSO_predictions = NVC_predict(NVC_gLASSO_mod, t_new=t, id_new=id, X_new=X)

## Subjects
NVC_gLASSO_predictions$id

## Observation times
NVC_gLASSO_predictions$time

## Predicted responses
NVC_gLASSO_predictions$y_pred


# \donttest{
## Fit NVC-SSL model to the data instead. Here, we do need to specify id

NVC_SSL_mod = NVC_SSL(y=y, t=t, id=id, X=X)
NVC_SSL_predictions = NVC_predict(NVC_SSL_mod, t_new = t, id_new=id, X_new=X)

## Subjects
NVC_SSL_predictions$id

## Observation times
NVC_SSL_predictions$time

## Predicted responses
NVC_SSL_predictions$y_pred
# }

Run the code above in your browser using DataLab