[R] plm Issues

spencerg
Sun, 12 Jul 2009 01:09:55 -0000

Your script ran for me without error under the following configuration:

 > sessionInfo()
R version 2.9.1 (2009-06-26)
i386-pc-mingw32

locale:
LC_COLLATE=English_United States.1252;LC_CTYPE=English_United
States.1252;LC_MONETARY=English_United
States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252

attached base packages:
[1] splines stats graphics grDevices utils datasets methods
[8] base

other attached packages:
[1] plm_1.1-4 sandwich_2.2-1 zoo_1.5-6 MASS_7.2-47
[5] Formula_0.1-3 kinship_1.1.0-22 lattice_0.17-25 nlme_3.1-92
[9] survival_2.35-4

loaded via a namespace (and not attached):
[1] grid_2.9.1 tools_2.9.1


I suggest you upgrade to R 2.9.1.


By the way, I did not know about "plm". To find that function, I
proceeded as follows:


library(RSiteSearch)
plm. <- RSiteSearch.function('plm')
HTML(plm.)


This identified 82 different help pages in 11 different packages; 38
matches were found in the "plm" package, which contained a function
called "plm". I assume this is the one you were using.


Hope this helps.
Spencer Graves


Damien Moore wrote:
> Hi List
>
> I'm having difficulty understanding how plm should work with dynamic
> formulas. See the commands and output below on a standard data set. Notice
> that the first summary(plm(...)) call returns the same result as the second
> (it shouldn't if it actually uses the lagged variable requested). The
third
> call results in error (trying to use diff'ed variable in regression)
>
> Other info: I'm running R 2.7.2 on WinXP
>
> cheers
>
>
>
> *>data("Gasoline",package="Ecdat")
>
>>
Gasoline_plm<-plm.data(Gasoline,c("country","year"))
>> pdim(Gasoline_plm)
>>
> **Balanced Panel: n=18, T=19, N=342
> *
> *>summary(plm(lgaspcar~lincomep,data=Gasoline_plm**))
> **Oneway (individual) effect Within Model
>
> Call:
> plm(formula = lgaspcar ~ lincomep, data = Gasoline_plm)
>
> Balanced Panel: n=18, T=19, N=342
>
> Residuals :
>     Min.  1st Qu.   Median  3rd Qu.     Max.
> -0.40100 -0.08410 -0.00858  0.08770  0.73400
>
> Coefficients :
>          Estimate Std. Error t-value  Pr(>|t|)
> lincomep -0.76183    0.03535 -21.551 < 2.2e-16 ***
> ---
> Signif. codes:  0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1
>
> Total Sum of Squares: 17.061
> Residual Sum of Squares: 6.9981
> Multiple R-Squared: 0.58981
> F-statistic: 464.442 on 323 and 1 DF, p-value: 0.036981
>
> **> summary(plm(lgaspcar~lag(lincomep),data=Gasoline_plm))
> **Oneway (individual) effect Within Model
>
> Call:
> plm(formula = lgaspcar ~ lag(lincomep), data = Gasoline_plm)
>
> Balanced Panel: n=18, T=19, N=342
>
> Residuals :
>     Min.  1st Qu.   Median  3rd Qu.     Max.
> -0.40100 -0.08410 -0.00858  0.08770  0.73400
>
> Coefficients :
>               Estimate Std. Error t-value  Pr(>|t|)
> lag(lincomep) -0.76183    0.03535 -21.551 < 2.2e-16 ***
> ---
> Signif. codes:  0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1
>
> Total Sum of Squares: 17.061
> Residual Sum of Squares: 6.9981
> Multiple R-Squared: 0.58981
> F-statistic: 464.442 on 323 and 1 DF, p-value: 0.036981
>
> *
> *>summary(plm(lgaspcar~diff(lincomep),data=Gasoline_plm))*
> *Error in model.frame.default(formula = lgaspcar ~ diff(lincomep), data
> mydata,  :
>   variable lengths differ (found for 'diff(lincomep)')
> *
>
> 	[[alternative HTML version deleted]]
>
>
> ------------------------------------------------------------------------
>
> ______________________________________________
> 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.
>