|
|
@ -1209,13 +1209,14 @@ class RegLogit(object):
|
|
|
|
Calculates likelihood for the ordinal logistic regression model.
|
|
|
|
Calculates likelihood for the ordinal logistic regression model.
|
|
|
|
'''
|
|
|
|
'''
|
|
|
|
# Author: Gordon K. Smyth <gks@maths.uq.oz.au>
|
|
|
|
# Author: Gordon K. Smyth <gks@maths.uq.oz.au>
|
|
|
|
zx = np.hstack((z,x))
|
|
|
|
zx = np.hstack((z, x))
|
|
|
|
z1x = np.hstack((z1,x))
|
|
|
|
z1x = np.hstack((z1, x))
|
|
|
|
g = _logitinv(np.dot(zx,beta))
|
|
|
|
g = _logitinv(np.dot(zx, beta))
|
|
|
|
g1 = _logitinv(np.dot(z1x,beta))
|
|
|
|
g1 = _logitinv(np.dot(z1x, beta))
|
|
|
|
g = np.maximum(y == y.max(), g)
|
|
|
|
g = np.maximum(y == y.max(), g)
|
|
|
|
g1 = np.minimum(y > y.min(), g1)
|
|
|
|
g1 = np.minimum(y > y.min(), g1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
p = g - g1
|
|
|
|
p = g - g1
|
|
|
|
dev = -2 * sum (np.log(p));
|
|
|
|
dev = -2 * sum (np.log(p));
|
|
|
|
#return dev, p, g, g1
|
|
|
|
#return dev, p, g, g1
|
|
|
@ -1300,6 +1301,15 @@ def _test_reslife():
|
|
|
|
mrl = reslife(R, nu=20)
|
|
|
|
mrl = reslife(R, nu=20)
|
|
|
|
mrl.plot()
|
|
|
|
mrl.plot()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_reglogit():
|
|
|
|
|
|
|
|
y=np.array([1, 1, 2, 1, 3, 2, 3, 2, 3, 3])
|
|
|
|
|
|
|
|
x = np.arange(10).T
|
|
|
|
|
|
|
|
b = reglogit(y,x)
|
|
|
|
|
|
|
|
b.display() % members and methods
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
b.summary()
|
|
|
|
|
|
|
|
[mu,plo,pup] = b.predict();
|
|
|
|
|
|
|
|
plot(x,mu,'g',x,plo,'r:',x,pup,'r:')
|
|
|
|
def main():
|
|
|
|
def main():
|
|
|
|
#_test_dispersion_idx()
|
|
|
|
#_test_dispersion_idx()
|
|
|
|
import doctest
|
|
|
|
import doctest
|
|
|
@ -1307,4 +1317,6 @@ def main():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
if __name__ == '__main__':
|
|
|
|
|
|
|
|
pass
|
|
|
|
main()
|
|
|
|
main()
|
|
|
|
|
|
|
|
|
|
|
|