ptsr.sim {PTSR} | R Documentation |
Function to simulate a PTSR model
Description
Function to simulate a PTSR model
Usage
ptsr.sim(n = 1, burn = 0, xreg = NULL, xregar = TRUE, varphi = 1,
alpha = 0, beta = NULL, phi = NULL, theta = NULL,
seed = stats::runif(1, 1000, 10000), rdist = r.gamma, link1 = "log",
link2 = "identity", g1 = NULL, g1.inv = NULL, g2 = NULL)
Arguments
n |
a strictly positive integer. The sample size of yt (after burn-in). Default is 1. |
burn |
a non-negative integer. length of "burn-in" period. Default is 0. |
xreg |
optionally, a vector or matrix of external regressors.
For simulation purposes, the length of xreg must be |
xregar |
logical, if |
varphi |
non-negative parameter. Default is 1. |
alpha |
a numeric value corresponding to the intercept. Default is 0. |
beta |
optionally, a vector of coefficients corresponding to the
regressors in |
phi |
optionally, for the simulation function this must be a vector
of size |
theta |
optionally, for the simulation function this must be a vector
of size |
seed |
optionally, an integer which gives the value of the fixed seed to be used by the random number generator. If missing, a random integer is chosen uniformly from 1,000 to 10,000. |
rdist |
function, the random number generator to be used |
link1 |
character indicating which link must be used for |
link2 |
character indicating which link must be used for |
g1 |
optionally, a link function to be used for |
g1.inv |
optionally, a the inverse link function to be used for |
g2 |
optionally, a link function to be used for |
Details
The function ptsr.sim
generates a random sample from a positive time
series regression model, with a given distribution.
Value
Returns a list with the following components
-
yt
: the simulated time series -
mut
: the conditional mean -
etat
: the linear predictorg(\mu_t)
-
error
: the error term.
Examples
#-------------------------------------------------------------------
# Generating a sample of a Gamma-ARMA(1,1) model with no regressors
#-------------------------------------------------------------------
simu = ptsr.sim(n = 300, burn = 50,
varphi = 20, alpha = 0,
phi = 0.35, theta = 0.2,
seed = 1234, rdist = r.gamma,
link1 = "log", link2 = "log")
names(simu)
plot.ts(simu$yt)
lines(simu$mut, col= "red")