Displaying 1 result from an estimated 1 matches for "prodterm".
Did you mean:
procter
2007 Aug 16
0
Help with optimization using GENOUD
...using this package, it would be really helpful if you can point out where I'm making a mistake.
Thanks in advance
Anup
Sample code attached
library(rgenoud)
nobs <- 5000
t.beta <- c(0,1,-1)
X <- as.matrix(cbind(rep(1, nobs), runif(nobs), runif(nobs))) # Creating the design matrix
prodterm <- (X%*%t.beta)+rnorm(nrow(X))
Y <- as.matrix(ifelse(prodterm<0, 0, 1))
# Defining the likelihood function
log.like <- function(beta, Y, X)
{
term1 <- pnorm(X%*%beta)
term2 <- 1-term1
loglik <- (sum(Y*log(term1))+sum((1-Y)*log(term2))) # Likelihood function to be maximized
}...