I want to run the average marginal effects between two predictors: education and unemployment rate. While the package Effects in Julia can do the trick, i am having an error which i will describe below. First, i show the code that works perfectly fine and the results i get from running the MixedModelspackage. Second, i show the part of the code that is not working.
using Arrow, Effects, DataFrames, MixedModels, PooledArrays, FreqTables
dffnm = "df4_full"
df = DataFrame(Arrow.Table(dffnm))
df1 = DataFrame(
unemploy = disallowmissing(df.macro_unemployment),
workhours_imputed = df.workhours_imputed,
education = PooledArray(df.education),
id = PooledArray(string.(disallowmissing(df.id))),
age = Int8.(disallowmissing(df.age)) .- Int8(42), # center the age at 42
sex = PooledArray(df.sex),)
form1 = @formula workhours_imputed ~ 1 + sex + age + education + education * unemploy + sex * unemploy + (1|id)
contr = Dict(nm => Grouping() for nm in (:country, :country_year, :id))
contr = Dict(:country => Grouping(),
:country_year => Grouping(),
:id => Grouping(),
:sex => DummyCoding(base="Female"),
:education => DummyCoding(base="Tertiary"))
m1 = @time fit(MixedModel, form1, df1, contrasts=contr)
Everything works perfectly so far. The aim is to run the average marginal effects for education and unemployment on working hours. However, i thought that i would start with a simpler example which is just taking the average marginal effects of education (i follow their example here: https://beacon-biosignals.github.io/Effects.jl/stable/#Interaction-Terms-in-Effects):
design = Dict(:education => unique(df1))
effects(design, m1)
Error:
MethodError: no method matching effects!(::Dict{Symbol, DataFrame}, ::LinearMixedModel{Float64})
Closest candidates are:
effects!(::DataFrame, ::StatsBase.RegressionModel; eff_col, err_col, typical) at /Users/jmoawad/.julia/packages/Effects/B3CEy/src/regressionmodel.jl:40
Stacktrace:
[1] top-level scope
@ In[28]:1
[2] eval
@ ./boot.jl:360 [inlined]
[3] include_string(mapexpr::typeof(REPL.softscope), mod::Module, code::String, filename::String)
@ Base ./loading.jl:1116
Could someone help me to fix this? I am also unsure how to run the average marginal effects for the interaction between education and unemployment rate.
