I'm working with panel data using the plm package in R to estimate a fixed effects model that includes interaction terms. I'm currently able to get my model results using plm and display them with stargazer, but I'm looking for a more refined way to present these results, specifically focusing on the interaction terms. Additionally, I need to calculate and display the marginal effects of these interaction terms, including their p-values, in the same table. I'm also interested in plotting these marginal effects to better understand their impact.
Here's an example of my plm model setup:
fe_model_interaction <- plm(life_satisfaction ~
employment_level_Full_Time*care_low +
employment_level_Full_Time*care_high +
employment_level_Part_Time*care_low +
employment_level_Part_Time*care_high+
other_control_variables,
data = data_analyse_mother,
index = c("pid", "syear"),
model = "within")
My questions are:
What is the best way to display the plm model results, especially for interaction terms, in a more detailed and customizable format than what
stargazeroffers? I'm looking for a method to include standard errors, coefficients, and p-values in a clean and professional-looking table.How can I calculate and include the marginal effects of these interaction terms in the results table, along with their p-values?
What are the recommended approaches or packages in R for plotting the marginal effects of interaction terms in a fixed effects model estimated with plm?
The
marginaleffectsandmodelsummaryboth supportplmobjects. They both have extensive customization options and detailed tutorials. Please visit the package websites to access each package’s “Get Started” page:(Disclaimer: I am the maintainer.)
Your questions are not specific enough for me to solve your exact problem, but here is an example. First, we fit a model and display the results in a regression table using
modelsummary:Now, we use
marginaleffectsto compute quantities of interest. Note that the terminology around “marginal effects” is highly inconsistent across field, so I can’t know exactly what quantity you want based only on your post. Regardless, the package is extremely flexible, and you should be able to compute the quantities of interest if your read the documentation and tutorials. Here are some examples: average slopes, average contrasts, and average predictions by region:You can feed the resulting object back to
modelsummaryto display the results in a regression table. Here is an example:And you can use the
modelsummary::modelplot()function or one of the plotting functions frommarginaleffectsto visualize the results easily.