Documentation for ‘sibreg’ module

Documentation for the sibreg model class.

class sibreg.model(y, X, labels)[source]

Define a linear model with within-class correlations.

Parameters:
y : array

1D array of phenotype observations

X : array

Design matrix for the fixed mean effects.

labels : array

1D array of sample labels

Returns:
model : sibreg.model

Methods

alpha_mle(self, tau[, sigma2, compute_cov]) Compute the MLE of alpha given variance parameters
likelihood_and_gradient(self, sigma2, tau) Compute the loss function, which is -2 times the likelihood along with its gradient
optimize_model(self, init_params) Find the parameters that minimise the loss function for a given regularisation parameter
predict(self, X) Predict new observations based on model regression coefficients
set_alpha  
alpha_mle(self, tau, sigma2=nan, compute_cov=False)[source]

Compute the MLE of alpha given variance parameters

Parameters:
sigma2 : float

variance of model residuals

tau : float

ratio of variance of model residuals to variance explained by mean differences between classes

Returns:
alpha : array

MLE of alpha

likelihood_and_gradient(self, sigma2, tau)[source]

Compute the loss function, which is -2 times the likelihood along with its gradient

Parameters:
sigma2 : float

variance of model residuals

tau : float

ratio of variance of model residuals to variance explained by mean differences between classes

Returns:
L, grad : float

loss function and gradient, divided by sample size

optimize_model(self, init_params)[source]

Find the parameters that minimise the loss function for a given regularisation parameter

Parameters:
init_param : array

initial values for residual variance (sigma^2_epsilon) followed by ratio of residual variance to within-class variance (tau)

Returns:
optim : dict

dictionary with keys: ‘success’, whether optimisation was successful (bool); ‘warnflag’, output of L-BFGS-B algorithm giving warnings; ‘sigma2’, MLE of residual variance; ‘tau’, MLE of ratio of residual variance to within-class variance; ‘likelihood’, maximum of likelihood.

predict(self, X)[source]

Predict new observations based on model regression coefficients

Parameters:
X : array

matrix of covariates to predict from

Returns:
y : array

predicted values

sibreg.simulate(n, alpha, sigma2, tau)[source]
Simulate from a linear model with correlated observations within-class. The mean for each class
is drawn from a normal distribution.
Parameters:
n : int

sample size

alpha : array

value of regression coefficeints

sigma2 : float

variance of residuals

tau : float

ratio of variance of residuals to variance of distribution of between individual means

Returns:
model : regrnd.model

linear model with repeated observations