Question 1

The log-likelihood is \[ l(\theta)=-\frac{1}{\theta}\sum X_i -\theta \sum Y_i. \] Suppose \(\theta_1\) is the MLE of \(\theta\), then \[ \theta_1=\sqrt{\frac{\sum X_i}{ \sum Y_i}}, \] and \[ J(\theta_1)=\frac{2\sum X_i}{\theta_1^3}. \] Since \(I(\theta)=\frac{2}{\theta^2}\), we have \[ nI(\theta_1)=n \frac{2}{\theta_1^2}. \]

Note that \(X \sim \exp(\frac{1}{\theta})\), \(X \sim \exp(\theta)\) and they are independent, we can sample them separately. Assume the true value \(\theta_0=2\) and \(n=100\). We can do the simulation based on repeated samples of size \(m=1000\). As we see, the sampling distributions of \([nI(\theta_1)]^{0.5}(\theta_1-\theta_0)\) and \([J(\theta_1)]^{0.5}(\theta_1-\theta_0)\) are very close.

m=1000
n=100
theta=2
fI=rep(0,m)
fJ=rep(0,m)
ftrue=rep(0,m)
for (i in 1:m) {
x=rexp(n,1/theta)
y=rexp(n,theta)
xn=sum(x)
yn=sum(y)
thetahat=sqrt(xn/yn)
fI[i]=(thetahat-theta)*(n*2/thetahat^2)^0.5 
fJ[i]=(thetahat-theta)*(2*xn/thetahat^3)^0.5
ftrue[i]=(thetahat-theta)*(2*xn/theta^3)^0.5
}
ks.test(fI,ftrue)
## 
##  Two-sample Kolmogorov-Smirnov test
## 
## data:  fI and ftrue
## D = 0.045, p-value = 0.2634
## alternative hypothesis: two-sided
ks.test(fJ,ftrue)
## 
##  Two-sample Kolmogorov-Smirnov test
## 
## data:  fJ and ftrue
## D = 0.041, p-value = 0.37
## alternative hypothesis: two-sided
fall=data.frame(IJ=c(fI,fJ),index=c(rep("I",m),rep("J",m)))
fall$index=factor(fall$index)
library(ggplot2)
ggplot(fall, aes(x = IJ, fill = index))+geom_density(alpha = 0.4)

Question 2

Note that the statistic \(T \sim t(u,38)\), where \(u\) is the non-centrality parameter given by \[ u = \frac{\mu_1 - \mu_2}{\sqrt(2/20)} \]

Since the level of significance is \(0.05\), the observed data points are \(5\) samples that are drawn from a truncated T distribution such that \(|T_i| \ge t_{1-0.025,38}\). Then we can try grid search to find the MLE of \(u=\mu_1-\mu_2\) numerically.

T=c(2.47,2.17,3.41,2.81,2.87)
C=qt(1-0.025,38)
u= seq(-6,6,by=0.01)
likeli=rep(0,length(u))
for (i in 1:length(u)){
  likeli[i]=sum(dt(T, df=38, ncp=u[i],log=TRUE)) -    length(T)*log(1-pt(C,df=38,ncp=u[i])+pt(-C,df=38,ncp=u[i]))
 

}
plot(u,likeli,type="l")

MLE=print(u[which.max(likeli)]*sqrt(1/10))
## [1] 0.5186135

Then the MLE of \(\mu_1-\mu_2\) is \(0.5186\) .