母分散の区間推定
母平均の区間推定と母比率の区間推定はそれぞれt.test()とbinom.test()を用いれば求めることができる。しかし母分散の区間推定をしてくれる関数はRには用意されていない。
★母分散の区間推定を行う関数 var.estimate()
☆ソース
var.estimate<-function(x,conf)
{
var<-var(x)
n<-length(x)
df<-n-1
if(conf==0.90){
low.esti<-(df*var)/qchisq(0.95,df)
high.esti<-(df*var)/qchisq(0.05,df)
}else if(conf==0.95){
low.esti<-(df*var)/qchisq(0.975,df)
high.esti<-(df*var)/qchisq(0.025,df)
}else if(conf==0.99){
low.esti<-(df*var)/qchisq(0.995,df)
high.esti<-(df*var)/qchisq(0.005,df)
}else{
stop("有意水準の設定が間違っています")
}
list("confidence interval"=c(low.esti,high.esti))
}
☆使い方
引数xはベクトル形式のデータ,confは有意水準(0.90,0.95,0.99のいずれか)を指定する。
> x [1] 174 165 156 165 165 170 168 167 178 158 161 172 167 171 177 174 177 165 164 [20] 173 > var.estimate(x,0.95) $`confidence interval` [1] 22.29827 82.24877