got the neg binom to work

This commit is contained in:
Matthew Gaughan 2024-05-09 18:40:33 -05:00
parent 9dc810bedf
commit 92dcf50bd6
3 changed files with 7 additions and 2 deletions

BIN
R/0509_gmodel.rda Normal file

Binary file not shown.

BIN
R/0509caterpillar.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 103 KiB

View File

@ -82,8 +82,12 @@ mean (all_actions_data$log1p_count) # 0.6426873
#all_gmodel <- glmer.nb(count ~ D * I(week_offset)+ scaled_project_age + (D * I(week_offset) | upstream_vcs_link),
# control=glmerControl(optimizer="bobyqa",
# optCtrl=list(maxfun=2e5)), data=all_actions_data)
all_gmodel <- glmer.nb(count ~ D * I(week_offset)+ scaled_project_age + (D | upstream_vcs_link), data=all_actions_data)
all_gmodel <- glmer.nb(count ~ D * I(week_offset)+ scaled_project_age + (D * I(week_offset) | upstream_vcs_link), data=all_actions_data, nAGQ=0, control=glmerControl(optimizer="bobyqa",
optCtrl=list(maxfun=1e5)))
summary(all_gmodel)
saveRDS(all_gmodel, "0509_gmodel.rda")
#readRDS(path)
library(broom.mixed)
test_condvals <- broom.mixed::tidy(all_gmodel, effects = "ran_vals", conf.int = TRUE)
test_glmer_ranef_D <- test_condvals [which(test_condvals $term == "D"),]
has_zero <- function(estimate, low, high){
@ -92,10 +96,11 @@ has_zero <- function(estimate, low, high){
test_glmer_ranef_D <- test_glmer_ranef_D |>
mutate(ranef_grouping = has_zero(estimate, conf.low, conf.high)) |>
mutate(rank = rank(estimate))
test_glmer_ranef_D |>
g <- test_glmer_ranef_D |>
ggplot(aes(x=rank, y=estimate, col = as.factor(ranef_grouping))) +
geom_linerange(aes(ymin= conf.low, ymax= conf.high)) +
theme_bw()
ggsave("0509caterpillar.png", g)
#below this groups the ranefs
"""
has_zero <- function(condval, condsd){