旅客對不同機場滿意度調查誤差界限計算

場景

  • 旅客對 Miami 及 Los Angeles 機場滿意度調查,資料如附件檔。

問題

  • 求算信心區間為 95% 下之誤差界限。(樣本標準誤差=0.4541 誤差界限=0.8901
  • 求算平均價格之點估計。([-0.5101, 1.2701])

GNU R

source("Statistics.R")

########################################################
MarginErrorPrintOutOf2 <- function(myMeanOf2, myVarianceOf2, myStdDeviationOf2, myConfidenceInterval, myMarginError) {
  print(sprintf("樣本平均數=%8.4f 樣本變異數=%.4f 樣本標準差=%.4f 信任區間=%.4f 誤差界限=%.4f [%8.4f, %8.4f]", 
	myMeanOf2, myVarianceOf2, myStdDeviationOf2, myConfidenceInterval, myMarginError, myMeanOf2-myMarginError, myMeanOf2+myMarginError))
}
########################################################

# 6: 樣本數 > 30

# 已知


myConfidenceInterval <- 0.95

# 資料準備

mySampleRowData <- read.table(file="Statistical-Inference-6.dat", header=TRUE)
mySampleSize <- length(mySampleRowData$Miami)
mySampleMean <- c(Mean(mySampleRowData$LosAngeles), Mean(mySampleRowData$Miami))
mySampleStdDeviation <- c(StdDeviation(mySampleRowData$LosAngeles, TRUE), StdDeviation(mySampleRowData$Miami, TRUE))
mySampleVariance <- mySampleStdDeviation ^ 2

mySampleData <- data.frame(mySampleSize, mySampleMean, mySampleVariance, mySampleStdDeviation, row.names=mySampleNames)
names(mySampleData) <- c("Size", "Mean", "Variance", "StdDeviation")

print(mySampleData)
print(summary(mySampleData))

# 求算

myMeanOf2 <- MeanOf2(mySampleData$Mean[1], mySampleData$Mean[2])
myStdDeviationOf2 <- StdDeviationOf2(mySampleData$StdDeviation[1], mySampleData$Size[1], mySampleData$StdDeviation[2], mySampleData$Size[2])
myVarianceOf2 <- myStdDeviationOf2 ^ 2

myMarginError <- MarginErrorOfKnownStdDeviationOf2(myStdDeviationOf2, myConfidenceInterval)
MarginErrorPrintOutOf2(myMeanOf2, myVarianceOf2, myStdDeviationOf2, myConfidenceInterval, myMarginError)

解答

     Size Mean Variance StdDeviation
2000   50 6.72 5.634286     2.373665
1999   50 6.34 4.677959     2.162859

      Size         Mean          Variance      StdDeviation  
 Min.   :50   Min.   :6.340   Min.   :4.678   Min.   :2.163  
 1st Qu.:50   1st Qu.:6.435   1st Qu.:4.917   1st Qu.:2.216  
 Median :50   Median :6.530   Median :5.156   Median :2.268  
 Mean   :50   Mean   :6.530   Mean   :5.156   Mean   :2.268  
 3rd Qu.:50   3rd Qu.:6.625   3rd Qu.:5.395   3rd Qu.:2.321  
 Max.   :50   Max.   :6.720   Max.   :5.634   Max.   :2.374  

樣本平均數=  0.3800 樣本變異數=0.2062 樣本標準差=0.4541 信任區間=0.9500 誤差界限=0.8901 [ -0.5101,   1.2701]
ċ
Statistical-Inference-6.R
(2k)
李智,
2011年5月25日 上午12:29
ċ
Statistical-Inference-6.dat
(0k)
李智,
2011年5月25日 上午12:14