我正在运行此代码:
n <- 30
set.seed(42)
x <- rcauchy(n)
minL <- function(x){
sum(-10*log(pi)-sum(log(1+(x-mu)^2)))
}
uniroot(f=minL,interval=c(-10,10),check.conv = FALSE, maxiter = 1000, trace = 0)
并不断收到此错误消息:
Error in uniroot(f = minL, interval = c(-10, 10), check.conv = FALSE, :
f() values at end points not of opposite sign
我尝试过重写和重新格式化代码(例如,低= -10,高= 10),但仍有相同的问题。