Skip to content
Prev 178323 / 398506 Next

plm Hausman-Taylor model

On Sat, 25 Apr 2009, Ron Burns wrote:

            
This seems to be a bug in "plm". traceback() shows:

R> traceback()
4: lev2var(data[, -c(K - 1, K)])
3: plm.ht(formula, data)
2: switch(model, within = plm.within(formula, data, effect), between = 
plm.between(formula,
        data, effect), pooling = plm.pooling(formula, data), random = 
plm.random(formula,
        data, effect, random.method, inst.method), ht = plm.ht(formula,
        data), fd = plm.fd(formula, data))
1: plm(lwage ~ occ + south + smsa + ind + exp + exp2 + wks + ms +
        union + fem + blk + ed | exp + exp2 + wks + ms + union +
        ed, data = fulldat.plm, model = "ht")

lev2var() is a function internal to "plm" and it apparently fails if there 
are no factors in the data. (The result is NULL and lev2var() tries to 
assign names to it; these are character(0) but still this fails with the 
error message you have quoted above.) Maybe Yves can clarify this.

A workaround for your example is to code the dummy variables as factors 
(which might also be more useful in other situations). For example:

R> for(i in c(3:9, 11)) fulldat[[i]] <- factor(fulldat[[i]])
R> fulldat.plm = plm.data(fulldat,index=c("id","t"))
R> earn_plm <- plm(lwage~ occ+ south + smsa+ ind + exp + exp2 + wks +
+    ms + union + fem + blk + ed | exp + exp2 + wks + ms + union + ed,
+    data = fulldat.plm, model = "ht")

Of course, more meaningful factor levels would be desirable but at least 
this works. It gives similar results to those that you refer to above, but 
they are not identical. Maybe Yves can something more about the 
differences to Stata.

hth,
Z