hapsburg.PackagesSupport.fit_ne =============================== .. py:module:: hapsburg.PackagesSupport.fit_ne .. autoapi-nested-parse:: Class the fits Ne with a MLE framework. Standard error either from bootstrap over individuals, or from likelihood curve (kind of assumping ROH are independent, which is not fully correct) @Author: Harald Ringbauer, 2020 Classes ------- .. autoapisummary:: hapsburg.PackagesSupport.fit_ne.MLE_ROH_Ne Functions --------- .. autoapisummary:: hapsburg.PackagesSupport.fit_ne.ind_roh_from_pdf hapsburg.PackagesSupport.fit_ne.inds_roh_from_pdf hapsburg.PackagesSupport.fit_ne.load_roh_vec hapsburg.PackagesSupport.fit_ne.get_default_res Module Contents --------------- .. py:class:: MLE_ROH_Ne(endog=[], exog=[], start_params=[1000], min_len=4, max_len=20.0, error_model=False, output=False, chr_lgts=[], **kwds) Bases: :py:obj:`statsmodels.base.model.GenericLikelihoodModel` Class for MLE estimation of block sharing between populations with modeled error Bins into length blocks and models block-sharing between populations as indep. Poisson Operates in cM unit space (not Morgan!) .. py:attribute:: bin_width :value: 0.1 .. py:attribute:: mid_bins :value: [] .. py:attribute:: chr_lgts :value: [] .. py:attribute:: fp_rate :value: [] .. py:attribute:: theoretical_shr :value: [] .. py:attribute:: trans_mat .. py:attribute:: full_shr_pr :value: [] .. py:attribute:: density_fun :value: 0 .. py:attribute:: start_params :value: [] .. py:attribute:: error_model :value: True .. py:attribute:: estimates :value: [] .. py:attribute:: summary :value: 0 .. py:attribute:: output :value: True .. py:method:: initialize_ll_model(**kwds) Function to initialize LL model .. py:method:: set_params(recalculate_bins=False, **kwargs) Set the Parameters. Takes keyworded arguments .. py:method:: fit(start_params=None, maxiter=10000, maxfun=5000, **kwds) Fit Parameters via fit method of statsmodels .. py:method:: fit_ll_profile(ns=[], level=1.92, num=1000) Fit Parameters via likelihood profile. Only works for 1D search. Return ML, lower, upper CI values ns: Array of 2Ne values to test. level: loglikelihood difference to use for CI values. .. py:method:: loglikeobs(params) Return vector of log likelihoods for every observation. (here pairs of pops) .. py:method:: ll_individual(roh, params) Log likelihood function for every raw of data (sharing between countries). Return log likelihood. .. py:method:: create_bins() Creates the bins according to parameters in Class. Also set the false positive rate .. py:method:: calculate_thr_shr(params) Calculates the expected Bessel-Decay per bin .. py:method:: calculate_trans_mat() Calculate the transition matrix from true estimated to observed values for block sharing. .. py:method:: calculate_full_bin_prob() Calculate the full probablities per bin .. py:method:: get_bl_shr_interval(interval, r, params=[]) Return the estimated block-sharing under the model in interval given distance r. For this use all the bins intersecting the interval and average. Assumes r is array and return array .. py:method:: print_block_nr() Calculate and print the Nr of analyzed Blocks of right Length. .. py:method:: ci_li(ns=[], level=1.92, update=True) Get confidence Intervall based on likelihood ration test. Return lower, upper Ne supported by ns: N values to test. level: loglikelihood difference to use. update: Whether to update Confidence Intervals in the fit .. py:method:: block_shr_density(l, params) Calculate and print the Nr of analyzed Blocks of right Length. .. py:method:: get_summ_as_df(summary) Transforms statsmodels summary to pandas dataframe. If no summary given use the last saved one Return that dataframe .. py:function:: ind_roh_from_pdf(ne=500, bin_range=[0.04, 0.5], nbins=100000, output=False) Create ROH for single individual. Everything measured in Morgan. Return array of ROH lengths, in Morgan .. py:function:: inds_roh_from_pdf(n_ind=5, ne=500, bin_range=[0.04, 0.5], nbins=100000, output=False, cm=True) Create ROH for single individual. Everything measured in Morgan. Return array of ROH lengths, in Morgan. cm: If true, output in centimorgan .. py:function:: load_roh_vec(iids=[], base_path='./output/roh/', suffix='_roh_full.csv') Load and return ROH length vector .. py:function:: get_default_res() REturn default line of results dataframe. Used for unfittable scenarios