Reputation: 857
I am using this helpful package https://github.com/FixedEffects/FixedEffectModels.jl in Julia which helps to run Fixed Effects models.
I have one problem though, i am not sure how to extract the average marginal effects or predicted values of an interaction variable following the use of that package. For instance, the two lines below show how to extract the average marginal effects in Stata.
xtreg chronic_illness age country_birth social_class#macro_unemployment, fe
margins crisis, dydx(social_class)
Here is how to extract them in R: How to run the predicted probabilities (or average marginal effects) for individuals fixed effects in panel data using R?
Is there by any chance a similar version of it in Julia?
Here is the model that i am running in Julia:
m= reg(df1, @formula(chronic_illness ~ status+ age + social_class*crisis + fe(id) + fe(year) + fe(country)), contrasts=contr,save=true)
Chronic illness is a binary variable (0= no chronic illness), crisis is a binary variable (0= no financial crisis). The idea is to see how much different social classes scored on chronic illness when there is no crisis compared with when there is one. The model here just shows me the interaction effect, but i am interested in the baseline values.
Here is the output:
Fixed Effect Model
========================================================================================================
Number of obs: 1468882 Degrees of freedom: 459252
R2: 0.703 R2 Adjusted: 0.567
F-Stat: 62.8378 p-value: 0.000
R2 within: 0.001 Iterations: 18
========================================================================================================
cillness | Estimate Std.Error t value Pr(>|t|) Lower 95% Upper 95%
-------------------------------------------------------------------------------------------------------
status: Unemployed | 0.0145335 0.00157535 9.22556 0.000 0.0114459 0.0176212
status: missing | -0.00702545 0.0136504 -0.51467 0.607 -0.0337797 0.0197288
age | 0.00178437 2.79058 0.000639427 0.999 -5.46766 5.47123
class: Lower-middle class | 0.00458331 250.251 1.83149e-5 1.000 -490.478 490.487
class: Working class | 0.0286466 163.324 0.000175398 1.000 -320.081 320.138
crisis | -0.00600744 0.00156138 -3.84753 0.000 -0.00906768 -0.00294719
class: Lower-middle class & crisis | -0.00189866 0.00192896 -0.984289 0.325 -0.00567936 0.00188205
class: Working class & crisis | -0.00332881 0.00170221 -1.95558 0.051 -0.0066651 7.46994e-6
Upvotes: 3
Views: 461
Reputation: 13800
I'm not aware of an exact match for emmeans
in Julia, but you might be interested in the Effects.jl package. From the docs:
Regression models are useful but they can be tricky to interpret. Variable centering and contrast coding can obscure the meaning of main effects. Interaction terms, especially higher order ones, only increase the difficulty of interpretation. Here, we introduce Effects.jl which translates the fitted model, including estimated uncertainty, back into data space. Using Effects.jl, it is possible to generate effects plots that enable rapid visualization and interpretation of regression models.
As an aside, it appears that you have a binary response in your model so you probably should not fit a lienar model but a model appropriate for your data such that you can interpret coefficients as changes in probabilities/log odds, e.g. a logit or probit model. (Note that these aren't supported in FixedEffectsModels though, you'd have to fall back onto GLM.jl if your data isn't too big or GLFixedEffectModels).
Upvotes: 1