rARCens {ARCensReg} | R Documentation |
Generating censored autoregressive data
Description
It simulates a censored response variable with autoregressive errors of order following normal or Student-t innovations, with an established censoring rate.
Usage
rARCens(n, beta, phi, sig2 = 1, x = rep(1, n), cens = "left",
pcens = 0.1, innov = "norm", nu = NULL)
Arguments
n |
Length of the desired time serie. |
beta |
Vector of theoretical regression parameters of length |
phi |
Vector of theoretical autoregressive coefficients of length |
sig2 |
Theoretical variance of the error. |
x |
Matrix of covariates of dimension |
cens |
|
pcens |
Desired censoring rate. |
innov |
Distribution of the innovation variable. The values are |
nu |
Degrees of freedom for Student-t innovations. |
Value
data |
Generated response (y), censoring indicator (cc), and lower (lcl) and upper (ucl) bounds of the interval, which contains the true value of the censored observation. |
param |
Theoretical parameters (beta, sig2, phi). |
Note
For data generation with Student-t innovations, the first observations are not censored.
Author(s)
Fernanda L. Schumacher, Katherine L. Valeriano, Victor H. Lachos, Christian E. Galarza, and Larissa A. Matos
See Also
Examples
library(ggplot2)
## Example 1: Generating a sample with normal innovations
set.seed(1234)
dat = rARCens(n=100, beta=c(1,-1), phi=c(.48,-.2), sig2=.5,
x=cbind(1,runif(100)), cens='left', pcens=.10)
# Plotting the time serie
ggplot(data.frame(dat$data$y), aes(x=1:100, y=dat$data$y)) + geom_line() +
geom_line(aes(x=1:100, y=dat$data$ucl), color="red", linetype="twodash") +
labs(x="Time", y=bquote(y["obs"])) + theme_bw()
table(dat$data$cc)
dat$param
#[1] 1.00 -1.00 0.50 0.48 -0.20
## Example 2: Generating a sample with Student-t innovations
set.seed(8278)
dat1 = rARCens(n=100, beta=c(1,-1), phi=c(.48,-.2), sig2=.5,
x=cbind(1,rnorm(100)), cens='right', pcens=.10,
innov='t', nu=3)
# Plotting the time serie
ggplot(data.frame(dat1$data$y), aes(x=1:100, y=dat1$data$y)) + geom_line() +
geom_line(aes(x=1:100, y=dat1$data$lcl), color="red", linetype="twodash") +
labs(x="Time", y=bquote(y["obs"])) + theme_bw()
dat1$param
#[1] 1.00 -1.00 0.50 0.48 -0.20 3.00