Instrumental Variables Regression (IV Regression) - R for Economists Moderate 4
HTML-код
- Опубликовано: 11 сен 2024
- This series of videos will serve as an introduction to the R statistics language, targeted at economists.
In this video we cover how to perform an instrumental variables regression using ivreg() from the AER package. We also cover how to estimate the first stage separately, and run an F-test on the instruments using linearHypothesis().
Also, oops, I totally goofed on the source of the AER package. It is indeed from Applied Econometrics with R, but that is an entirely separate book from Florian Heiss' Using R for Introductory Econometrics! Heiss' book can be found in free ebook form here: urfie.net/read/...
Download the code from all my R videos at once at nickchk.com/R%...
You can find links to every video in the series here: nickchk.com/vid...
There are videos on: [BASIC] Getting Started, Getting Help, Objectives and Variables, Vectors and Matrices, Data Frames, Packages, Summary Statistics (of One and Two Variables), Plots and Graphs, and Linear Regression (OLS), [MODERATE] Regression Formulas, Robust or Clustered Standard Errors and Post-Regression Stats, Regression Plots, Instrumental Variables (IV Regression), Time Series, ARIMA and ARMA, Probit and Logit, Tobit and Heckman, Panel Data, and Missing Data, and [ADVANCED] Simulations, The Tidyverse, Reshape and Join/Merge, dplyr (Introduction, Piping, and Grouping), ggplot (Introduction, Geometries, Overlaid and Grouped Plots, and Titles and Labels), and vtable
Thank you for you contribution to R knowledge, Mr. Huntington-Klein. Haven't found an article on the Internet, on how to calculate first-stage reg in R. Your video helped a lot actually and saved hours of search.
I've followed you on Twitter for so long and I didn't know you have a RUclips channel!. I'm so happy because now I know how I'm gonna spend my vacations (I really need to improve in R).
Thank you for all your contributions for students around the world :)
Thanks a lot! Among all my search results you were the one who helped me complete my homework :)
Edit: And more importantly, understand the concept.
Dude, it's really amazing how easy you are to explain things, thank you! 😁
This is a great job mate!...I only wanted to say thank you for your effort and dedication (and I am waiting for the Panel Data Session!!!)...Thanks again!!!
Thank you! Panel data is coming in the next batch of videos, probably filming this weekend and posting next week.
Amazing!!...I am doing my PhD in Australia and I have built a Panel, but I do not feel really confident with the "empirical strategy" to follow to analyze my data with the plm and the splm packages. Running the commands is the easy part, but interpreting and deciding which is the "better model" can be hard...Thanks again...
Great job. I just wanted to say thank you.
Also another Q, im assuming the same method can be used for panel data? Thanks in advance !
Yep.
@@NickHuntingtonKlein thanks! Was wondering if i need to use fixed effects but guess the instrument already gives as good as random variation
@@klopplegend4520 You might - FE might improve precision or be necessary to support your validity assumption. But it's not by default necessary.
@@NickHuntingtonKlein you're a legend! Thanks
I'm probably still going to be coming back to these videos years after I graduate :)
That's what I like to hear!
Thank you for this useful video.
However, i have one question:
Is this function (ivreg) is usable with binomial variables?
By advance thanks
In the dependent variable? You're probably fine although you might consider use of the ivpoisson package. If you mean binary instead of binomial, then don't use ivreg, use the ivprobit package instead.
Hello Nick, is there a way to use the ivreg() command together with a fixed effects model?
Thank you!
The felm command in the lfe package, or the iv_robust command in the estimatr package can both do this. Former is more powerful, latter easier to use.
@@NickHuntingtonKlein thanks for your support! i used the iv_robust() command and included company and year fixed effects. for testing if my instrument is weak/strong, I tried the linearHypothesis() command which you used in your iv_reg() tutorial based on a firststage regression for which I used the lm_robust() command and same fixed effects.
However, the linearHypothesis() command does not return a F-value for my instrument. Do you have any idea how the test for weak/strong instrument can work with iv_robust() ???
Again big thank you! :) your videos are really helpful!
@@patrickstender6949 set the diagnostics option to TRUE and it will do it automatically
is it possible to use a binary variable as an instrument ?
Yep! Very common actually
Thanks for the video. How can we use the method in panel data?
The plm or lfe packages are both capable of this, see for example stats.stackexchange.com/questions/243438/test-excluded-instrument-in-r-plm-package
my f statistic is over 200. is this a problem?
Not necessarily a problem but worth checking - if you look at your first stage do you get something that looks like near-perfect multicollinearity (e.g. an R^2 very near 1?) if so there may be something degenerate about your model where you're basically using the endogenous variable to predict itself in some way. But if that's not the case, then you've just got a super good instrument and thumbs up to that.
@@NickHuntingtonKlein thank you for your prompt response. My r square is actually not close to one for the first stage. More like 0.75. so i guess I'm fine! Thanks for your response :) and your videos are super helpful.