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
Run the code above in your browser using DataLab