# Luennot 8.2.2007 ######################## y<-8; n<-10 curve(dbinom(y,n,x),0,1) y<-3 curve(dbinom(y,n,x),0,1,add=T) par(mfrow=c(1,2)) y<-8; n<-10 curve(dbinom(y,n,x),0,1) y<-3 curve(dbinom(y,n,x),0,1) x<-8; n<-10 theta<- seq(0,1,len=100) like <- dbinom(8,10,theta) like <- like/max(like) plot(theta,like,type='l',xlab=expression(theta), ylab='Uskottavuus') # 2. tapa, jossa täytyy tietää SUE like<- function(theta){ dbinom(x,n,theta)/dbinom(x,n,x/n) } plot(like,0,1,xlab=expression(theta), ylab='Likelihood') title(expression('Uskottavuusfunktio')) ################################# # H4.3 # Count Rumford t<-c(4,5,7,12,14,16,20,24,28,31,34,37.5,41) F<-c(126,125,123,120,119,118,116,115,114,113,112,111,110) plot(t,F) th<- 1 curve(60+70*exp(-th*x),3,42) ############################# # H4.5 # (a) x<-1 theta<- seq(0,8,by=0.1) like <- dpois(x,theta) like <- like/max(like) plot(theta,like,type='l',xlab=expression(theta), ylab='Uskottavuus') #################################### #curve(dpois(y,x),0,8) #Esimerkki################### theta<- seq(0,8,by=0.1) like <- dpois(y,theta) like <- like/max(like) plot(theta,like,type='l',xlab=expression(theta), ylab='Likelihood') ############################################ # also possible to use formula plotting, but # we need to know the MLE in advance #like<- function(theta){ # dbinom(x,n,theta)/dbinom(x,n,x/n) # } #plot(like,0,1,xlab=expression(theta), # ylab='Likelihood') title(expression('Likelihood function')) ############################################ # (b) x<-3 theta<- seq(0,8,by=0.1) like <- dpois(x,theta) like <- like/max(like) plot(theta,like,type='l',xlab=expression(theta), ylab='Uskottavuus') # (c) theta<- seq(0,8,by=0.1) like<-theta^(10)*exp(-10*theta) like <- like/max(like) plot(theta,like,type='l',xlab=expression(theta), ylab='Uskottavuus') ######################## lines(theta,like,lwd=.3) ####################### # Samaan kuvioon ################ x<-1 theta<- seq(0,8,by=0.1) like <- dpois(x,theta) like <- like/max(like) plot(theta,like,type='l',xlab=expression(theta), ylab='Uskottavuus') x<-3 like <- dpois(x,theta) like <- like/max(like) lines(theta,like,lwd=.3) like<-theta^(10)*exp(-10*theta) like <- like/max(like) lines(theta,like,lwd=.3) ############################### # H4.2 # (b) theta<- seq(0,1,by=0.01) like <- theta^(110)*(1-theta)^(90) like <- like/max(like) plot(theta,like,type='l',xlab=expression(theta), ylab='Uskottavuus') title(expression('Tehtävä 4.2(b)')) ############################### # H4.3 # (b) theta<- seq(-1/6,1/12,by=0.001) like <- (1/6+theta)^(54)*(1/6-2*theta)^(46) like <- like/max(like) plot(theta,like,type='l',xlab=expression(theta), ylab='Uskottavuus') title(expression('Tehtävä 4.3(b)')) ############################### # H4.5 N<- seq(137,150,by=0.01) like <- 1/N^8 like <- like/max(like) plot(N,like,type='l',xlab=expression(theta), ylab='Uskottavuus') title(expression('Tehtävä 4.5')) ############################## # H4.6 # (c) theta<- seq(0,0.4,by=0.001) like <- (1-theta)^(580)*(1-(1-theta)^(20))^(91) like <- like/max(like) plot(theta,like,type='l',xlab=expression(theta), ylab='Uskottavuus') title(expression('Tehtävä 4.6(c)')) ###############################