1

I have a syvglm code that would work in R3.6.3, but not R4.0.2 (which gives the error messages of:

for svylgm:

Error: Must subset elements with a valid subscript vector. x Subscript has the wrong type omit. i It must be logical, numeric, or character. Backtrace:

  1. survey::svyglm(...)
  2. survey:::svyglm.survey.design(...)
  3. survey:::[.survey.design2(design, -nas, )
  4. base::[.data.frame(x$variables, i, ..1, drop = FALSE)
  5. vctrs:::[.vctrs_vctr(xj, i)
  6. vctrs:::vec_index(x, i, ...)
  7. vctrs::vec_slice(x, i)

For interactions package:

Error: <labelled> - is not permitted Backtrace:

  1. interactions::probe_interaction(...)
  2. interactions::sim_slopes(...)
  3. interactions:::center_ss(...)
  4. interactions:::center_ss_survey(...)
  5. jtools::gscale(vars = ndfvars, data = design, center.only = TRUE) ...
  6. vctrs:::-.vctrs_vctr(left, right)
  7. haven:::vec_arith.haven_labelled.default("-", e1, e2)
  8. vctrs::stop_incompatible_op(op, x, y)
  9. vctrs:::stop_incompatible(...)
  10. vctrs:::stop_vctrs(...)

My code is:

 design <-
  svydesign(

    id = ~I_i ,
    data = sm ,
    weights = ~w ,
  )

fit <- svyglm(sc ~ sex + school +sex*school, design)

summary(fit)

probe_interaction(fit, pred = school, modx = sex)

I wish to continue with R4.0.2 as downgrading R create a lot of problems with other R packages. The probe_Interaction part did not work on older version of R (PC computer) either. Any clue what went wrong?

Data:

structure(list(I_i = structure(c(-54, 1000987, 1000166), label = "ID institution", format.spss = "F39.0", display_width = 39L, labels = c(Filtered = -99, Don't know = -98, Refused = -97, Not in list = -96, Implausible value = -95, Not reached = -94, Does not apply = -93, Question erroneously not asked = -92, Survey aborted = -91, Unspecific missing = -90, Not participated = -56, Not determinable = -55, Missing by design = -54, Anonymized = -53, Implausible value removed = -52, No estimate in check module = -51 ), class = c("haven_labelled", "vctrs_vctr", "double")), w = c(0.197917401820921, 0.186422150045312, 0.275986837527898),sc = c(NA, 7.66666666666667, 8.66666666666667 ), sex = structure(c(1, 1, 0), label = "Gender", format.spss = "F3.0", display_width = 9L, labels = c(Implausible value = -95, Unspecific missing = -90, Missing by design = -54, <U+0085> male? = 1, <U+0085> female? = 2), class = c("haven_labelled", "vctrs_vctr", "double")), school = c(NA, 1L, 1L)), row.names = c(NA, 3L), class = "data.frame")
Syl
  • 29
  • 4
  • Don't know because I get `object 'sm' not found` with your code. Possibly you are hit by R's new `stringsAsFactors = FALSE` default? – Roland Jul 30 '20 at 10:54
  • So, maybe try `options(stringsAsFactors = TRUE)` before running your code. – Roland Jul 30 '20 at 11:04
  • Hey Roland, thanks a lot for your input. I am not sure if I am understanding what you meant correctly, sm is just the name of my data set that I am using to run the regression :) – Syl Jul 30 '20 at 11:23
  • I'm fully aware of that. But without this data set I can't reproduce and investigate the issue. – Roland Jul 30 '20 at 11:25
  • I see. It is difficult, and I know how it makes my question very pointless without the data, but I cannot provide the data due to agreement issue...I am sorry about that...Is there another way of getting around it? – Syl Jul 30 '20 at 11:28
  • Please read this [FAQ](https://stackoverflow.com/a/5963610/1412059). – Roland Jul 30 '20 at 11:30
  • Thanks heaps! This is what I got: structure(list(sc = c(NA, 7.66666666666667, 8.66666666666667 ), sex = structure(c(1, 1, 0), label = "Gender", format.spss = "F3.0", display_width = 9L, labels = c(`Implausible value` = -95, `Unspecific missing` = -90, `Missing by design` = -54, ` male?` = 1, ` female?` = 2), class = c("haven_labelled", "vctrs_vctr", "double")), school = c(NA, 1L, 1L)), row.names = c(NA, 3L), class = "data.frame") Sorry if that is not what is required.. I am very new to R! – Syl Jul 30 '20 at 11:44
  • `object 'I_i' not found` – Roland Jul 30 '20 at 11:50
  • I_i = structure(c(-54, 1000987, 1000166), label = "ID institution", format.spss = "F39.0", display_width = 39L, labels = c(Filtered = -99, `Don't know` = -98, Refused = -97, `Not in list` = -96, `Implausible value` = -95, `Not reached` = -94, `Does not apply` = -93, `Question erroneously not asked` = -92, `Survey aborted` = -91, `Unspecific missing` = -90, `Not participated` = -56, `Not determinable` = -55, `Missing by design` = -54, Anonymized = -53, `Implausible value removed` = -52, `No estimate in check module` = -51 ), class = c("haven_labelled", "vctrs_vctr", "double")) – Syl Jul 30 '20 at 11:55
  • w = c(0.197917401820921, 0.186422150045312, 0.275986837527898) – Syl Jul 30 '20 at 11:55
  • @Syl; can you add these details to your question please --> if you click [**edit**](https://stackoverflow.com/posts/63171462/edit) under your question – user20650 Jul 30 '20 at 11:57
  • Your code does not produce an error with supplied data. – Roland Jul 30 '20 at 12:15
  • Tht is stranged... do you by any chance know what might have gone wrong? – Syl Jul 30 '20 at 12:26

0 Answers0