In [ ]:
import numpy as np
from scipy import stats
import statsmodels.api as sm
from statsmodels.base.model import GenericLikelihoodModel
In [ ]:
print sm.datasets.spector.NOTE
In [ ]:
data = sm.datasets.spector.load_pandas()
exog = sm.add_constant(data.exog, prepend=True)
endog = data.endog
In [ ]:
sm_probit = sm.Probit(endog, exog).fit()
In [ ]:
class MyProbit(GenericLikelihoodModel):
def loglike(self, params):
exog = self.exog
endog = self.endog
q = 2 * endog - 1
return stats.norm.logcdf(q*np.dot(exog, params)).sum()
In [ ]:
my_probit = MyProbit(endog, exog).fit()
In [ ]:
print sm_probit.params
In [ ]:
print sm_probit.cov_params()
In [ ]:
print my_probit.params
In [ ]:
print my_probit.cov_params()