markvanderloo / simputation

Making imputation easy
GNU General Public License v3.0
91 stars 11 forks source link

error with using weight variable #35

Open sfallahpour opened 10 months ago

sfallahpour commented 10 months ago

when i try the following command

imp_simpuatation<-impute_rhd(
  data,
  GI~age+sex,
  pool = "univariate",
  prob = data$SamplingWeight
)

i get the following error:

Error in impute_rhd(data, earnings ~ AG + sex, pool = "univariate", prob = data$SamplingWeight) : 
  length(prob) != nrow(dat) is not TRUE

I used a debugger function and i think there is a bug in the package which i believe is here: image

I believe the highlighted line should be stopifnot(length(prob) == nrow(dat))

sfallahpour commented 10 months ago

@markvanderloo please see my suggestion above to fix the bug with impute_rhd function

LukasWallrich commented 9 months ago

On this note, could it be documented that prob is an optional parameter? Currently, it looks required, which made me get stuck with this issue until I noticed that I don't need to specify weights.