anniejw6/modmarg

Change the way we handle weights

Closed this issue · 1 comments

data(margex)
margex$distance[c(1,3,5)] <- NA
margex$age[c(10, 24, 390)] <- NA
margex$y[c(12, 220)] <- NA

This + how clean_glm_data handles weights is a problem when you have missing values but don't want to specify weights, because mod$prior.weights is already subset to complete cases. E.g.

mm <- glm(y ~ as.factor(treatment) + age, data = margex, family = 'gaussian',
          weights = distance)
z1 <- modmarg::marg(mod = mm, var_interest = 'treatment', type = 'levels')[[1]]
Error in modmarg::marg(mod = mm, var_interest = "treatment", type = "levels") : 
  `weights` and `data` must be the same length.

What about something like this:

  • weights defaults to NULL
    *If NULL, defaults to mod$prior.weights
  • Must be equal to length of original data - maybe with new error message.

Resolved in #118