Displaying 1 result from an estimated 1 matches for "gprobit".
Did you mean:
probit
2011 Nov 30
1
How can I pick a matrix from a function? (Out Product of Gradient)
...it <- *function*(beta,y,X) {
n <- length(y)
k <- ncol(X)
b <- beta[1:k]
kk <- 2*y-1
z <- X %*% b
L <- log(pnorm(kk*z))
L <- sum(L)
return(-L)
}
# *********************************************
# Probit model: analytic gradient
# *********************************************
gprobit <- *function*(b,y,X) {
kappa=2*y-1
z <- kappa*(X %*% b)
imr <- kappa*dnorm(z)/pnorm(z)
G<-matrix(ncol=ncol(X),nrow=nrow(X))
*for*(i *in* 1:nrow(imr)){
G[i,]<-imr[i,]*X[i,]
}
g <- apply(G,2,sum)
return(-g)
}
#**********************************************************
# How can I p...