Martin Hulényi
Martin Hulényi

Reputation: 55

R (splm): error tells me panel is unbalanced though the panel is balanced

when I run the spatial 2sls from the splm package using the spgm command, I get an error that the panel is unbalanced, even though it is balanced: The data

str(pdata.natura1)
Classes ‘pdata.frame’ and 'data.frame': 4680 obs. of  63 variables

The spatial weight matrix (inverse distance):

    str(dm1.lw)
    List of 3
     $ style     : chr "W"
     $ neighbours:List of 260
     $ weights   :List of 260

The conducted regression:

spgr01<-spgm(rgrowthpc~lrgdp0pc+lefpayr, 
             data=pdata.natura1, listw=dm1.lw,
             model="within", lag=TRUE, spatial.error= TRUE, 
             endog=~lefpayr, instruments=~area_prop,  
             method="w2sls"
             )
Error in spsarargm(formula = formula, data = data, index = index, listw = listw,  : 
  Estimation method unavailable for unbalanced panels

However:

is.pbalanced(pdata.natura1)
[1] TRUE

Can anyone please tell me where is the mistake?

Edit: Solved it by creating new panel dataset as a subset of the wold one.

Upvotes: 2

Views: 1001

Answers (1)

Soegampars
Soegampars

Reputation: 21

I had the same problem recently, and apparently putting your index column (such as "id" and "year" identifier column) as the first two column fixed it in my case.

Upvotes: 2

Related Questions