plm, controls, model, effect and index, fixed effects and random effects

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
  1. 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?

  1. 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)
  1. What is the difference between the fixed effects or random effects models?

  2. 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?

  3. 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?

  1. 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"?

  1. How would I estimate "Type" and "Year" fixed effects and "ID" random effects using plm()?

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.