[R] plm Issues

Damien Moore
Thu, 09 Jul 2009 14:58:11 -0000

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]]