This article proposes a hybrid bootstrap approach to approximate the augmented Dickey–Fuller test by perturbing both the residual sequence and the minimand of the objective function. Since random errors can be dependent, this allows the inclusion of conditional heteroscedasticity models. The new bootstrap method is also applied to least absolute deviation-based unit root test statistics, which are efficient in handling heavy-tailed time series data. The asymptotic distributions of resulting bootstrap tests are presented, and Monte Carlo studies demonstrate the usefulness of the proposed tests.
Shared posts
A hybrid bootstrap approach to unit root tests
New package TPmsm with initial version 1.1.0
Package: TPmsm
Type: Package
Depends: R (>= 2.12.0),graphics,grDevices,KernSmooth
Enhances: p3state.msm,etm
Title: Estimation of transitions probabilities in multistate models
Version: 1.1.0
Date: 2013-04-28
Author: Artur Agostinho Araujo, Javier Roca-Pardinas and Luis Meira-Machado
Maintainer: Artur Agostinho Araujo
Description: Estimation of transition probabilities for the illness-death model and or the three-state progressive model
License: GPL (>= 2)
LazyLoad: yes
LazyData: yes
Packaged: 2013-04-28 19:45:04 UTC; Owner
NeedsCompilation: yes
Repository: CRAN
Date/Publication: 2013-05-03 10:53:53
Animation, from R to LaTeX
Just a short post, to share some codes used to generate animated graphs, with R. Assume that we would like to illustrate the law of large number, and the convergence of the average value from binomial sample. We can generate samples using
> n=200 > k=1000 > set.seed(1) > X=matrix(sample(0:1,size=n*k,replace=TRUE),n,k)
Each row will be a trajectory of heads and tails. For each trajectory, define the mean
, which will denote the mean of the first
values. Such a matrix can be computed using
> cummean=function(M){
+ U=matrix(M[,1],nrow(M),1)
+ for(i in 2:ncol(M)){
+ U=cbind(U,(U[,i-1]*(i-1)+M[,i])/i)}
+ return(U)
+ }
Define then
> Xbar=cummean(X)
Now, to generate an animated gif, the way I usually do it is to generate graphs (png graphs) using a loop,
> S=trunc(10^seq(1,3,by=.05))
> for(j in 1:length(S)){
+ s=S[j]
+ Xhist=hist(Xbar[,s],breaks=seq(0,1,by=.05),plot=FALSE)
+ nfile=paste("LLN-",100+j,".png",sep="")
+ png(nfile,600,350)
+ layout(matrix(c(3,0,1,2),2,2,byrow=TRUE), c(3,1), c(1,3), TRUE)
+ plot(1:s,Xbar[1,1:s],type="l",col="light blue",ylim=0:1,xlab="",ylab="",axes=FALSE,
+ xlim=c(10,k),log="x")
+ axis(1)
+ axis(2)
+ for(i in 2:(n-1)) lines(1:s,Xbar[i,1:s],col="light blue")
+ lines(1:s,Xbar[n,1:s],col="red",lwd=2)
+ abline(v=s)
+ barplot(Xhist$counts, axes=TRUE,horiz=TRUE,col="light green",xlim=c(0,n/2*1.05))
+ dev.off()
+ }
I start at 100 because afterwards, when merging files, it is better to have (really) consecutive numbers, since sometimes, the lexical order is used, i.e. after 1 is 10, then 100, etc. Then I use Terminal commands

Here, the delay is in /100 seconds, and I use an infinite loop. The graph is here

It is possible to use
> library(animation)
> ani.options(interval=.15)
> saveGIF({ })
But the loop can be used also to generate several graphs, and to produce an animated graph in a pdf document (slides or lecture notes). The idea is to use the same code, but the output is here a pdf graph.
> S=trunc(10^seq(1,3,by=.1))
> for(j in 1:length(S)){
+ s=S[j]
+ Xhist=hist(Xbar[,s],breaks=seq(0,1,by=.05),plot=FALSE)
+ nfile=paste("LLN-",j,".pdf",sep="")
+ pdf(nfile,10,6)
+ layout(matrix(c(3,0,1,2),2,2,byrow=TRUE), c(3,1), c(1,3), TRUE)
+ plot(1:s,Xbar[1,1:s],type="l",col="light blue",ylim=0:1,xlab="",ylab="",axes=FALSE,
+ xlim=c(10,k),log="x")
+ axis(1)
+ axis(2)
+ for(i in 2:(n-1)) lines(1:s,Xbar[i,1:s],col="light blue")
+ lines(1:s,Xbar[n,1:s],col="red",lwd=2)
+ abline(v=s)
+ barplot(Xhist$counts, axes=TRUE,horiz=TRUE,col="light green",xlim=c(0,n/2*1.05))
+ dev.off()
+ }
We can then import them in LaTeX,
\documentclass[a4]{article}
\usepackage{graphicx}
\usepackage{animate}
\begin{document}
\begin{center}
\animategraphics[height=3.1in,palindrome]{1}{/Users/UQAM/LLN-}{1}{21}
\end{center}
\end{document}
This will generate the following pdf file. This animate package is described in several forums, e.g. http://www.geogebra.org/…
Arthur Charpentier
Arthur Charpentier, professor in Montréal, in Actuarial Science. Former professor-assistant at ENSAE Paristech, associate professor at Ecole Polytechnique and assistant professor in Economics at Université de Rennes 1. Graduated from ENSAE, Master in Mathematical Economics (Paris Dauphine), PhD in Mathematics (KU Leuven), and Fellow of the French Institute of Actuaries.
To leave a comment for the author, please follow the link and comment on his blog: Freakonometrics » R-english.R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series,ecdf, trading) and more...
US market portrait 2013 week 18
US large cap market returns.
Fine print
- The data are from Yahoo
- Almost all of the S&P 500 stocks are used (as implied by Wikipedia on 2013 January 5 — see the R commands to scrape the data)
- The initial post was “Replacing market indices”
- The R code is in marketportrait_funs.R — you are free to use these functions however you like
invent clustering algorithms and visualization in r
the app shows how to use your own algorithm in r(written in various languages) and compare it with standard clustering algorithms using the visualization tools.









