logmle<-function(theta){
n<-length(x)
loglik<-sum(log(1-cos(x-theta)))-n*log(2*pi)
return(loglik)
}
x<-c(3.91,4.85,2.28,4.06,3.70,4.04,5.46,3.53,2.28,1.96,
2.53,3.88,2.22,3.47,4.82,2.46,2.99,2.54,0.52,2.50)
curve(logmle,-pi,pi)
为什么结果显示这样:
Error in curve(logmle, -pi, pi) : 'expr'没有评估为长度是'n'的对象
此外: Warning message:
In x - theta : 长的对象长度不是短的对象长度的整倍数
R语言新手求助各位大神[em29][em29]