[R] problem with "dynformula" from "plm" package [RE-POST]

David Winsemius dwinsemius at comcast.net
Fri Nov 27 18:22:22 CET 2009


On Nov 27, 2009, at 12:04 PM, Owen Powell wrote:

> Hi David,
>
> Thank you for the response.
>
> I forgot to mention that I'd already tried what (I think) you propose
> (adding ".form" to the end of the "lag", "log" and "diff") and I still
> see the same results (posted below). Specifically, I still see no
> lags, logs or diffs in my model.
>
> Any other ideas?
>
> ~Owen
>
> R> rm(list = ls())
> R> options(prompt= "R> ")
> R> library("plm")
> R> data("EmplUK", package="plm")
> R> EmplUK <- plm.data(EmplUK, index = c("firm", "year"))
> R> log(emp)~lag(log(emp),1)+lag(log(emp),2)+lag(log(wage), 
> 2)+lag(log(wage),3)+diff(capital,2)+diff(capital,3)
> log(emp) ~ lag(log(emp), 1) + lag(log(emp), 2) + lag(log(wage),
>    2) + lag(log(wage), 3) + diff(capital, 2) + diff(capital,
>    3)
> R> a = dynformula(emp~wage 
> + 
> capital 
> ,log 
> .form 
> = 
> list 
> (capital 
> = 
> FALSE 
> ,TRUE),lag.form=list(emp=2,c(2,3)),diff.form=list(FALSE,capital=TRUE))
> R> grun.fe <- plm(formula = a,data=EmplUK,model="within")
> [1] 1031    2

If I instead use the results of dynformula in plm as copied as a  
string from the output, I get what appears to be more what one might  
expect:

 > grun.fe <- plm(log(emp) ~ lag(log(emp), 1) + lag(log(emp), 2) +  
lag(log(emp),
+     1) + lag(log(emp), 2) + lag(log(wage), 2) + lag(log(wage),
+     3) + diff(capital, 2) + diff(capital, 3) ,data=EmplUK)
 > grun.fe

Model Formula: log(emp) ~ lag(log(emp), 1) + lag(log(emp), 2) +  
lag(log(emp),
     1) + lag(log(emp), 2) + lag(log(wage), 2) + lag(log(wage),
     3) + diff(capital, 2) + diff(capital, 3)

Coefficients:
  lag(log(emp), 1)  lag(log(emp), 2) lag(log(wage), 2) lag(log(wage),  
3)  diff(capital, 2)
         0.8678675        -0.1936447        -0.1632724          
0.3200785         0.0037612
  diff(capital, 3)
         0.0137866

It certainly appears that the function plm is not decoding its  
arguments as do most regression functions. Perhaps you should take up  
your concerns for this non-standard behavior up with the package  
authors?

-- 
David.

> R> summary(grun.fe)
> Oneway (individual) effect Within Model
>
> Call:
> plm(formula = a, data = EmplUK, model = "within")
>
> Unbalanced Panel: n=140, T=7-9, N=1031
>
> Residuals :
>    Min.  1st Qu.   Median  3rd Qu.     Max.
> -17.1000  -0.3060   0.0137   0.3070  27.3000
>
> Coefficients :
>         Estimate Std. Error t-value  Pr(>|t|)
> wage    -0.143626   0.032790 -4.3802 1.186e-05 ***
> capital  0.801495   0.064088 12.5062 < 2.2e-16 ***
> ---
> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
>
> Total Sum of Squares:    5030.6
> Residual Sum of Squares: 4207.8
> F-statistic: 86.9179 on 2 and 889 DF, p-value: < 2.22e-16
>
> 2009/11/27 David Winsemius <dwinsemius at comcast.net>
>>
>> On Nov 27, 2009, at 10:25 AM, Owen Powell wrote:
>>
>>> Hello list,
>>>
>>> I'm following the paper (http://www.jstatsoft.org/v27/i02/paper) on
>>> how to use "plm" to run panel regressions, and am having trouble  
>>> with
>>> what I believe should be something very basic.
>>>
>>> When I run the command (p.9 in the paper):
>>>
>>> R>
>>> dynformula(emp~wage 
>>> + 
>>> capital 
>>> ,log 
>>> = 
>>> list 
>>> (capital 
>>> =FALSE,TRUE),lag=list(emp=2,c(2,3)),diff=list(FALSE,capital=TRUE))
>>>
>>
>> Perhaps you could have read the help page for the current version  
>> of the package which says the argument have been modified. Using  
>> the current arguments:
>>
>> dynformula(emp~wage 
>> + 
>> capital 
>> ,log 
>> .form 
>> = 
>> list 
>> (capital 
>> = 
>> FALSE 
>> ,TRUE 
>> ),lag.form=list(emp=2,c(2,3)),diff.form=list(FALSE,capital=TRUE))
>>
>> log(emp) ~ lag(log(emp), 1) + lag(log(emp), 2) + lag(log(emp),
>>    1) + lag(log(emp), 2) + lag(log(wage), 2) + lag(log(wage),
>>    3) + diff(capital, 2) + diff(capital, 3)
>>
>> --
>> David Winsemius, MD
>>
>>> I see:
>>>
>>> emp ~ wage + capital
>>>
>>> rather than the complete model that is given in the paper:
>>>
>>> log(emp) ~ lag(log(emp), 1) + lag(log(emp), 2) + lag(log(wage), 2) +
>>> lag(log(wage), 3) + diff(capital, 2) + diff(capital, 3)
>>>
>>> And indeed, when I try to run a regression using that formula, it
>>> appears to not contain any lags or logs (output below).
>>>
>>> Any ideas? Thanks in advance,
>>>
>>> ~Owen
>>>
>>> --
>>> Owen Powell
>>> http://center.uvt.nl/phd_stud/powell
>>>
>>> R> library("plm")
>>> R> data("EmplUK", package="plm")
>>> R> a =
>>> dynformula(emp~wage 
>>> + 
>>> capital 
>>> ,log 
>>> = 
>>> list 
>>> (capital 
>>> =FALSE,TRUE),lag=list(emp=2,c(2,3)),diff=list(FALSE,capital=TRUE))
>>
>> snipped
>>
>>
>> David Winsemius, MD
>> Heritage Laboratories
>> West Hartford, CT
>>
>
>
>
> --
> Owen Powell
> http://center.uvt.nl/phd_stud/powell

David Winsemius, MD
Heritage Laboratories
West Hartford, CT




More information about the R-help mailing list