simulateUnivariateAR: Builds an autoregressive model and uses it to predict

View source: R/simulateUnivariateAR.R

simulateUnivariateARR Documentation

Builds an autoregressive model and uses it to predict

Description

A wrapper function for buildAR and predictAR.

Usage

simulateUnivariateAR(
  vec,
  x = NULL,
  x_lag = 0,
  wsize = 14,
  method = c("equal", "unweighted", "triangle"),
  pdays = 28,
  nsim = 100,
  skip = 0,
  seed = NULL,
  output_type = "all",
  rhat_method = c("none", "geometric", "arithmetic"),
  lambda = seq(0, 1, 0.05),
  alpha = 0,
  rolling_mean = 1,
  debug = FALSE
)

Arguments

vec

A vector of numeric data

x

A vector of numeric data, used to predict vec. Must be the same size as vec and indexed to vec

x_lag

An integer used to specify the number of observations x should be shifted. Vec will also be truncated on top by x_lag

wsize

Number of prior observations to use for averaging, default is 14

method

Type of weighting to use, default is equal

pdays

Number of days into the future to make predictions, default is 28

nsim

Number of simulations, default is 100

skip

Number of input values to skip, default is 0

seed

Seed for random number generator

output_type

Type of output, default is all

rhat_method

Method for calculating rhat, if "none", rhat = 1 and has no effect

lambda

Shrinkage parameter, if not specified, default is a grid search from 0 to 1 by 0.05. A value of 0 produces no shrinkage. If an array is specified, all values in the array are evaluated and the optimal lambda is chosen based on residual sum of squares. Values should be between 0 and 1 inclusive.

alpha

Alpha parameter, if not specified, default is 0 which produces no scaling. If an array is specified, all values in the array are evaluated and the optimal alpha is chosen based on residual sum of squares. Values should be >=0.

rolling_mean

rolling mean window for x. Must be an integer less than length of x and at least 1. Default is 1

debug

TRUE returns buildAR objects in addition to standard output

Value

A data frame containing the specified output statistics for each sim


olshena/COVIDNearTerm documentation built on May 27, 2023, 1:23 p.m.