Dear R-Community,

I tried plotting the residuals of an FE-model estimated via plm .

And detected that there are no residuals in the plot for the last two
countries.

I guess this happens because for some countries values are missing and R
gives me the following for 

 

> fixed.reg1.new$resid[1]

         5 

-0.4051985

 

Because the first 4 elements are missing. So there are residuals different
from zero for the last two countries, but because of NA there´s a shift
because the residuals are not padded to the correct length.

 

I´ve  read  in https://stat.ethz.ch/pipermail/r-help/2008-June/166312.html
and the manual

that na.action=na.exclude is useful in lm-case to avoid this:  “when
na.exclude is used the residuals and predictions are padded to the correct
length by inserting NAs for cases omitted by na.exclude”

 

and tried it for my plm regression, but it does not work.

 

Perhaps you have an Idea how to get residuals into the correct length? Or
another way to deal with it?

 

 

 

 

To make it easier explaining the way of proceeding, a reproducible example
could be:

 

> # add NA´s for firm 6

> 

> data("Grunfeld", package = "plm") 

> Grunfeld$inv2= ifelse(Grunfeld$firm==6,NA, Grunfeld$inv)

> data<- pdata.frame(Grunfeld,index=c("firm","year"))

> fixed.reg1.1 <- plm(value~inv2+capital,

+                data = data,na.action=na.exclude ,index=c("firm","year"),
model="within")

> #resid(fixed.reg1.1) 

> # no values for firm 6, no residuals displayed from 101-120

> fixed.reg1.1$resid[105]

     125 

9.371963

> require(lattice)

> xyplot(resid(fixed.reg1.1) ~ firm, data=data)

# As you can see because of  the NA´s of firm 6 ,there´s a shift because the
residuals are not padded to the correct length,

#  and looking at the plot suggests there are no residuals for firm 10,
which is not true.

 

 

 

Thanks in advance for your help!

Have a nice day Katie

 

 

 


	[[alternative HTML version deleted]]

