###Road casualties in Great Britain (see help("Seatbelts"))
timeseries <- Seatbelts[, "VanKilled"]
regressors <- cbind(PetrolPrice=Seatbelts[, c("PetrolPrice")],
linearTrend=seq(along=timeseries)/12)
#Logarithmic link function with Poisson distribution:
seatbeltsfit <- tsglm(ts=timeseries, link="log",
model=list(past_obs=c(1, 12)), xreg=regressors, distr="poisson")
se(seatbeltsfit) #by normal approximation
## Not run:
# system.time(stderror <- se(seatbeltsfit, B=100)) #by bootstrap
# stderror
# #This estimation of bootstrap standard errors takes several minutes on a single
# #processing unit, of course depending on its speed.
# #Parallel computation for shorter run time on a cluster:
# library(parallel)
# ntasks <- 3
# clust <- makeCluster(ntasks)
# setDefaultCluster(cl=clust)
# system.time(stderror <- se(seatbeltsfit, B=100, parallel=TRUE))## End(Not run)
Run the code above in your browser using DataLab