Documentation for ‘hetlm’ module¶
Documentation for the heteroskedastic linear model class.
-
class
hetlm.model(y, X, V)[source]¶ Define a heteroskedastic linear model and calculate likelihood, gradients, and maximum likelihood estimates of parameters.
Parameters: - y :
array 1D array of phenotype observations
- X :
array Design matrix for the fixed mean effects.
- V :
array Design matrix for the fixed variance effects.
Returns: - model :
hetlm.model heteroskedastic linear model class with input data
Methods
alpha_mle(beta)Compute the maximum likelihood estimate of the fixed mean effect parameters, given particular fixed variance effect parameters and variance of random effects alpha_ols()Compute the ordinary least squares (OLS) estimate of the fixed mean effect parameters approx_beta_mle()Analytical approximation to the maximum likelihood estimate of the fixed variance effects grad_beta(beta, alpha)Compute the gradient with respect to the fixed variance effects of -2*L/n-log(2*pi), where L is the log-likelihood, the function that is minimized to find the MLE likelihood(beta, alpha[, negative])Compute the log of the likelihood, the likelihood at the maximum likelihood for the fixed mean effects optimize_model()Find the maximum likelihood estimate (MLE) of the parameters and their sampling distribution. alpha_cov beta_cov -
alpha_mle(beta)[source]¶ Compute the maximum likelihood estimate of the fixed mean effect parameters, given particular fixed variance effect parameters and variance of random effects
Parameters: - beta :
array value of fixed variance effects
Returns: - alpha :
array maximum likelihood estimate of alpha given beta
- beta :
-
alpha_ols()[source]¶ Compute the ordinary least squares (OLS) estimate of the fixed mean effect parameters
Returns: - alpha :
array ordinary least-squares estimate of alpha
- alpha :
-
approx_beta_mle()[source]¶ Analytical approximation to the maximum likelihood estimate of the fixed variance effects
Returns: - beta :
array approximate MLE of beta
- beta :
-
grad_beta(beta, alpha)[source]¶ Compute the gradient with respect to the fixed variance effects of -2*L/n-log(2*pi), where L is the log-likelihood, the function that is minimized to find the MLE
Parameters: - beta :
array value of fixed variance effects
- alpha :
array value of fixed mean effects to gradient for
Returns: - grad_beta :
array
- beta :
-
likelihood(beta, alpha, negative=False)[source]¶ Compute the log of the likelihood, the likelihood at the maximum likelihood for the fixed mean effects
Parameters: - alpha :
array value of fixed mean effects to compute likelihood for
- beta :
array value of fixed variance effects to compute likelihood for
- negative :
bool compute -2*L/n-log(2*pi), where L is the log-likelihood, the function that is minimized to find the MLE. Default is False.
Returns: - L :
float log-likelihood of data given parameters.
- alpha :
-
optimize_model()[source]¶ Find the maximum likelihood estimate (MLE) of the parameters and their sampling distribution.
Returns: - optim :
dict keys: MLEs (‘alpha’, fixed mean effects; ‘beta’, fixed variance effects), their standard errors (‘alpha_se’, ‘beta_se’), covariance matrix for sampling distribution of parameter vectors (‘beta_cov’ and ‘alpha_cov’), maximum likelihood (‘likelihood’), whether optimisation was successful (‘success’),
- optim :
- y :