algorithms.statistics.models.nlsmodel

Module: algorithms.statistics.models.nlsmodel

Inheritance diagram for nipy.algorithms.statistics.models.nlsmodel:

digraph inheritancee18b6c9c2f { rankdir=LR; size="8.0, 12.0"; "models.model.Model" [URL="nipy.algorithms.statistics.models.model.html#nipy.algorithms.statistics.models.model.Model",fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5)",target="_top",tooltip="A (predictive) statistical model."]; "models.nlsmodel.NLSModel" [URL="#nipy.algorithms.statistics.models.nlsmodel.NLSModel",fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5)",target="_top",tooltip="Class representing a simple nonlinear least squares model."]; "models.model.Model" -> "models.nlsmodel.NLSModel" [arrowsize=0.5,style="setlinewidth(0.5)"]; }

Non-linear least squares model

NLSModel

class nipy.algorithms.statistics.models.nlsmodel.NLSModel(Y, design, f, grad, theta, niter=10)[source]

Bases: nipy.algorithms.statistics.models.model.Model, object

Class representing a simple nonlinear least squares model.

__init__(Y, design, f, grad, theta, niter=10)[source]

Initialize non-linear model instance

Parameters

Y : ndarray

the data in the NLS model

design : ndarray

the design matrix, X

f : callable

the map between the (linear parameters (in the design matrix) and the nonlinear parameters (theta)) and the predicted data. f accepts the design matrix and the parameters (theta) as input, and returns the predicted data at that design.

grad : callable

the gradient of f, this should be a function of an nxp design matrix X and qx1 vector theta that returns an nxq matrix df_i/dtheta_j where:

\[f_i(theta) = f(X[i], theta)\]

is the nonlinear response function for the i-th instance in the model.

theta : array

parameters

niter : int

number of iterations

getZ()[source]

Set Z into self

Returns

None

getomega()[source]

Set omega into self

Returns

None

predict(design=None)[source]

Get predicted values for design or self.design

Parameters

design : None or array, optional

design at which to predict data. If None (the default) then use the initial self.design

Returns

y_predicted : array

predicted data at given (or initial) design

SSE()[source]

Sum of squares error.

Returns

sse: float

sum of squared residuals

fit()

Fit a model to data.

initialize()

Initialize (possibly re-initialize) a Model instance.

For instance, the design matrix of a linear model may change and some things must be recomputed.