I have MANY doubts when TRYING to use the plm() function.
Let's say my data.frame "df" has many variables as columns, e.g. ROS, type of business/industry, employees, assets, etc. It has these values for many businesses, and for each year.
For simplicity's sake, it could look like something like this:
> df
Year ID Type ROS Employees etc...
2010 1 55 103 4 ...
2011 1 55 120 6 ...
2012 1 55 111 6 ...
2010 2 42 106 5
2011 2 42 195 20
2012 2 42 214 20
2010 3 55 130 9
2011 3 55 95 12
2012 3 55 40 2
- When using plm is there a difference where we index the ID and time variables? In the pdata.frame or plm functions? I.e. should I do this:
panel <- pdata.frame(df, index = c("ID", "Year"))
and then not include the index in the plm function or should I put it directly into the plm function?
- How do I include "assets" as a control variable for "ROS" as dependent and "Employees" as independent?
Would it be this?
plm(ROS ~ Employees + Assets, index = c("ID", "Year"),
model = "within", effect = "twoways", data = panel)
-
What is the difference between the fixed effects or random effects models?
-
If I want the "ID" and "Year" variables to be fixed should I use the "twoways" effect or the "nested"? What is the difference between them?
-
How can I add a third variable to the index? The "Type" variable, for example. Does this work?
plm(ROS ~ Employees, index = c("ID", "Year", "Type"), model = "within",
effect = "twoways", data = df)
Or does the factor() function do the same thing? Could I even use the "twoways" effect in this? Is there a "threeways" effect?
plm(ROS ~ Employees + factor(Type), index = c("ID", "Year"),
model = "within", effect = "twoways", data = df)
Would doing this previous line of code give me the "Employees" estimated coefficient I'm looking for?
- Would using the "random" effects model solve this issue? Something like this:
plm(ROS ~ Employees + factor(Type), index = c("ID", "Year"),
model = "random", effect = "twoways", data = df)
Does using the "twoways" effect work for a model = "random"?
- How would I estimate "Type" and "Year" fixed effects and "ID" random effects using plm()?