# DGB
## Mean from One Sample
ci.mean.os <- function(alpha, m, sd, n) {
# Computes confidence interval for a population mean
# Arguments:
# alpha: alpha level for 1-alpha confidence
# m: sample mean
# sd: sample standard deviation
# n: sample size
# Values:
# estimate of population mean, SE, lower limit and upper limit
df <- n - 1
tcrit <- qt(1 - alpha/2, df)
se <- sd/sqrt(n)
ll <- m - tcrit*se
ul <- m + tcrit*se
out <- t(c(m, se, ll, ul))
colnames(out) <- c("Estimate", "SE", "LL", "UL")
return(out)
}
size.ci.mean.os <- function(alpha, var, w) {
# Computes sample size required to estimate a population
# mean with desired precision in a 1-group design
# Arguments:
# alpha: alpha level for 1-alpha confidence
# var: planning value of DV variance
# w: desired confidence interval width
# Values:
# required sample size
z <- qnorm(1 - alpha/2)
n <- ceiling(4*var*(z/w)^2 + z^2/2)
return(n)
}
size.test.mean.os <- function(alpha, var, pow, es) {
# Computes sample size required to test a population
# mean with desired power in a 1-group design
# Arguments:
# alpha: alpha level for test
# var: planning value of DV variance
# pow: desired power
# es: planning value of mean minus null hypothesis value
# Values:
# required sample size
za <- qnorm(1 - alpha/2)
zb <- qnorm(pow)
n <- ceiling(var*(za + zb)^2/es^2 + za^2/2)
return(n)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.