Take the 2-minute tour ×
Cross Validated is a question and answer site for people interested in statistics, machine learning, data analysis, data mining, and data visualization. It's 100% free, no registration required.

I have the plm package and would like to run unit root tests on some variables. I get the following error:

> purtest(data$tot.emp)
Error in data.frame(baldwin = c(59870, 61259, 60397, 58919, 57856, 57227,  : 
  arguments imply differing number of rows: 14, 19, 11, 12, 1, 20, 18, 10, 13

I assume that I'm getting this error because my panel is unbalanced. Two questions:

  • Can you use panel unit root tests (Levin, Lin and Chu (2002), Im, Pesaran and Shin (2003), or others) for unbalanced panels?
  • If so, is it implemented in R?
share|improve this question
    
I can't answer your question but FYI, Stata runs these tests even when the variable is unbalanced. However, Breitung's, Harris-Tzavalis and Hadri's LM tests seem to require balancedness. –  johnny Jul 31 '12 at 1:50
    
An update. Take a look at the punitroots package. I think it may do what you want. road.unimol.it/bitstream/2192/163/3/ESDP11063.pdf –  Manoel Galdino Oct 22 '13 at 20:17
add comment

3 Answers

up vote 4 down vote accepted

At the current moment (version 1.2-10) it seems that the unbalanced case is not supported. I've looked at the code, and the final data preparation line (no matter what is your initial argument) is the following:

 object <- as.data.frame(split(object, id))

If you pass unbalanced panel, this line will make it balanced by repeating the same values. If your unbalanced panel has time series with lengths which divide each other then even no error message is produced. Here is the example from purtest page:

 > data(Grunfeld)
 > purtest(inv ~ 1, data = Grunfeld, index = "firm", pmax = 4, test = "madwu")

Maddala-Wu Unit-Root Test (ex. var. : Individual Intercepts )

  data:  inv ~ 1 
  chisq = 47.5818, df = 20, p-value = 0.0004868
  alternative hypothesis: stationarity 

This panel is balanced:

 > unique(table(Grunfeld$firm))
  [1] 20

Disbalance it:

 > gr <- subset(Grunfeld, !(firm %in% c(3,4,5) & year <1945))

Two different time series length in the panel:

 > unique(table(gr$firm))
  [1] 20 10

No error message:

> purtest(inv ~ 1, data = gr, index = "firm", pmax = 4, test = "madwu")

    Maddala-Wu Unit-Root Test (ex. var. : Individual Intercepts )

data:  inv ~ 1 
chisq = 86.2132, df = 20, p-value = 3.379e-10
alternative hypothesis: stationarity 

Another disbalanced panel:

  > gr <- subset(Grunfeld, !(firm %in% c(3,4,5) & year <1940))
  > unique(table(gr$firm))
  [1] 20 15

And the error message:

 > purtest(inv ~ 1, data = gr, index = "firm", pmax = 4, test = "madwu")
  Erreur dans data.frame(`1` = c(317.6, 391.8, 410.6, 257.7, 330.8, 461.2,  : 
  arguments imply differing number of rows: 20, 15
share|improve this answer
add comment

Did you try to convert your data to pdata.frame? I have an unbalanced panel also, but purtest seems to work with unbalanced panel if the data is pdata.frame. But I might be wrong too:)

However in ?purtest authors write:

"object, x  

Either a 'data.frame' or a matrix containing the time series, 
a 'pseries' object, a formula, or the name of a column of a 'data.frame',
or a **'pdata.frame'**
on which the test has to be computed; a'purtest' object for the print 
and summary methods,"

So I guess if one uses pdata.frame the purtest "understands" that panel is unbalanced.

Am I wrong???

share|improve this answer
add comment

Eviews 5 allows you to test the panel unit roots for the unbalanced data that is not possible with R and Stata. For example, even though Im–Pesaran–Shin and Fisher-type tests can be applied for unbalanced panel in Stata, it is not possible if we have some observations , with the gap i.e. we have data of country i for year 2002 and 2004 but not 2003 (assuming the lag to be greater than one). I think that Eviews drop all such observations while performing tests, for our example this is country i. However, if you manually drop all such observations, you can still perform the tests with R and Stata.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.