R:如何比较估算器的质量(矩方法与最大似然法)

时间:2018-11-21 23:25:19

标签: r statistics

这是我的第一个问题,所以请不要对我太严格。

我需要比较估计量的质量。我有以下数据和代码。我需要了解的是,了解更好估计的唯一方法是查看图形,还是有一种更精确的方法来查看图形。预先感谢!

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")

0 个答案:

没有答案