gemmr.sample_size.linear_model.do_fit_lm¶
-
gemmr.sample_size.linear_model.
do_fit_lm
(ds, n_reqs, include_pc_var_decay_constants=True, include_latent_explained_vars=True, include_pdiff=False, verbose=False)¶ Fits a linear model to outcome data.
First, prepares outcome data, i.e. selects predictor variables and stacks it along dimensions px, r, Sigma_id. Second, fits linear model.
Parameters: - ds (xr.Dataset) – outcome dataset
- n_reqs (xr.DataArray) – required sample sizes
- include_pc_var_decay_constants (bool) – whether to include a predictor for the principal component spectrum decay constant in the linear model
- include_latent_explained_vars (bool) – whether to include a predictor for the latent explained variance in the linear model
- include_pdiff (bool) – whether to include predictor for \(|p_X - p_Y|\) in the linear model
- verbose (bool) – if
True
prints deltaAIC
Returns: - lm (sklearn.LinearRegression instance) – fitted model
- X ((n_synth_datasets, n_predictors)) – predictor data matrix
- y ((n_synth_datasets,)) – dependent variable
- coef_names (list) – labels for included linear model coefficients (first one is “const”)