def nllf(p): beta0C, beta, phi, q, x[x_index] = p[0], p[1], p[2:6].reshape(2, 2), p[6], p[7:] p = ilogit(beta0C + beta*np.floor(x)) x_int, d_int = [np.asarray(np.floor(v), 'i') for v in (x, d)] cost = 0 cost += np.sum(dbern_llf(d, q)) cost += np.sum(dbern_llf(d, p)) cost += np.sum(dbern_llf(w, phi[x_int, d_int])) cost += dnorm_llf(beta0C, 0, 0.00001) cost += dnorm_llf(beta, 0, 0.00001) return -cost
def nllf(p): alpha, beta = p p = exp(alpha * xa + beta * xs) cost = 0 cost += np.sum(dbern_llf(y, p)) return -cost
def nllf(p): alpha, beta, theta = p[:T], p[T], p[T + 1:] p = ilogit(beta * theta[:, None] - alpha[None, :]) cost = 0 cost += np.sum(dbern_llf(r, p)) cost += np.sum(dnorm_llf(theta, 0.0, 1.0)) cost += np.sum(dnorm_llf(alpha, 0, 0.0001)) cost += dflat_llf(beta) return -cost
def nllf(p): delta, alpha, state = p[0], p[1], p[2:] beta = exp(alpha) theta = ilogit(delta) P = np.array([ilogit(alpha), 0]) state = np.asarray(np.floor(state), 'i') #state1 = state + 1 # zero-indexing in numpy #prop = P[state] # unused cost = 0 cost += np.sum(dbin_llf(y, P[state], t)) cost += np.sum(dbern_llf(state, theta)) cost += dnorm_llf(alpha, 0, 1e-4) cost += dnorm_llf(delta, 0, 1e-4) return -cost