TU Wien:Statistik und Wahrscheinlichkeitstheorie UE (Levajkovic)/Übungen 2023W/HW08.5

Aus VoWi
Zur Navigation springen Zur Suche springen
Confidence interval

In the June 1986 issue of Consumer Reports, some data on the calorie content of beef hot dogs is given. Here are the numbers of calories in 20 different hot dog brands:

186, 181, 176, 149, 184, 190, 158, 139, 175, 148, 152, 111, 141, 153, 190, 157, 131, 149, 135, 132.

Assume that the numbers are from a normal distribution with mean and variance , both unknown. Use R to obtain a 90% confidence interval for the mean number of calories .

Dieses Beispiel ist als solved markiert. Ist dies falsch oder ungenau? Aktualisiere den Lösungsstatus (Details: Vorlage:Beispiel)


Lösungsvorschlag von Lessi[Bearbeiten | Quelltext bearbeiten]

--Lessi 2024-02-07T13:04:11Z

data <- c(186, 181, 176, 149, 184, 190, 158, 139, 175, 148, 152, 111, 141, 153, 190, 157, 131, 149, 135, 132)

n <- length(data)
m <- mean(data)
s <- sd(data)
sem <- s / sqrt(n)
alpha <- 0.1

# this time use t-quantiles as the data is bell shaped
q <- qt(1 - (alpha / 2), n - 1)

lower <- m - q * sem
upper <- m + q * sem

hist(data)

abline(v=m, col='red')
arrows(lower, 4.2, upper, 4.2, code=3, length=0.1, angle=90)
text(m + 10, 4.5, "90% - C.I.")
text(m + 5, 5, expression(bar(x)), col='red')