Hello everybody,
   
  I've got a matrix called EUROPEDATA and I want to calculate the adf test statistic (part of the tseries package) on a rolling basis for window my.win on each column; i.e. each column of EUROPEDATA represents a particular variable; for the first column I calculate the adf test statistic for window my.win = 60 for example, roll forward one observation, calculate the adf again, and so on, until the end of the first column is reached and then I jump to the second column etc. The code for doing this is given below:
   
  adfroll <- sapply(1:(ncol(EUROPEDATA)), function(i, my.data, my.win)
  {
  sss <- sapply(1:(nrow(my.data)-my.win), function (j, my.data, my.win)
  { my.data <- as.matrix(my.data)
  ans <- adf.test(na.omit(my.data[j:(j+my.win)]))
  return(ans$p.value)
  },my.data=my.data[,i],my.win=my.win) 
  },my.data=EUROPEDATA,my.win=60,simplify=T)
   
  The problem is that the adf test does not calculate this way. There is an error saying:
   
  "Error in embed(y, k) : wrong embedding dimension"
   
  This error is generated from within the adf.test function. The embed function is part of the stats package, which I load before doing the adf.test.
   
  I would be very obliged if anybody were to explain to me why this happens and how I can correct it/ estimate what I want in a different way that will not invoke this error. 
   
  P.S. the function works fine if the adf.test on each column of the dataset is calculated, that is, without the rolling window for each column:
   
   
  summaryadf <- sapply(1:ncol(EUROPEDATA),function(i,my.data)
  {
  tt <- adf.test(na.omit(my.data[,i]))
  return(tt$p.value)
  },my.data=EUROPEDATA) 
   
  Please note that the same error is generated with the pp.test function of the tseries package
   
  Thanks in advance,
  Spyros

 		
---------------------------------

	[[alternative HTML version deleted]]

