20 Aug 04:22
Confidence Interval
From: Raphael Saldanha <saldanha.plangeo <at> gmail.com>
Subject: Confidence Interval
Newsgroups: gmane.comp.lang.r.general
Date: 2008-08-20 02:25:28 GMT
Subject: Confidence Interval
Newsgroups: gmane.comp.lang.r.general
Date: 2008-08-20 02:25:28 GMT
Hi!
With the following script, I'm trying to make a demonstration of a
Confidence Interval, but I'm observing some differences on tails.
# Teste de média entre uma amostra e uma população normal
# Autor: Raphael de Freitas Saldanha
# Agosto de 2008
n <- 200 # Sample size
xbar <- 100 # Sample mean
s <- 2 # Sample SD
nc <- 0.95 # Confidence level (95% -> 0.95)
rep <- 1000 # Loops
#######################################################################
y <- NULL # Vetor com as médias da amostra
for (i in 1:rep){ # Loop
x <- rnorm(n,xbar,s) # Gere uma amostra normal n elementos, xbar média e
s desvio-padrão
x <- mean(x) # Calcule a média (exata) dessa amostra
y <- c(y,x) # Coloque essa média em um registro em y
}
y <- sort(y) # Ordene todas as médias geradas
LI <- y[((1-nc)/2)*rep] # Limite inferior,
LS <- y[rep-(((1-nc)/2)*rep)] # Limite superior
(Continue reading)
RSS Feed