find.c<-function(p){
L<- function(Q,x=p){
Const <- log(16.1)
ConstP <- log(15.1+Q)*(0.144)+log(14.1+Q)*(0.0064)+log(8.1+Q)*(0.0032)
X <- log(16.1+Q)*(0.81+x)+log(2.1+Q)*(0.0004+x)
X + ConstP - Const #This is derived from the principle of zero utility.
}
P<-uniroot(L,lower=0,upper=100000)$root
c=P/0.44
return(c)
}
find.c(p=0.005)
find.c(p=0.015)
在查找 p 的单个值时,此函数可以正常工作。但是当我尝试
curve(find.c, from = 0, to=1)
我得到标题中的错误。我对 R 或一般编码非常陌生,所以我真的迷失在这里。