程序代写代做 In [1]:

In [1]:
# data is MMFM

# Likelihood
thetas <- seq(0,1,0.05) like <- c() for (theta in thetas) like <- c(like, (theta^3)*(1-theta)^1) thetas[which.max(like)] 0.75 In [2]: plot(thetas, like)  In [3]: chi2 <- 2*(like[which(thetas==0.75)]/like[which(thetas==0.05)]) print(chi2) 1 - pchisq(chi2, df=1) [1] 1776.316 0 In [4]: # Belief 1 belief1 <- 1/thetas belief1[1] <- NA belief1 <- belief1/sum(belief1, na.rm=T) par(mfrow=c(1,3)) plot(thetas,like,type="l") plot(thetas,belief1,type="l") plot(thetas,belief1*like,type="l")  In [ ]: thetas[which.max(like*belief1)] In [ ]: # Belief 2 belief2 <- 1/(thetas^2) belief2[1] <- NA belief2 <- belief2/sum(belief2, na.rm=T) par(mfrow=c(1,3)) plot(thetas,like,type="l") plot(thetas,belief2,type="l") plot(thetas,belief2*like,type="l") In [ ]: thetas[which.max(like*belief2)] In [ ]: # Belief 3 belief3 <- 1/(thetas^3) belief3[1] <- NA belief3 <- belief3/sum(belief3, na.rm=T) par(mfrow=c(1,3)) plot(thetas,like,type="l") plot(thetas,belief3,type="l") plot(thetas,belief3*like,type="l") In [ ]: thetas[which.max(like*belief3)] In [ ]: In [ ]: In [ ]: In [ ]: In [ ]: In [ ]: # make it a legitimate probability function? In [ ]: prob <- belief2*like prob <- prob / sum(prob, na.rm=T) plot(thetas,prob,type="l") In [ ]: sum(prob[thetas<=0.20],na.rm=T) In [ ]: sum(prob[thetas<=0.05],na.rm=T) In [ ]: