pistacliffcho / icenReg_devel

Code for icenReg plus testData
4 stars 0 forks source link

`ic_np` does not like raw matrices of data #11

Open hhau opened 3 years ago

hhau commented 3 years ago

Hi! Thanks for the package!

I am a bit confused about how to use ic_np. I only have one group, so https://github.com/pistacliffcho/icenReg_devel/blob/master/Code/icenReg/R/ic_np.R#L8-L9 makes it seem like I do not need the formula argument:

library(icenReg)
#> Loading required package: survival
#> Loading required package: Rcpp
#> Loading required package: coda

l <- rbinom(n = 250, size = 1, prob = 0.5)
u <- rpois(n = 250, lambda = 10) + 1

# error
icenReg::ic_np(data = cbind(l, u))
#> Error in rep(1, nrow(data)): invalid 'times' argument

# get next error by manually specifying weights:
icenReg::ic_np(data = cbind(l, u), weights = rep(1, times = length(l)))
#> Error in array(x, c(length(x), 1L), if (!is.null(names(x))) list(names(x), : 'data' must be of a vector type, was 'NULL'

but it looks like you intend for the function to be called as icenReg::ic_np(cbind(l, r)), i.e. excluding the data argument when there are no groups. It might be possible to throw a more informative error if ic_np is called without a formula argument yet with a data argument? Or at least tweak the docs / include the fixed version of the above as an example.

Thanks again!