algorithms.statistics.models.nlsmodel

Module: algorithms.statistics.models.nlsmodel

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

Inheritance diagram of nipy.algorithms.statistics.models.nlsmodel

Non-linear least squares model

NLSModel

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

Bases: nipy.algorithms.statistics.models.model.Model, nipy.externals.six.Iterator

Class representing a simple nonlinear least squares model.

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

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

SSE()

Sum of squares error.

Returns:

sse: float

sum of squared residuals

getZ()

Set Z into self

Returns:None
getomega()

Set omega into self

Returns:None
predict(design=None)

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