Learn R Programming

growfunctions (version 0.11)

predict_functions.gpdpgrow: Use the model-estimated GP covariance parameters from gpdpgrow() to predict the GP function at future time points. Inputs the gpdpgrow object of estimated parameters.

Description

A companion function to gpdpgrow

Usage

## S3 method for class 'gpdpgrow':
predict_functions(object, J = 500, test_times,
  time_points = NULL, sn_order = NULL, ...)

Arguments

object
Object of class gpdpgrow returned from model run of gpdpgrow()
J
Scalar denoting number of draws to take from posterior predictive for each unit. Defaults to J = 500.
test_times
A numeric vector holding test times at which to predict GP function values Will use the estimated covariance parameters from the training data to predict functions at the test_times for the N observation units.
time_points
Inputs a vector of common time points at which the collections of functions were observed (with the possibility of intermittent missingness). The length of time_points should be equal to the number of columns in the data matrix, y
sn_order
An integer vector of length, L_s, equal to the number of seasonal terms. Conveys the order of the seasonality for each term on the scale of T; for example, if T is dimensioned in months, and one wishes to model quarterly seasonality, then
...
further arguments passed to or from other methods.

Value

  • out A list object containing containing two matrices; the first is a K x (N*T) matrix of predicted function values for each of K sampled iterations. N is slow index and denotes the number of experimental units. The second matrix is an N x T average over the K sampled draws, composed in Rao-Blackwellized fashion.

See Also

gpdpgrow

Examples

Run this code
library(growfunctions)
data(cps)
y_short   <- cps$y[,(cps$yr_label %in% c(2010:2013))]
t_train   <- ncol(y_short)
N         <- nrow(y_short)
t_test    <- 4

## Model Runs
res_gp              = gpdpgrow(y = y_short
                              n.iter = 50,
                              n.burn = 25,
                              n.thin = 1,
                              n.tune = 0)

## Prediction Model Runs
T_test             <- 4
T_yshort           <- ncol(y_short)
pred_gp            <- predict_functions( object = res_gp,
                       test_times = (T_yshort+1):(T_yshort+T_test) )

## plot estimated and predicted functions
plot_gp         <- predict_plot(object = pred_gp,
                               units_label = cps$st,
                               single_unit = FALSE,
                               credible = TRUE)

Run the code above in your browser using DataLab