0
$\begingroup$

I have many panels of two-year longitudinal data, something of the form:

# A tibble: 8 x 5
     ID  year     Y    X1     X2
  <int> <int> <int> <int> <fctr>
1     1  2015     2     2      D
2     1  2016     4     5      C
3     2  2015     1     5      A
4     2  2016     1     2      C
5     3  2015     4     3      D
6     3  2016     5     3      B
7     4  2015     3     1      C
8     4  2016     3     1      C

I am interested in how changes in $X_1$ and $X_2$ affect changes in $Y$. My data has many different types of variables, and in this instance $X_1$ is ordinal and $X_2$ is nominal.

I am particularly interested in how a transition from $A$ to $B$ or vice versa in the variable $X_2$ would affect $Y$.

Initially I was thinking of modelling the change in $Y$ is a linear regression with dummy variables for where $X_2$ goes from $A$ to $B$ or vice versa, and also including $X_1$.

Doing a quick google search leads me to a lot of literature relating to these sorts of problems, however, I have never worked with panel data before, and I am in need of a good starting point, ideally with examples, and perhaps implementation which is available in R.

Previous authors working with a similar dataset have done this using pooled OLS, though, I am not well versed in this area and have read commentary about fixed effects and random effects modelling which is preferable to pooled OLS.

Any suggestions or guidance would be greatly appreciated.

$\endgroup$
  • $\begingroup$ In R you usually want to go with package plm (cran.rstudio.com/web/packages/plm). See the vignette for an introduction. Also, Wooldridge, Introductory Econometrics, is a good starting point. Here is a book which builds on top of Wooldridge and gives R implementations: urfie.net/index.html $\endgroup$ – Helix123 Jan 9 '17 at 20:56
1
$\begingroup$

A very simple regression that you can run for the same is modelling your outcome as a linear function of the two variables much like the pooled OLS but now taking advantage of the panel nature of the data! So something like: $Y_{it} = \alpha_{i} + \delta_{t} + \beta_{1} X_{1it} + \beta_{2} X_{2it} + \varepsilon_{it}$

Note here $\alpha_{i}$ gets rid of any individual specific factors that dont vary over time, and $\delta_{t}$ gets rid of any time varying factors affecting your outcomes. A first difference means that you reduce your data to n-1 data points, by estimating the folliwng equation: $\Delta Y_{it} = \Delta \delta_{t} + \beta_{1} \Delta X_{1i} + \beta_{2} \Delta X_{2i} + \Delta\varepsilon_{i}$ You can estimate the above as a first difference or a fixed effects regression. Given that you have two time periods, both the estimates would be the same (Please Refer Angrist and Pischke Chapter 5 for a discussion of the same). Hope this helps you!

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.