Dear Friends,

I have been trying to learn how to use the derivative free optimization 
algorithms implemented in the package RGENOUD by Mebane and Sekhon. However, it 
does not seem to work for reasons best described as my total ignorance. If 
anybody has experience 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
}

stval <- c(0,0,0)
opt.output <- optim(stval,log.like,Y=Y[,1], X=X[,1:3],
hessian=T, method="BFGS", control=c(fnscale=-1,trace=1))
opt.output

### Now using GENOUD gives me errors

genoud.output <- genoud(log.like,beta=stval,X=X[,1:3], Y=Y[,1], nvars=3, 
pop.size=3000, max=TRUE)


       
---------------------------------

        [[alternative HTML version deleted]]

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to