I want to fit a linear mixed model inside my function and extract estimates of random effect standard deviations (
sigmas from a
So I wrote the following function, and it runs perfectly in REPL or ipynb.
However, if I put this function (exactly the same function) into my package and run it through the
test command for packages, the property
sigmas no longer shows up in the list of property names. I checked that the model was fit successfully, and other properties such as
sigma were all present, but somehow
sigmas were not.
I just cannot understand why. Any help is appreciated. Thanks!
using StatsModels, MixedModels, JuliaDB, DataFrames function testlmm( file::String, f::FormulaTerm, id_name::String ) lhs_name = [string(x) for x in StatsModels.termvars(f.lhs)] rhs_name = [string(x) for x in StatsModels.termvars(f.rhs)] ftable = JuliaDB.loadtable( file, datacols = filter(x -> x != nothing, vcat(lhs_name, rhs_name)) ) df = DataFrame(ftable) categorical!(df, Symbol(id_name)) lmm = LinearMixedModel(f, df) print(propertynames(lmm, true), "\n") MixedModels.fit!(lmm) print(propertynames(lmm, true), "\n") end # I saved the sleep study dataset as a csv test("sleepstudy.csv", @formula(Reaction ~ 1 + Days + (Days | Subject)), "Subject")