I am new with Julia, my background is Stata. I am looking a way for get marginal mean for a categorical variable (Stata: margins i.group).
I am using categorical variable for variable group, then my goal its get probabilities for each level of variable group, but lamentably I get for all model.
example:
using Margins, DataFrames, GLM, CategoricalArrays, Random
n = 10000
Random.seed!(06515)
y = rand([0,1], n)
data = DataFrame(y=y, x1 = randn(n),
x2 = randn(n),
bino =rand([1,2], n),
group = rand(["A", "B", "C"], n))
model = glm(@formula(y ~ x1+ x2+ bino+ group), data, Binomial(), LogitLink())
population_margins(model, data; type=:predictions)
PredictionsResult: 1 population predictions (N=10000)
────────────────────────────────────────────────────
Prediction Std. Err. [95% Conf. Interval]
────────────────────────────────────────────────────
0.4952 0.005 0.4854 0.505
────────────────────────────────────────────────────
My goal its get this Stata result but using Julia:
------------------------------------------------------------------------------
| Delta-method
| Margin std. err. z P>|z| [95% conf. interval]
-------------+----------------------------------------------------------------
group |
A | .4845861 .0086549 55.99 0.000 .4676229 .5015493
B | .5056282 .0087316 57.91 0.000 .4885145 .5227418
C | .4955554 .0085923 57.67 0.000 .4787148 .5123959
------------------------------------------------------------------------------
.