For example, to calculate the following

Suppose X1,X2,…,Xn is a random sample from a normal population with mean μ and variance 16. Find the test with the best critical region, that is, find the most powerful test, with a sample size of n=16 and a significance level α=0.05 to test the simple null hypothesis H0:μ=10 against the simple alternative hypothesis HA:μ=15.

This is the code I have up until now

#X values

X=rnorm(16,sd=4)

mlog1=function(media,x,sdev){

sum(-dnorm(x,mean=media, sd=sdev, log=T))

}

#L(10)

out1=nlm(mlog1,10,x=X,sd=4,

#L(15)

out2=nlm(mlog1,15,x=X,sd=4)

k1=out1$estimate

k2=out2$estimate

#L(10)/L(15)

print( k1/k2)

This is the very basic axample and the solution, done by hand, can be found here.

I know you also have the LRT function, but I don't know how to apply this function.

Please help, the code looks correct but it always returns 1 or 0.9999999 for any value in the parameters.

Best Regards