2
$\begingroup$

After days of searching for an answer to my problem, reading guide documents, questions and answers here and elsewhere, I decided to ask this community. I am new to R (and R Studio), coming from working with Stata only, and I am having trouble with performing a regression using panel data and the plm function.

What I want to estimate is how much better an investment model ("P_Model") is at identifying firms that tend to increase share price over time, controlling for Country and industry Sector. I created an Excel file structured as it should be for panel data (as far as I know), and can be found here (all data there is public so there is no privacy or data issues). There are only 7 variables:

"Company" -> the firms.

"t" -> time period.

"Country"

"Sector" -> industry.

"Subsector"-> industry subsector (this was out of curiosity, not used for the main regression).

"P_Model" -> binary variable that is 0 for all firms that were chosen at random and not using the model, and 1 for those that were.

"ValoPP" -> this is the firm's stock price return on investment from day 1, in percentage points.

After loading the data to R, I tried several different suggestions of how to perform the panel regression, but they all give this error: R input and error

I believe the problem has to be with the panel structure I am using, but I can't find out what this is, as every firm has one of each of the other variables and only one time variable.

EDIT:

I created a simple test to check whether the issue was with coding or statistical concepts, and it seems to be definitively the latter. I used the following data and tried to run the same regression as above, getting the same error:

Simple Test

I tried to find out the impact of being a Male on the GPA of 3 students in 3 years. What concept am I getting wrong?

I have edited this post to adjust for this shift of focus.

$\endgroup$
2
  • $\begingroup$ There might be some statistical content in that question, but it could be a programming questions well. The variable P_Model does not seem to vary per Company (at a quick glance, did not check thoroughly), it could be perfectly collinear with Country and/or Sector, thus dropping out of the model and, hence, empty model. Also, you do not disclouse what kind of model you want to estimate. $\endgroup$
    – Helix123
    Commented Jan 23, 2021 at 13:33
  • $\begingroup$ Thank you for the quick response. The P_Model varies per company, though it is a dummy variable that is only "1" for 37 out of the 300+ companies, but I understand that it is not perfectly collinear with either Country or Sector because the process I used for randomization was: for each firm with P_Model = 1, I added 10 firms from the same country and sector. So there is at least 2 countries and 2 sectors for each P_Model = 1. Regarding the kind of model, I understand that due to the controls I chose, a random effects model would be best. Please let me know if I misunderstood your comments. $\endgroup$
    – PPBarbos
    Commented Jan 23, 2021 at 13:54

2 Answers 2

1
$\begingroup$

I don't understand exactly why, but I solved the issue with the panel data. Apparently, the problem was that I was adding "Company" in the panel index. In other words:

I was using this:

pdata <- pdata.frame(mydata, index = c("Company","t"))

And I should have been using this:

pdata <- pdata.frame(mydata, index = "t")

With that, the problem was fixed and the regression ran correctly.

$\endgroup$
1
  • $\begingroup$ You want to check if the way you specified the index variables is what you want, e.g., look at index(pdata) to see what the individual and time dimension looks like. $\endgroup$
    – Helix123
    Commented Feb 13, 2021 at 22:02
0
$\begingroup$

For the ones searching for this answer, the whole thing is that for using plm you have to declare your series as a panel data series. To check whether you have set this or not, use class(df); if is not pdata.frame you should

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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