首页 > 解决方案 > 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")

标签: rstatistics

解决方案


推荐阅读