[R] problem with dynformula from plm package

2009-11-27 Thread Owen Powell
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))

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))
R testModel - plm(formula = a,data=EmplUK,model=within)
[1] 10312
R summary(testModel)
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

[[alternative HTML version deleted]]

__
R-help@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.


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

2009-11-27 Thread Owen Powell
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))

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))
R testModel - plm(formula = a,data=EmplUK,model=within)
[1] 10312
R summary(testModel)
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

__
R-help@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.


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

2009-11-27 Thread Owen Powell
Great! That did the trick, thanks David.

To summarize for the list, to get dynformula to work (example):

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

it might be necessary to use:

R plm(formula = formula(a), data=EmplUK)

rather than just:

R plm(formula = a, data = EmplUK)

~Owen

2009/11/27 David Winsemius dwinsem...@comcast.net:
 You might also note that the authors hint on the help page that one might
 want to use the formula() operation on the result of dynformula. Following
 that path would have gotten us to a more successful conclusion.

 grun.fe - plm(formula = formula(a),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


 --
 David.
 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
 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 dwinsem...@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





-- 
Owen Powell
http://center.uvt.nl/phd_stud/powell

__
R-help@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.


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

2009-11-27 Thread Owen Powell
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] 10312
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 dwinsem...@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

__
R-help@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.


[R] joint estimation of two poisson equations

2009-04-13 Thread Owen Powell
Dear list members,

Is there a package somewhere for jointly estimating two poisson processes?

I think the closest I've come is using the SUR option in the Zelig
package (see below), but when I try the poisson option instead of
the SUR optioin I get an error (error given below, and indeed,
reading the documentation of the Zelig package, I get the impression
poisson was not meant to handle a system of equations).

I think I could do it myself by constructing the likelihood function
and then applying ML, but I'd prefer to avoid doing that unless it's
entirely necessary.

I'll post my solution to the list when I've worked it out.

Regards,

~Owen

# CODE FOR sur OPTION
rm(list = ls())
library(Zelig)

y1 = c(1,2,3,4)
y2 = c(0,2,0,2)
x = c(2,3,4,8)
d = data.frame(cbind(y1, y2, x))

eq1 = y1 ~ x
eq2 = y2 ~ x
eqSystem = list (eq1, eq2)

system_out = zelig(formula = eqSystem, model = sur, data = d)
summary(system_out)

-

# ERROR FROM REPLACING sur WITH poisson
Error in switch(mode(x), `NULL` = structure(NULL, class = formula),  :
  invalid formula

--
Owen Powell
http://center.uvt.nl/phd_stud/powell

__
R-help@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.


Re: [R] joint estimation of two poisson equations

2009-04-13 Thread Owen Powell
Thanks Tirthankar, that did the trick.
Here's the solution to my problem using the bivpois package:

rm(list = ls())
library(bivpois)

y1 = c(1,2,3,4,4,3)
y2 = c(0,2,0,2,3,5)
x1 = c(2,3,4,8,1,3)
x2 = c(3,5,6,7,8,9)
d = data.frame(cbind(y1, y2, x))

eq1 = y1 ~ x1 + x2
eq2 = y2 ~ x1 + x2

out = lm.pb(eq1, eq2, data = d, zeroL3 = TRUE)
print(out)

I couldn't find out how to get standard errors and p-values from the
package, so I bootstrapped them.

~Owen

2009/4/13 Tirthankar Chakravarty tirthankar.chakrava...@gmail.com

 You should probably try the -bivpois- package:
 http://cran.r-project.org/web/packages/bivpois/index.html

 A very good discussion of multivariate Poissons, negative binomials
 etc. can be found in Chapter 7 of Rainer Winkelmann's book
 Econometric Analysis of Count Data (Springer 2008). Most of the
 likelihoods involved are fairly straightforward.

 T

 On Mon, Apr 13, 2009 at 9:32 AM, Owen Powell opow...@gmail.com wrote:
  Dear list members,
 
  Is there a package somewhere for jointly estimating two poisson
 processes?
 
  I think the closest I've come is using the SUR option in the Zelig
  package (see below), but when I try the poisson option instead of
  the SUR optioin I get an error (error given below, and indeed,
  reading the documentation of the Zelig package, I get the impression
  poisson was not meant to handle a system of equations).
 
  I think I could do it myself by constructing the likelihood function
  and then applying ML, but I'd prefer to avoid doing that unless it's
  entirely necessary.
 
  I'll post my solution to the list when I've worked it out.
 
  Regards,
 
  ~Owen
 
  # CODE FOR sur OPTION
  rm(list = ls())
  library(Zelig)
 
  y1 = c(1,2,3,4)
  y2 = c(0,2,0,2)
  x = c(2,3,4,8)
  d = data.frame(cbind(y1, y2, x))
 
  eq1 = y1 ~ x
  eq2 = y2 ~ x
  eqSystem = list (eq1, eq2)
 
  system_out = zelig(formula = eqSystem, model = sur, data = d)
  summary(system_out)
 
  -
 
  # ERROR FROM REPLACING sur WITH poisson
  Error in switch(mode(x), `NULL` = structure(NULL, class = formula),  :
   invalid formula
 
  --
  Owen Powell
  http://center.uvt.nl/phd_stud/powell
 
  __
  R-help@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.
 



 --
 To every ù-consistent recursive class ê of formulae there correspond
 recursive class signs r, such that neither v Gen r nor Neg(v Gen r)
 belongs to Flg(ê) (where v is the free variable of r).




-- 
Owen Powell
http://center.uvt.nl/phd_stud/powell

[[alternative HTML version deleted]]

__
R-help@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.