σ
x=(x1,...,xn)(μ,σ)
L(μ,σ)∝1σnexp(−12σ2∑j=1n(xj−μ)2)
(μ^,σ^)=(x¯,s)s=1n∑nj=1(xj−x¯)2−−−−−−−−−−−−−−√σ
Rp(σ)=supμL(μ,σ)L(μ^,σ^)=(σ^σ)nexp[n2(1−(σ^σ)2)]
Rp:R+→(0,1]0.1470.95R
data = rnorm(30)
n = length(data)
sg = sqrt(mean((data-mean(data))^2))
# Profile likelihood
rp = function(sigma) return( (sg/sigma)^n*exp(0.5*n*(1-(sg/sigma)^2)) )
vec = rvec = seq(0.5,1.5,0.01)
for(i in 1:length(rvec)) rvec[i] = rp(vec[i])
plot(vec,rvec,type="l")
rpc = function(sigma) return(rp(sigma)-0.147)
# Approximate 95% confidence interval
c(uniroot(rpc,c(0.7,0.8))$root,uniroot(rpc,c(1.1,1.3))$root)
σI=(L,U)σ2I′=(L2,U2)