The problem arises because your data.frame contains no factors and plm:::lev2var implicitly assumes that its input data.frame, x, contains both factor and non-factor columns. That is because, e.g., the output of sapply(zeroLongInput, func) has class NULL, not the class of the output of func() (since func() was never called it doesn't know what that class would be). Similarly, the output of unlist(zeroLongList) and names(zeroLongVector) have class NULL. It might be nice if names(NULL)<-character(0) worked, since it would not corrupt NULL, but it doesn't. It also might be nice if sapply had an option that let you declare the output type of func so sapply's output always had the expected type, but that wouldn't solve the whole problem.
A possible change to plm:::lev2var is to pass the output of the some of these calls through as.character() so the NULL is changed to character(0), as in plm:::lev2var <- function (x, ...) { is.fact <- sapply(x, is.factor) not.fact <- names(x)[!is.fact] names(not.fact) <- not.fact x <- x[is.fact] wl <- lapply(x, levels) nl <- sapply(wl, length) nf <- as.character(rep(names(nl), nl)) # as.character in case of 0-long result result <- as.character(unlist(wl)) # ditto names(result) <- nf result <- paste(names(result), result, sep = "") names(nf) <- result c(nf, not.fact) } I used trace(plm:::lev2var, edit=T) to test this change -- the real fix involves changing the source code and recompiling the package. Bill Dunlap TIBCO Software Inc - Spotfire Division wdunlap tibco.com [R] plm Hausman-Taylor model Ron Burns rrburns at cox.net Sat Apr 25 19:47:24 CEST 2009 Dear all- I am have trouble in using the model="ht" option in function plm from the plm library. I am using Package: plm Version: 1.1-1; R version 2.8.1 (2008-12-22) running on a FC-8 linux machine. Here is what I am trying to do: ##---------------------------------------------------------------------- ------ R> ###Prob 6 Chapter 3 Use R! Applied Econometrics with R (Kleiber & Zeileis) R> ## hlp(PSID1982) => cross section data for 1982 only Need panel data I guess R> ## found full set on STATA web site R> ## http://www.stata-press.com/data/r10/psidextract.dta R> ## STATA results in Sec 2 of: folk.uio.no/erikbi/ECON5120_H07_Note19.pdf R> library("foreign") R> fulldat <- read.dta("~/Desktop/psidextract.dta") R> library("plm") R> R> fulldat.plm = plm.data(fulldat,index=c("id","t")) R> 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") Error in names(result) <- nf : attempt to set an attribute on NULL I have tried several variations and some other data sets (not so easily reproducible for others as this one) but have yet to obtain an error free result. Thanks in advance for any help Ron -- R. R. Burns Retired Oceanside, CA ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.