Inheritance diagram for nipy.algorithms.statistics.models.model:
Bases: object
Results from an F contrast of coefficients in a parametric model.
The class does nothing, it is a container for the results from F contrasts, and returns the F-statistics when np.asarray is called.
Bases: nipy.algorithms.statistics.models.model.Model
Methods
fit() | Fit a model to data. |
information(theta[, nuisance]) | Fisher information matrix |
initialize() | Initialize (possibly re-initialize) a Model instance. |
logL(theta, Y[, nuisance]) | Log-likelihood of model. |
predict([design]) | After a model has been fit, results are (assumed to be) stored |
score(theta, Y[, nuisance]) | Gradient of logL with respect to theta. |
Fit a model to data.
Fisher information matrix
The inverse of the expected value of - d^2 logL / dtheta^2.
Initialize (possibly re-initialize) a Model instance.
For instance, the design matrix of a linear model may change and some things must be recomputed.
Log-likelihood of model.
After a model has been fit, results are (assumed to be) stored in self.results, which itself should have a predict method.
Gradient of logL with respect to theta.
This is the score function of the model
Bases: object
Class to contain results from likelihood models
Methods
AIC() | Akaike Information Criterion |
BIC() | Schwarz’s Bayesian Information Criterion |
Fcontrast(matrix[, dispersion, invcov]) | Compute an Fcontrast for a contrast matrix matrix. |
Tcontrast(matrix[, store, dispersion]) | Compute a Tcontrast for a row vector matrix |
conf_int([alpha, cols, dispersion]) | The confidence interval of the specified theta estimates. |
logL() | The maximized log-likelihood |
t([column]) | Return the (Wald) t-statistic for a given parameter estimate. |
vcov([matrix, column, dispersion, other]) | Variance/covariance matrix of linear contrast |
Set up results structure
Parameters: | theta : ndarray
Y : ndarray
model : LikelihoodModel instance
cov : None or ndarray, optional
dispersion : scalar, optional
nuisance : None of ndarray
rank : None or scalar
|
---|
Notes
The covariance of thetas is given by:
dispersion * cov
For (some subset of models) dispersion will typically be the mean square error from the estimated model (sigma^2)
Akaike Information Criterion
Schwarz’s Bayesian Information Criterion
Compute an Fcontrast for a contrast matrix matrix.
Here, matrix M is assumed to be non-singular. More precisely
M pX pX' M'
is assumed invertible. Here, pX is the generalized inverse of the design matrix of the model. There can be problems in non-OLS models where the rank of the covariance of the noise is not full.
See the contrast module to see how to specify contrasts. In particular, the matrices from these contrasts will always be non-singular in the sense above.
Parameters: | matrix : 1D array-like
dispersion : None or float, optional
invcov : None or array, optional
|
---|---|
Returns: | f_res : FContrastResults instance
|
Notes
For F contrasts, we now specify an effect and covariance
Compute a Tcontrast for a row vector matrix
To get the t-statistic for a single column, use the ‘t’ method.
Parameters: | matrix : 1D array-like
store : sequence, optional
dispersion : None or float, optional |
---|---|
Returns: | res : TContrastResults object |
The confidence interval of the specified theta estimates.
Parameters: | alpha : float, optional
cols : tuple, optional
dispersion : None or scalar
|
---|---|
Returns: | cis : ndarray
|
Notes
Confidence intervals are two-tailed. TODO: tails : string, optional
tails can be “two”, “upper”, or “lower”
Examples
>>> from numpy.random import standard_normal as stan
>>> from nipy.algorithms.statistics.models.regression import OLSModel
>>> x = np.hstack((stan((30,1)),stan((30,1)),stan((30,1))))
>>> beta=np.array([3.25, 1.5, 7.0])
>>> y = np.dot(x,beta) + stan((30))
>>> model = OLSModel(x).fit(y)
>>> confidence_intervals = model.conf_int(cols=(1,2))
The maximized log-likelihood
Return the (Wald) t-statistic for a given parameter estimate.
Use Tcontrast for more complicated (Wald) t-statistics.
Variance/covariance matrix of linear contrast
Parameters: | matrix: (dim, self.theta.shape[0]) array, optional :
column: int, optional :
dispersion: float or (n_voxels,) array, optional :
other: (dim, self.theta.shape[0]) array, optional :
|
---|---|
Returns: | cov: (dim, dim) or (n_voxels, dim, dim) array :
Returns the variance/covariance matrix of a linear contrast of the : estimates of theta, multiplied by `dispersion` which will often be an : estimate of `dispersion`, like, sigma^2. : The covariance of interest is either specified as a (set of) column(s) : or a matrix. : |
Bases: object
A (predictive) statistical model.
The class Model itself does nothing but lays out the methods expected of any subclass.
Methods
fit() | Fit a model to data. |
initialize() | Initialize (possibly re-initialize) a Model instance. |
predict([design]) | After a model has been fit, results are (assumed to be) stored |
Fit a model to data.
Initialize (possibly re-initialize) a Model instance.
For instance, the design matrix of a linear model may change and some things must be recomputed.
After a model has been fit, results are (assumed to be) stored in self.results, which itself should have a predict method.
Bases: object
Results from a t contrast of coefficients in a parametric model.
The class does nothing, it is a container for the results from T contrasts, and returns the T-statistics when np.asarray is called.