You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a R dependency is missing, the estimator return None with a warning. It hence badly interacts with get_estimation error pattern
In [8]: from med_bench.get_simulated_data import simulate_data
In [12]: from numpy.random import default_rng
In [13]: data = simulate_data(
...: n=SAMPLE_SIZE,
...: rg=default_rng(45),
...: mis_spec_m=False,
...: mis_spec_y=False,
...: dim_x=1,
...: dim_m=1,
...: seed=9,
...: type_m="binary",
...: sigma_y=0.5,
...: sigma_m=0.5,
...: beta_t_factor=0.5,
...: beta_m_factor=0.5,
...: )
...:
...: x, t, m, y = data[0], data[1], data[2], data[3]
In [15]: from med_bench.get_estimation import get_estimation
In [16]: get_estimation(x, t.ravel(), m, y.ravel(), 'simulation_based', 0)
R[write to console]: Error: package or namespace load failed for ‘mediation’ in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]):
namespace ‘htmltools’ 0.5.6.1 is being loaded, but >= 0.5.7 is required
R[write to console]: Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) :
namespace ‘htmltools’ 0.5.6.1 is being loaded, but >= 0.5.7 is required
/data/parietal/store/work/jabecass/med_bench/src/med_bench/utils/utils.py:58: UserWarning: The 'mediation' R package is not installed. Please install it using R by running:
import rpy2.robjects.packages as rpackages
utils = rpackages.importr('utils')
utils.chooseCRANmirror(ind=33)
utils.install_packages('mediation')
warnings.warn(
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
Cell In[16], line 1
----> 1 get_estimation(x, t.ravel(), m, y.ravel(), 'simulation_based', 0)
File /data/parietal/store/work/jabecass/med_bench/src/med_bench/get_estimation.py:676, in get_estimation(x, t, m, y, estimator, config)
674 if config not in (0, 1, 2):
675 raise ValueError("Estimator only supports 1D binary mediator.")
--> 676 raise ValueError("Estimator does not support 1D binary mediator.")
677 return effects
ValueError: Estimator does not support 1D binary mediator.
Not sure what the right fix is:
raise an error instead of a warning when R package is missing
refactor get_estimation (which is needed anyway, to get rid of a lengthy pattern + the legacy "config" parameter)
yes, we can know it, and so far it is used in the new PR for a warning. I have 2 questions
do we want a warning and that the function returns None, or do we want to raise an error and interrupt the execution completely. I am not sure which is best
if we keep the warning, we have to adjust the behavior of the get_estimation function because this function raises an error when an estimator return None, but not the right error in that case.
When a R dependency is missing, the estimator return None with a warning. It hence badly interacts with get_estimation error pattern
Not sure what the right fix is:
wdyt @bthirion @houssamzenati and @brash6 @zbakhm (in terms of architecture and user interface)?
The text was updated successfully, but these errors were encountered: