r - R:如何比较估计器的质量(矩量法与最大似然法)
问题描述
这是我在这里的第一个问题,所以请不要对我太严格。
我需要比较估算器的质量。我有以下数据和代码。我需要了解的是,了解更好估计的唯一方法是看图形,还是有更精确的方法来做到这一点。提前致谢!
WT<-c(75, 265, 225, 402, 35, 105, 411, 346, 159, 229, 62, 256, 431, 177, 56, 144, 354, 178, 386, 294)
hist(WT,breaks=10,freq=F)
h<-hist(WT,breaks=quantile(WT,seq(0,1,0.1)),main="WT distribution")
cumfreq2<-cumsum(h$counts)/length(WT)
plot(h$breaks,c(0,cumfreq2),"l",main="Distribution
function",xlab="WT",ylab="Probabilite")+
lines(h$breaks,punif(h$breaks,min(WT),max(WT)),col="red")
#Estimate the parameter of this law by the method of moments.
u<-mean(WT)
v<-sqrt(sum((WT-u)^2)/length(WT)) # ce n'est pas le sqrt(var?) sqrt(var(WT))
a<-u-sqrt(3)*v #pourquoi 3
b<-u+sqrt(3)*v
#Estimate this parameter by the maximum likelihood method.
teta2<-max(WT)
#Compare the quality of these estimators by cumulative frequency graph
plot(h$breaks,c(0,cumfreq2),"l",main="Distribution
function",xlab="WT",ylab="Probabilite")+
lines(h$breaks,punif(h$breaks,min=a,max=b),col="red")
uni<-function(x){
if (x<=0){
y<-0
}else if (x<teta2) {
y<-x/teta2
}else {
y<-1
}
return(y)
}
lines(h$breaks,uni(h$breaks),col="blue")
解决方案
推荐阅读
- java - 来自java的API调用,奇怪的结果?
- android - 为Android Button添加箭头的最简单方法是什么
- python - 通过 Python (Spyder IDE) 连接到 Oracle
- python - 如何使用python从csv文件中读取数组列表
- javascript - Angular 6,Materialize:初始化javascript
- sql - 单个空格的正则表达式,然后是数字
- matplotlib - ModuleNotFoundError: No module named 'mpl_toolkits.basemap' 如何安装底图
- mapkit - 苹果地图不显示地图覆盖
- c++ - 在基类中存储指向派生类函数的指针
- python - 将列表中的嵌入列表写为文件中的行