def model_returns_t_alpha_beta(data, bmark, samples=<NUM_LIT>, progressbar=True):
data_bmark = pd.concat([data, bmark], axis=<NUM_LIT:1>).dropna()<EOL>with pm.Model() as model:<EOL><INDENT>sigma = pm.HalfCauchy(<EOL>'<STR_LIT>',<EOL>beta=<NUM_LIT:1>)<EOL>nu = pm.Exponential('<STR_LIT>', <NUM_LIT:1.> / <NUM_LIT>)<EOL>X = data_bmark.iloc[:, <NUM_LIT:1>]<EOL>y = data_bmark.iloc[:, <NUM_LIT:0>]<EOL>alpha_reg = pm.Normal('<STR_LIT>', mu=<NUM_LIT:0>, sd=<NUM_LIT>)<EOL>beta_reg = pm.Normal('<STR_LIT>', mu=<NUM_LIT:0>, sd=<NUM_LIT:1>)<EOL>mu_reg = alpha_reg + beta_reg * X<EOL>pm.StudentT('<STR_LIT>',<EOL>nu=nu + <NUM_LIT:2>,<EOL>mu=mu_reg,<EOL>sd=sigma,<EOL>observed=y)<EOL>trace = pm.sample(samples, progressbar=progressbar)<EOL><DEDENT>return model, trace<EOL>
Run Bayesian alpha-beta-model with T distributed returns.

This model estimates intercept (alpha) and slope (beta) of two
return sets. Usually, these will be algorithm returns and
benchmark returns (e.g. S&P500). The data is assumed to be T
distributed and thus is robust to outliers and takes tail events
into account.  If a pandas.DataFrame is passed as a benchmark, then
multiple linear regression is used to estimate alpha and beta.

Parameters
----------
returns : pandas.Series
    Series of simple returns of an algorithm or stock.
bmark : pandas.DataFrame
    DataFrame of benchmark returns (e.g., S&P500) or risk factors (e.g.,
    Fama-French SMB, HML, and UMD).
    If bmark has more recent returns than returns_train, these dates
    will be treated as missing values and predictions will be
    generated for them taking market correlations into account.
samples : int (optional)
    Number of posterior samples to draw.

Returns
-------
model : pymc.Model object
    PyMC3 model containing all random variables.
trace : pymc3.sampling.BaseTrace object
    A PyMC3 trace object that contains samples for each parameter
    of the posterior.