retowuest / autoMrP

autoMrP
25 stars 3 forks source link

Error in `dplyr::mutate()`: ℹ In argument: `svm = ...[]`. #14

Open georgytarasenko opened 10 months ago

georgytarasenko commented 10 months ago

Hi! I have been excited to start exploring your package, however, unfortunately, my experience with working with it was a bit controversial. After some hours I could fix some implicit data requirements, but I still had some troubles with running auto_MrP. Every time I run the full model I receive this error (however, when using only pcm = TRUE the error is not shown) :

Error in `dplyr::mutate()`:
ℹ In argument: `svm = ...[]`.
Caused by error in `matrix()`:
! length of 'dimnames' [2] not equal to array extent
Run `rlang::last_trace()` to see where the error occurred.
> rlang::last_trace()
<error/dplyr:::mutate_error>
Error in `dplyr::mutate()`:
ℹ In argument: `svm = ...[]`.
Caused by error in `matrix()`:
! length of 'dimnames' [2] not equal to array extent
---
Backtrace:
     ▆
  1. ├─autoMrP::auto_MrP(...)
  2. │ └─autoMrP:::run_classifiers(...)
  3. │   └─autoMrP:::post_stratification(...)
  4. │     └─... %>% ...
  5. ├─dplyr::summarize(...)
  6. ├─dplyr::group_by(., !!rlang::sym(L2.unit))
  7. ├─dplyr::mutate(...)
  8. ├─dplyr:::mutate.data.frame(...)
  9. │ └─dplyr:::mutate_cols(.data, dplyr_quosures(...), by)
 10. │   ├─base::withCallingHandlers(...)
 11. │   └─dplyr:::mutate_col(dots[[i]], data, mask, new_columns)
 12. │     └─mask$eval_all_mutate(quo)
 13. │       └─dplyr (local) eval()
 14. ├─stats::predict(...)
 15. └─e1071:::predict.svm(...)
 16.   ├─stats::napredict(...)
 17.   ├─stats:::napredict.default(...)
 18.   └─base::matrix(...)
Run rlang::last_trace(drop = FALSE) to see 3 hidden frames.

This is my model:

mrp_auro_out<- auto_MrP(y = "usa_bad", 
                   L1.x= c("educ","sex", 'urban_rural', 'age',
                           'int1', 'int2', 'int3',
                           'int4', 'int5', 'int6'
                           ), 
                   L2.x= c('latitude', 'longitude', 'gdp_pc_98',  'russians_89_share', 'popul_tot',
                           'republic','capitals', 'mms'), 
                   L2.unit = "regions_89", 
                   L2.reg = "district", 
                   bin.size= "n", 
                   survey = geo_r1_rand_AUTOMRP[c(common_covs, "district", "regions_89", "usa_bad")],
                   census = ps_c1_AUTOMRP[c(common_covs, "district", "regions_89", "n")], 
                   cores = 8)

I am just interested what this error can refer to: problem with model convergence, wrong data properties or it is just a bug? Thanks in advance!

philippbroniecki commented 9 months ago

Hi,

I think this has to do with the dataset or is a bug. Can you share a part of your data to test this?