reggie icon indicating copy to clipboard operation
reggie copied to clipboard

Error in reg(ChickWeight, weight ~ Time + Diet, vcov_cluster = ~ Chick, vcov_type = "boot")

Open b-rodrigues opened this issue 8 years ago • 1 comments

As you mentioned in the README, this regression does not work and this is the error message:

object of type 'closure' is not subsettable

I believe it's probably from line 52:

data = data[sample(seq_len(nrow(data)), nrow(data), TRUE), ], ...))

data is a function to load example datasets, and I think that this is where it goes wrong (you're trying to subset a function). I tried replacing data with dataset and when running the unit tests this is what I get:

==> devtools::test()

Loading reggie
Loading required package: testthat
Testing reggie
✔ | OK F W S | Context
✖ |  0 1     | Correct Data Structures Returned [3.5 s]
─────────────────────────────────────────────────────────────────────────────────────────────────────────
tests.R:19: error: (unknown)
object 'dataset' not found
1: reg(ChickWeight, weight ~ Time + Diet, vcov_cluster = ~Chick, vcov_type = "boot") at /home/bro/Documents/reggie/tests/testthat/tests.R:19
2: sandwich::vcovBS(x = mod, cluster = cluster_vec, R = boot_iterations) at /home/bro/Documents/reggie/R/reg.R:43
3: vcovBS.default(x = mod, cluster = cluster_vec, R = boot_iterations)
4: eval(up, envir = env, enclos = parent.frame())
5: eval(up, envir = env, enclos = parent.frame())
6: stats::glm(formula = formula, data = dataset, subset = .vcovBSenv$.vcovBSsubset)
7: eval(mf, parent.frame())
8: eval(mf, parent.frame())
9: stats::model.frame(formula = formula, data = dataset, subset = .vcovBSenv$.vcovBSsubset, drop.unused.levels = TRUE)
10: model.frame.default(formula = formula, data = dataset, subset = .vcovBSenv$.vcovBSsubset, drop.unused.levels = TRUE)
11: is.data.frame(data)

I don't know if this helps, but thought I'd mention.

b-rodrigues avatar Jan 23 '18 16:01 b-rodrigues

Thanks. I think it might be an issue in how arguments are evaluated by {sandwich}. Will have to investigate more.

leeper avatar Jan 23 '18 16:01 leeper