alexpkeil1 / qgcomp

QGcomp (quantile g-computation): estimating the effects of exposure mixtures. Works for continuous, binary, and right-censored survival outcomes. Flexible, unconstrained, fast and guided by modern causal inference principles
27 stars 6 forks source link

qgcomp.boot error: Must use a vector in `[`, not an object of class matrix. #1

Closed alexpkeil1 closed 5 years ago

alexpkeil1 commented 5 years ago

This error is raised when the data given to qgcomp.boot is a tibble. Here is a minimal working example:

library(dplyr)
library(qgcomp)

N = 100
dat <- tibble(i = 1:N) %>%
  mutate(
    u = runif(N)*0.75 + .125,
    x1 = rnorm(N, u),
    x2 = rnorm(N, u),
    y = rnorm(N) + x1 - x2*x1
  )

# error related

qgcomp.boot(y ~ x1 + x2, expnms = c("x1", "x2"), data=dat)
#Error: Must use a vector in `[`, not an object of class matrix.
#Call `rlang::last_error()` to see a backtrace

Until this is fixed, a simple workaround is to convert the data to a data.frame, as in here:


qgcomp.boot(y ~ x1 + x2, expnms = c("x1", "x2"), data=data.frame(dat))
alexpkeil1 commented 5 years ago

fixed in v1.0.4

Until this is pushed to CRAN (release date planned for May), you can install the dev version which fixes this and improves on some graphical output.

devtools::install_github("alexpkeil1/qgcomp")