0
$\begingroup$

This might be a bit of a newbish question, but I recently picked up a forecasting project at my job, and I'm trying to figure out whether it makes sense to run a panel regression like a Fixed Effects or Random Effects Model, or if a simple cross-sectional OLS would suffice.

My data consists of three separate columns ordered by date, each consisting of test scores a given person received at three different time periods (see below). For all intents and purposes, each of the three tests are the same; that is, the specific questions might differ, but the overall structure and content is consistent, so the scores are likely highly correlated, and are presumably increasing over time.

Person ID/Index   Test 1   Test 2   Test 3
----------------|--------|--------|--------|
       1        |   65   |    70  |   81
       2        |   55   |    45  |   55
       3        |   90   |    95  |   93
       4        |   78   |    82  |   93
      ...           ...      ...      ...

My instinct tells me that this is a panel data problem, since we are looking at test scores both cross-sectionally across individual test-takers, and longitudinally over three testing periods, but I'm kind of second-guessing myself since my forecasting experience is pretty limited, and I haven't really worked with panel data in such a "clean" format before. I'm planning to do my analyses in Python or R, and if I'm understanding the documentation correctly, most relevant panel packages expect the data to be in a "long" format.

Would anyone care to weigh in? Is my instinct correct, or would a basic OLS do the trick?

$\endgroup$
  • $\begingroup$ Need to describe your purpose. $\endgroup$ – user158565 Jan 11 at 3:40
  • $\begingroup$ Why do you think this is a forecasting problem? $\endgroup$ – Isabella Ghement Jan 11 at 4:21
0
$\begingroup$

My instinct tells me that this is a panel data problem, since we are looking at test scores both cross-sectionally across individual test-takers, and longitudinally over three testing periods

Yes, you are correct. If a dataset has a combination of cross-sectional and time series data, then it is a panel dataset.

That said, depending on how big your dataset, you should ensure that you have enough observations across both subjects and time periods to ensure that you have a statistically significant sample size when generating the regression.

  • Fixed Effects: Effects that are independent of random disturbances, e.g. observations independent of time
  • Random Effects: Effects that include random disturbances

As you mentioned, this analysis can be accomplished in Python and R, but I will use R for this example.

To determine whether your model should be random or fixed, you should firstly apply what is known as the Hausman test.

If we cannot reject the null hypothesis, then a random effects model is preferred. However, if the null hypothesis is rejected, then a fixed effects model is preferred due to the estimator being at least as consistent as the random one under this scenario.

As an example, let's run the Hausman test on the gasoline data example in R:

> library(plm)
> 
> data("Gasoline", package = "plm")
> form <- lgaspcar ~ lincomep + lrpmg + lcarpcap
> wi <- plm(form, data = Gasoline, model = "within")
> re <- plm(form, data = Gasoline, model = "random")
> phtest(wi, re)

    Hausman Test

data:  form
chisq = 302.8, df = 3, p-value < 2.2e-16
alternative hypothesis: one model is inconsistent

With a p-value of less than 0.05, the null hypothesis is rejected at the 5% level and this indicates that a fixed effects model is preferred.

In this regard, a "within" model would be generated using plm (you can see a more extensive example here):

> library(plm)
> plmwithin <- plm(Y ~ X1 + X2 + X3, data = mydata, model = "within")

Taking the above into account, my suggestion would be to run a preliminary Hausman test on your data to determine if the model should be fixed or random, and proceed accordingly.

$\endgroup$

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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