Package: tonymisc

Many of the methods and functions I have written about on this blog are available in my CRAN-contributed package tonymisc. As of its latest release (1.0.2), the tonymisc package contains methods that extend memisc's mtable() command to work with the following object types:
  • gls() objects from package nlme.
  • ivreg() objects from package AER.
  • plm() and pgmm() objects from package plm.
The package also allows for mtable() output of robust standard errors, probit and logit marginal effects and IV-regression objects created using the 2SLS command iv() within the tonymisc package.
  • mfx_me() coerces glm objects (probit or logit link) to interface conveniently with the mtable() command to report marginal effects.
  • robust() coerces lm objects to interface conveniently mtable() to specify heteroskedasticity-consistent standard errors.  This command also allows the user to keep or drop variables from the mtable() output.
  • iv() performs two-stage least squares regression and returns an object that conveniently allows the user to access first stage results and tests for relevance, both for single-endogenous regressor models (first stage F-test) and multiple-endogenous regressor models (test that the minimum canonical correlation is not zero, Anderson 2003).
Finally, the tonymisc library has several summary()-like commands available in the tonymisc library that report output to the screen for marginal effects, robust standard errors and IV models.
  • mfx() reports Stata-like marginal effects to the screen when applied to a glm()-fit probit or logit model.
  • summaryR() reports summary output for a lm()-fit model, but with robust standard errors (user-specified correction).
  • sum_iv() reports select summary output (first stage, second stage, F-test, CC-test) to the screen for an iv()-fit model.
Leave a comment on this page if you have questions or suggestions for this package.

2 comments:

  1. Hi Tony,
    I found your blog and tonymisc, looking for a way to do 2SLS with 2 endogenous variables.
    Unlike systemfit(), ivreg(), and so on, I intuitively understand iv()'s handling, and how to get the output that I want. I am really grateful that you provided the function (and the whole package). Thanks!

    What I noticed is that, if I have a structural equation with two endogenous variables on the RHS, then if I use sum_iv(fit, first=TRUE) to report the 1st stage results, I only get the 1st stage for the second endogenous variable (which ever I put in as "second_endog" in iv(...,first_endog+second_endog~...)). Also residuals(fit$first) only returns the residuals for second_endog.
    Seems to me that the loop in iv() that does the multiple first stages in the endog>1 case, overwrites previous cycles so that only the information on the last variable remains?!
    I also noticed that iv() can't handle log-models (workaround: do "x<-log(x)" for all variables that you need). The reasons seems to be the naming of the hat-variables: iv() just adds ".hat", so if log(x) is an endogenous variable, iv() produces a variable name log(x).hat, which R doesn't like.
    I'd like to solve these issues myself and post you the results, but I'm afraid that I would be more guessing than knowing what I do, and the result would be at least messy...

    Best,
    Christopher

    ReplyDelete
  2. Hey,

    I found your video very useful. I just want to thank you.

    from Seoul, Korea..

    Seongmin

    ReplyDelete