我将找到rank-logit模型的参数.但误差总是表明存在非有限的有限差分值.如果我将"b0 <-rep(0,5)"更改为"b0 <-rep(-1,5)",则非有限差分值后的数字从2变为1.如果需要数据集,我会通过电子邮件发送给您.
cjll <- function(b){
U <- X%*%b
lSU <- csm%*%exp(U)
lSU <- (lSU!=0)*lSU+(lSU==0)
LL <- sum(Ccsm%*%U-log(lSU))
return(LL)
}
b0 <- rep(0,5)
res <- optim(b0,cjll,method="BFGS",hessian=TRUE,control=list(fnscale=-1))
#Error in optim(b0, cjll, method = "BFGS", hessian = TRUE, control = list(fnscale = -1)) :
# non-finite finite-difference value [2]
b <- res$par
#Error: object 'res' not found
Run Code Online (Sandbox Code Playgroud)