[R] Attribute Length Error when Trying plm Regression

arun smartpink111 at yahoo.com
Wed Sep 4 23:14:23 CEST 2013


HI,
It is better to provide a reproducible example using ?dput().
you can also check in this link.

http://r.789695.n4.nabble.com/names-attribute-must-be-the-same-length-as-the-vector-td4503946.html

library(plm)
#Using the example from ?plm()
 data("Produc", package = "plm")
 zz <- plm(log(gsp) ~ log(pcap) + log(pc) + log(emp) + unemp, data = Produc, index = c("state","year"))

#Suppose, if I use a model like this:
zz1<- plm(gsp~pcap+pc+emp+unemp+water+util,data=Produc,index=c("gsp","year"))
#Error in names(y) <- namesy : 
 # 'names' attribute [816] must be the same length as the vector [0]

In your model statement, 

fixed <- plm (h ~ o + m + a, data=drugsXX, index=c("h","year"),
model="within") 


A.K.


----- Original Message -----
From: lross8 <lross8 at kent.edu>
To: r-help at r-project.org
Cc: 
Sent: Wednesday, September 4, 2013 3:22 PM
Subject: [R] Attribute Length Error when Trying plm Regression

Hello,

I am trying to run a fixed effects panel regression on data containing 5
columns and 1,494 rows. 

I read the data in as follows:

>drugsXX<-read.csv(file="C:\\Folder\\vX.X\\Drugs\\drugsXX_panel.csv",
head=TRUE, sep=",")

Verified it read in correctly and had a good data.frame:
>dim(drugsXX)
[1] 1494    5
>drugs XX
produce expected data with correct column names

The issue is, when I go to run the plm using:
>fixed <- plm (h ~ o + m + a, data=drugsXX, index=c("h","year"),
model="within") 

I get this error:
Error in names(y) <- namesy : 
  'names' attribute [996] must be the same length as the vector [0]

I know the data recognizes that I have 5 columns. I also know that there's
nothing wrong with row 996 (I even want back and checked for hidden
characters in the original .csv file).

traceback() was useless:
4: pmodel.response.pFormula(formula, data, model = model, effect = effect, 
       theta = theta)
3: pmodel.response(formula, data, model = model, effect = effect, 
       theta = theta)
2: plm.fit(formula, data, model, effect, random.method, inst.method)
1: plm(h ~ o + m + a, data = drugsXX, index = c("h", 
       "year"), model = "within")

What explicit steps can I follow to get my panel regression to run? 

Thank you, 
Laura



--
View this message in context: http://r.789695.n4.nabble.com/Attribute-Length-Error-when-Trying-plm-Regression-tp4675384.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help at 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.




More information about the R-help mailing list