mrtool.cov_selection package

Cov Finder

class CovFinder(data, covs, pre_selected_covs=None, normalized_covs=True, num_samples=1000, laplace_threshold=1e-05, power_range=(-8, 8), power_step_size=0.5, inlier_pct=1.0, alpha=0.05, beta_gprior_std=1.0, bias_zero=False, use_re=None)[source]

Bases: object

Class in charge of the covariate selection.

create_model(covs, prior_type='Laplace', laplace_std=None)[source]

Create Gaussian or Laplace model.

Parameters:
  • covs (List[str]) – A list of covariates need to be included in the model.
  • prior_type (str) – Indicate if use Gaussian or Laplace model.
  • laplace_std (float) – Standard deviation of the Laplace prior. Default to None.
Returns:

Created model object.

Return type:

MRBRT

fit_gaussian_model(covs)[source]

Fit Gaussian model.

Parameters:covs (List[str]) – A list of covariates need to be included in the model.
Returns:the fitted model object.
Return type:MRBRT
fit_laplace_model(covs, laplace_std)[source]

Fit Laplace model.

Parameters:
  • covs (List[str]) – A list of covariates need to be included in the model.
  • laplace_std (float) – The Laplace prior std.
Returns:

the fitted model object.

Return type:

MRBRT

fit_pre_selected_covs()[source]

Fit the pre-selected covariates.

static is_significance(var_samples, var_type='beta', alpha=0.05)[source]
Return type:ndarray
loose_gamma_uprior = array([1., 1.])
select_covs(verbose=False)[source]
select_covs_by_laplace(laplace_std, verbose=False)[source]
summary_gaussian_model(gaussian_model)[source]

Summary the gaussian model. Return the mean standard deviation and the significance indicator of beta.

Parameters:gaussian_model (MRBRT) – Gaussian model object.
Returns:Mean, standard deviation and indicator of the significance of beta solution.
Return type:Tuple[np.ndarray, np.ndarray, np.ndarray]
update_beta_gprior(covs, mean, std)[source]

Update the beta Gaussian prior.

Parameters:
  • covs (List[str]) – Name of the covariates.
  • mean (np.ndarray) – Mean of the priors.
  • std (np.ndarray) – Standard deviation of the priors.
zero_gamma_uprior = array([0., 0.])