
## com50a of november 2024,
#  looking at exam stk4011 december 2023 again,
#  with war and peace

# Why fume’th in fight: the Gentils spite / In fury raging stout?,
# sang Blindern Stunt- og Popupkor two days ago, at Godt Hjort 

# https://www.youtube.com/watch?v=cMxDt2KIwpk

#  rho = thetaL / thetaR 

nL <- 38
nR <- 18

ybarL <- 2.501
ybarR <- 1.129

thetaLhat <- 1/ybarL
thetaRhat <- 1/ybarR

rhohat <- thetaLhat / thetaRhat 

thetaval <- seq(0.1,1.6,by=0.001)

CLval <- 1 - pchisq(2*nL*thetaval/thetaLhat,2*nL)
CRval <- 1 - pchisq(2*nR*thetaval/thetaRhat,2*nR)

ccLval <- abs(1-2*CLval)
ccRval <- abs(1-2*CRval)

matplot(thetaval,cbind(CLval,CRval),type="l",lwd=3)

par(bty="l")
par(cex.lab=1.4142) 

matplot(thetaval,cbind(ccLval,ccRval),type="l",lwd=3,
   xlab="theta, before and after Vietnam",ylab="confidence")
matlines(thetaval,0*thetaval,type="l",lty=3,lwd=3)

## then for rho: 

rhoval <- seq(0.1,1.1,by=0.001)
Cval <- 1 - pf(rhohat/rhoval,2*nL,2*nR)
ccval <- abs(1 - 2*Cval) 

matplot(rhoval,Cval,type="l",lwd=3)

rhoshort <- rhoval[ccval <= 0.95]
# from 0.249 to 0.773 so rho < 1, so thetaL < thetaR which is good 

par(bty="l")
par(cex.lab=1.4142) 

matplot(rhoval,ccval,type="l",lwd=3,
   xlab="rho = thetaL/thetaR", ylab="confidence")
matlines(rhoval,0*rhoval,type="l",lty=3,lwd=3)

matlines(rhoshort, 0*rhoshort + 0.95,type="l",lty=2,lwd=3)

   


