From 0ad05945c060bc95f401664bd2f6971772fdc317 Mon Sep 17 00:00:00 2001 From: Douglas Bates Date: Fri, 16 Aug 2024 10:32:03 -0500 Subject: [PATCH] Add checks on complete separation --- issues/780/issue.jl | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/issues/780/issue.jl b/issues/780/issue.jl index df70d8d4f..2603b111b 100644 --- a/issues/780/issue.jl +++ b/issues/780/issue.jl @@ -25,10 +25,18 @@ module IssueData data = open(Downloads.download(URL), "r") do io zipfile = ZipFile.Reader(io) @info "extracting..." - return extract_csv(zipfile, "testdataforjulia_bothcase.csv") + return extract_csv( + zipfile, + "testdataforjulia_bothcase.csv"; + missingstring=["NA"], + downcast=true, + types=Dict( + :case => Bool, + :individual_local_identifier => String15, + ) + ) end - transform!(data, :individual_local_identifier => ByRow(string); renamecols=false), Arrow.write(path, data) return data end @@ -48,6 +56,33 @@ using MixedModels using Statistics data = get_data() + +# check for complete separation of response within levels of columns used as predictors + +println( + unstack( + combine(groupby(data, [:Analysisclass, :case]), nrow => :n), + :case, + :n + ), +) + +println( + unstack( + combine(groupby(data, [:individual_local_identifier, :case]), nrow => :n), + :case, + :n, + ), +) + +println( + unstack( + combine(groupby(data, [:cropyear, :case]), nrow => :n), + :case, + :n, + ), +) + m0form = @formula(case ~ 0 + Analysisclass + (1|cropyear/individual_local_identifier)) # fails