Compute Covariate Multiplier Statistics¶
Mulcov Statistics Script¶
(Note: mulcov is a short name for “covariate multiplier”)
Once we’ve done a sample on a database to get posteriors, we can compute statistics of the covariate multipliers.
This is useful because we often like to use covariate multiplier statistics at one level of the cascade as a prior for the covariate multiplier estimation in another level of the cascade.
-
cascade_at.executor.mulcov_statistics.
get_mulcovs
(dbs, covs, table='fit_var')[source]¶ Get mulcov values from all of the dbs, with all of the common covariates.
Parameters dbs
A list of dismod i/o objects
- covs
A list of covariate names
- table
Name of the table to pull from (can be fit_var or sample)
- Return type
DataFrame
-
cascade_at.executor.mulcov_statistics.
compute_statistics
(df, mean=True, std=True, quantile=None)[source]¶ Compute statistics on a data frame with covariate multipliers. :param df: pd.DataFrame :param mean: bool :param std: bool :param quantile: optional list
Returns: dictionary with requested statistics
-
cascade_at.executor.mulcov_statistics.
mulcov_statistics
(model_version_id, locations, sexes, outfile_name, sample=True, mean=True, std=True, quantile=None)[source]¶ Compute statistics for the covariate multipliers on a dismod database, and save them to a file.
- Parameters
model_version_id (
int
) – The model version IDlocations (
List
[int
]) – A list of locations that, when used in combination with sexes, point to the databases to pull covariate multiplier estimates fromsexes (
List
[int
]) – A list of sexes that, when used in combination with locations, point to the databases to pull covariate multiplier estimates fromoutfile_name (
str
) – A filepath specifying where to save the covariate multiplier statistics.sample (
bool
) – Whether or not the results are stored in the sample table or the fit_var table.mean (
bool
) – Whether or not to compute the meanstd (
bool
) – Whether or not to compute the standard deviationquantile (
Optional
[List
[float
]]) – An optional list of quantiles to compute
- Return type
None
Mulcov Statistics Cascade Operation¶
-
class
cascade_at.cascade.cascade_operations.
MulcovStatistics
(model_version_id, locations, sexes, sample, mean, std, quantile, outfile_name=None, **kwargs)[source]¶ Bases:
cascade_at.cascade.cascade_operations._CascadeOperation
The base class for a cascade operation.
- Parameters
upstream_commands – A list of commands that are upstream to this operation. This means that it will be run before this operation.
executor_parameters – Optional dictionary of execution parameters that updates the execution parameters
DEFAULT_EXECUTOR_PARAMETERS