> n <- 38 > xbarra <- 45 > S <- 6 > z <- 2.58 > #Limite inferior > LI <- (xbarra-(z*(S/(sqrt(38))))) > round(LI, dig=2)
[1] 42.49
> #Limite superior > LS <- (xbarra+(z*(S/(sqrt(38))))) > round(LS, dig=2)
[1] 47.51
> set.seed(123) > x <- rnorm(38, 45, 6) > t.test(x, conf.level = 0.99, mu = 45)
One Sample t-test data: x t = 0.4411, df = 37, p-value = 0.6617 alternative hypothesis: true mean is not equal to 45 99 percent confidence interval: 42.97008 47.81742 sample estimates: mean of x 45.39375
> n <- 22 > xbarra <- 15 > S <- 5 > t <- 2.08 > E <- t*(S/(sqrt(n))) > #Limite superior > LS <- (xbarra+E) > round(LS, dig=3)
[1] 17.217
> #Limite inferior > LI <- (xbarra-E) > round(LI, dig=3)
[1] 12.783
> set.seed(123) > y <- rnorm(22, 15, 5) > t.test(y, conf = 0.95, mu = 15)
One Sample t-test data: y t = 0.3426, df = 21, p-value = 0.7353 alternative hypothesis: true mean is not equal to 15 95 percent confidence interval: 13.21771 17.48532 sample estimates: mean of x 15.35152
> p <- seq(0, 1, 0.001) > p2 <- p * (1 - p) > plot(p, p2, type = "l", xlab = "p", ylab = "p(1-p)")
> n <- 600 > z <- 1.96 > p <- 0.7 > #Limite superior > LS <- p+z*((sqrt(p*(1-p)/n))) > round(LS, dig=3)
[1] 0.737
> #Limite inferior > LI <- p-z*((sqrt(p*(1-p)/n))) > round(LI, dig=3)
[1] 0.663
> X1 <- 21.3 > S1 <- 2.6 > X2 <- 13.4 > S2 <- 1.9 > n <- 30 > z <- 1.96 > #Limite superior > LS <- (X1-X2)+z*(sqrt(((S1^2)/n)+((S2^2)/n))) > round(LS, dig=3)
[1] 9.052
> #Limite inferior > LI <- (X1-X2)-z*(sqrt(((S1^2)/n)+((S2^2)/n))) > round(LI, dig=3)
[1] 6.748
> set.seed(123) > x1 <- rnorm(30, 21.3, 2.6) > x2 <- rnorm(30, 13.4, 1.9) > t.test(x1 - x2, conf = 0.95, mu = 7.9)
One Sample t-test data: x1 - x2 t = -0.7874, df = 29, p-value = 0.4375 alternative hypothesis: true mean is not equal to 7.9 95 percent confidence interval: 6.240396 8.636979 sample estimates: mean of x 7.438687
> n1 <- 10 > X1 <- 45.33 > S12 <- 1.54 > n2 <- 11 > X2 <- 43.54 > S22 <- 2.96 > Sp2 <- round((((n1-1)*S12)+((n2-1)*S22))/19, dig=2) > Sp2
[1] 2.29
> t <- 2.78 > #Limite superior > LS <- LS <- (X1-X2)+t*(sqrt(Sp2*((1/n1)+(1/n2)))) > round(LS, dig=3)
[1] 3.628
> #Limite inferior > LI <- LS <- (X1-X2)-t*(sqrt(Sp2*((1/n1)+(1/n2)))) > round(LI, dig=3)
[1] -0.048
> require(BSDA) > nsize(b = 100, sigma = 237.5)
The required sample size (n) to estimate the population mean with a 0.95 confidence interval so that the margin of error is no more than 100 is 22 .
> amp <- 1000 - 50 > desv.p <- amp/4 > n1.amostra <- function(z, dp, E){((z*dp)/E)^2} > # z = z(nivel de significancia). > # dp = desvio padrao. > # E = erro maximo. > round(n1.amostra(1.96, desv.p, 100), dig=0)
[1] 22
> require(BSDA) > nsize(b = 0.05, ty = "pi")
The required sample size (n) to estimate the population proportion of successes with a 0.95 confidence interval so that the margin of error is no more than 0.05 is 385 .
> nsize(b = 0.07, p = 0.6, ty = "pi")
The required sample size (n) to estimate the population proportion of successes with a 0.95 confidence interval so that the margin of error is no more than 0.07 is 189 .
> n.amostra <- function(N, n) { + (N * n)/(N + n) + }
> nsize(b = 1, sigma = 2.8, conf = 0.99)
The required sample size (n) to estimate the population mean with a 0.99 confidence interval so that the margin of error is no more than 1 is 53 .
> round(n.amostra(200, 53), dig = 0)
[1] 42