对于带有sigma.formula术语的gamlss模型,无法使用扫帚获得置信区间

时间:2017-08-15 01:04:37

标签: r tidyverse broom

我正在调用一个gamlss模型:

model <- gamlss(formula = formula("y_variable ~ image_name + random(biological_source_name) - 1"),
       sigma.formula = formula("~ biological_source_name - 1"),
       family = "NBI",
       data = na.omit(data))

但是,在尝试使用broom::confint_tidy获取置信区间时出错:

confint_tidy(model)

消息是:

Error in UseMethod("family") : 
  no applicable method for 'family' applied to an object of class "NULL"
In addition: Warning message:
In vcov.gamlss(object, robust = robust) :
  Additive terms exists in the  mu formula. 
  Standard errors for the linear terms maybe are not appropriate

但是在尝试使用broom::tidy时出现了不同的错误:

broom::tidy(model)

消息是:

Error in data.frame(..., check.names = FALSE) : 
  arguments imply differing number of rows: 0, 73

当我在没有sigma.formula项的情况下使用此模型时,我可以获得置信区间。

model_no_sigma <- gamlss(formula = formula("y_variable ~ image_name + random(biological_source_name) - 1"),
       family = "NBI",
       data = na.omit(data))
broom::tidy(model_no_sigma) # Does produce CI output

可重复的例子

    library("gamlss")

example_data <- rbind(
  data.frame(
    y = rnbinom(200, mu = 10, size = 1),
    x = "var_1"
  ),
  data.frame(
    y = rnbinom(200, mu = 20, size = 10),
    x = "var_2"
  )
)

# No estimate sigma
model_1 <- gamlss(formula = formula("y ~ x - 1"),
                data = example_data,
                family = "NBI")
broom::tidy(model_1, conf.int = TRUE)


# Include intercept term for sigma
model_2 <- gamlss(formula = formula("y ~ x - 1"),
                  sigma.formula = formula("~ x"),
                data = example_data,
                family = "NBI")
broom::tidy(model_2, conf.int = TRUE)


# Remove intercept for sigma
model_3 <- gamlss(formula = formula("y ~ x - 1"),
                  sigma.formula = formula("~ x - 1"),
                data = example_data,
                family = "NBI")
broom::tidy(model_3, conf.int = TRUE)

示例输出

Screen shot of error output

0 个答案:

没有答案