facebookexperimental / facebookexperimental/Robyn
Error using robyn_recreate() when there are NAs in a context variable (factor_vars)
- Dominant language
- Jupyter Notebook
- Stars
- 1.5k
- Forks
- 433
- PR merge metrics
- No merged PRs in 30d
Description
Hi, I'm using Robyn v3.11.1 and I've encountered an unexpected behavior when trying to recreate a model using `robyn_recreate()`.
In my dataset (_raw_data.csv_), I have a context variable called _"context_promo"_ which I include as part of the `factor_vars` parameter in `robyn_inputs()`. This variable indicates the type of promotion for each week, but in some weeks there are no promotions, so the values are NA.
**Observed behavior**:
• When running the initial model using `robyn_run()` followed by `robyn_outputs()`, everything works fine. The model runs without errors and returns several valid solutions.
• However, when I try to recreate a specific model using `robyn_recreate()`, I get the following error:
> Error in check_nas(dt_input, c(paid_media_vars, paid_media_spends, context_vars, :
> Dataset structure(list(paid_google_search_impresiones = c(85827, 62459, contains missing (NA) values. These values must be removed or fixed for Robyn to properly work.
> Missing values: context_promo (76 | 42.46%)Dataset 51795, 46710, 35099, 39496, 43559, 38302, 34290, 33168, 52034, contains missing (NA) values. These values must be removed or fixed for Robyn to properly work.
> Missing values: context_promo (76 | 42.46%)Dataset 41796, 49565, 22495, 27108, 33357, 61156, 57375, 63111, 54946, contains missing (NA) values. These values must be removed or fixed for Robyn to properly work.
> Missing values: context_promo (76 | 42.46%)Dataset 44925, 34681, 33546, 29643, 36671, 38954, 38876, 37715, 32547, contains missing (NA) values. These values must be removed or fixed for Robyn to properly work.
> Missing values: context_promo (76 | 42.46%)Dataset 33098, 33821, 32169, 31387, 32385, 32348, 30619, 34998, 39916, contains missing (NA) values. These values must be removed or fixe
Since the original model runs without issues despite having NAs in the context variable, **shouldn't `robyn_recreate()` be able to handle the same data?
Could this be a bug in the `robyn_recreate()` function?**
**What is the recommended way to handle missing values in a categorical variable (factor_var) such as "_context_promo_"?** I can’t assign the value "_no_promo_" to the "_context_promo_" variable because Robyn would internally treat it as a different type of promotion, rather than as the absence of promotion.
Thanks in advance for your help! Let me know if you need more information.
Contributor guide
Assessment
This issue has not been assessed yet.