@@ -46,7 +46,6 @@ class OLSModel(object):
46
46
Methods
47
47
-------
48
48
model.__init___(design)
49
- model.logL(b=self.beta, Y)
50
49
51
50
Attributes
52
51
----------
@@ -98,70 +97,6 @@ def initialize(self, design):
98
97
self .df_model = matrix_rank (self .design , eps )
99
98
self .df_resid = self .df_total - self .df_model
100
99
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
165
100
166
101
def whiten (self , X ):
167
102
""" Whiten design matrix
@@ -353,12 +288,6 @@ def __init__(self, results):
353
288
# put this as a parameter of LikelihoodModel
354
289
self .df_resid = self .df_total - self .df_model
355
290
356
- def logL (self , Y ):
357
- """
358
- The maximized log-likelihood
359
- """
360
- raise ValueError ('can not use this method for simple results' )
361
-
362
291
def resid (self , Y ):
363
292
"""
364
293
Residuals from the fit.
0 commit comments