Skip to content

non-observed categories in brandom #71

Description

@carlganz

Hello,

Apologies for all the issues I've raised recently. My coauthor and I have found a lot of value in mboost so we have been using it a lot lately.

From the docs:

For a categorical covariate with non-observed categories bols(x) and brandom(x) both assign a zero effect to these categories. However, the non-observed categories must be listed in levels(x). Thus, predictions are possible for new observations if they correspond to this category.

This behavior is ideal, however I don't believe it is working, but it is possible I am using levels(x) incorrectly.

library(mboost)

myData <- data.frame(
  ZIP  = factor(c("90046","91423", "90064"),
                # include non-observed categoreies in levels
                levels = c("90046","91423", "90064","95432")),
  uninsured = factor(c(0,1,1))
)


model <- mboost(
  uninsured ~ brandom(ZIP, df = 2), data = myData,
  family = Binomial(), control = 
    boost_control(mstop = 1000, nu = 0.01, trace=TRUE)
)
# warning about dropping unobserved levels


newData <- data.frame(
  ZIP = factor(c("90046","95432"), 
               # use same levels in new data
               levels = c("90046","91423", "90064","95432"))
)

predict(model, newData)
# errors

Thank you for your help and the wonderful package.

Regards

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions