Skip to content
This repository was archived by the owner on Apr 2, 2020. It is now read-only.

Commit d8f43d2

Browse files
committed
Removed unsued logL
1 parent 3be4fb7 commit d8f43d2

File tree

2 files changed

+1
-78
lines changed

2 files changed

+1
-78
lines changed

nistats/model.py

+1-7
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def __init__(self, theta, Y, model, cov=None, dispersion=1., nuisance=None,
4646
multiplicative factor in front of `cov`
4747
4848
nuisance : None of ndarray
49-
parameter estimates needed to compute logL
49+
parameter estimates needed to compute log-lokelohood
5050
5151
rank : None or scalar
5252
rank of the model. If rank is not None, it is used for df_model
@@ -77,12 +77,6 @@ def __init__(self, theta, Y, model, cov=None, dispersion=1., nuisance=None,
7777
# put this as a parameter of LikelihoodModel
7878
self.df_resid = self.df_total - self.df_model
7979

80-
@setattr_on_read
81-
def logL(self):
82-
"""
83-
The maximized log-likelihood
84-
"""
85-
return self.model.logL(self.theta, self.Y, nuisance=self.nuisance)
8680

8781
def t(self, column=None):
8882
"""

nistats/regression.py

-71
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ class OLSModel(object):
4646
Methods
4747
-------
4848
model.__init___(design)
49-
model.logL(b=self.beta, Y)
5049
5150
Attributes
5251
----------
@@ -98,70 +97,6 @@ def initialize(self, design):
9897
self.df_model = matrix_rank(self.design, eps)
9998
self.df_resid = self.df_total - self.df_model
10099

101-
def logL(self, beta, Y, nuisance=None):
102-
r''' Returns the value of the loglikelihood function at beta.
103-
104-
Given the whitened design matrix, the loglikelihood is evaluated
105-
at the parameter vector, beta, for the dependent variable, Y
106-
and the nuisance parameter, sigma.
107-
108-
Parameters
109-
----------
110-
beta : ndarray
111-
The parameter estimates. Must be of length df_model.
112-
113-
Y : ndarray
114-
The dependent variable
115-
116-
nuisance : dict, optional
117-
A dict with key 'sigma', which is an optional estimate of sigma. If
118-
None, defaults to its maximum likelihood estimate (with beta fixed)
119-
as ``sum((Y - X*beta)**2) / n``, where n=Y.shape[0], X=self.design.
120-
121-
Returns
122-
-------
123-
loglf : float
124-
The value of the loglikelihood function.
125-
126-
Notes
127-
-----
128-
The log-Likelihood Function is defined as
129-
130-
.. math::
131-
132-
\ell(\beta,\sigma,Y)=
133-
-\frac{n}{2}\log(2\pi\sigma^2) - \|Y-X\beta\|^2/(2\sigma^2)
134-
135-
The parameter :math:`\sigma` above is what is sometimes referred to as a
136-
nuisance parameter. That is, the likelihood is considered as a function
137-
of :math:`\beta`, but to evaluate it, a value of :math:`\sigma` is
138-
needed.
139-
140-
If :math:`\sigma` is not provided, then its maximum likelihood estimate:
141-
142-
.. math::
143-
144-
\hat{\sigma}(\beta) = \frac{\text{SSE}(\beta)}{n}
145-
146-
is plugged in. This likelihood is now a function of only :math:`\beta`
147-
and is technically referred to as a profile-likelihood.
148-
149-
References
150-
----------
151-
.. [1] W. Green. "Econometric Analysis," 5th ed., Pearson, 2003.
152-
'''
153-
# This is overwriting an abstract method of LikelihoodModel
154-
X = self.wdesign
155-
wY = self.whiten(Y)
156-
r = wY - np.dot(X, beta)
157-
n = self.df_total
158-
SSE = (r ** 2).sum(0)
159-
if nuisance is None:
160-
sigmasq = SSE / n
161-
else:
162-
sigmasq = nuisance['sigma']
163-
loglf = - n / 2. * np.log(2 * np.pi * sigmasq) - SSE / (2 * sigmasq)
164-
return loglf
165100

166101
def whiten(self, X):
167102
""" Whiten design matrix
@@ -353,12 +288,6 @@ def __init__(self, results):
353288
# put this as a parameter of LikelihoodModel
354289
self.df_resid = self.df_total - self.df_model
355290

356-
def logL(self, Y):
357-
"""
358-
The maximized log-likelihood
359-
"""
360-
raise ValueError('can not use this method for simple results')
361-
362291
def resid(self, Y):
363292
"""
364293
Residuals from the fit.

0 commit comments

Comments
 (0)