Resource assessment exercises: required sample size determination
From AWF-Wiki
(Difference between revisions)
Line 1: | Line 1: | ||
{{construction}} | {{construction}} | ||
+ | [[Resource assessment exercises: standard error and confidence intervals|Previously]] we took a sample <code>S</code> of size <math>n=50</math>. | ||
+ | |||
+ | <pre> | ||
+ | S | ||
+ | |||
+ | ## [1] 22 8 18 43 21 44 17 25 32 10 11 17 9 10 56 14 14 10 20 8 37 14 55 29 33 | ||
+ | ## [26] 17 10 15 29 8 21 9 9 24 21 28 19 58 16 16 15 20 5 9 14 30 11 9 12 27 | ||
+ | </pre> | ||
+ | |||
+ | The width of the confidence interval was, | ||
+ | |||
+ | <pre> | ||
+ | sd(S)/sqrt(n) * qt(0.975, n - 1) * 2 | ||
+ | |||
+ | ## [1] 7.364 | ||
+ | </pre> | ||
+ | |||
+ | Suppose a confidence interval of <math>A=3</math> cm is desired. How large should the sample size, <math>n</math>, be? This can be estimated, | ||
+ | |||
+ | {{EquationRef|equation=$A=t_{\alpha,n-1}\frac{s}{\sqrt{n} }\rightarrow n=\frac{t_{\alpha, n-1}^2s^2}{A^2}$|1}} | ||
+ | |||
+ | We will use the sample <code>S</code> (<math>n=50</math>) to estimate how many observations we need in our sample. | ||
+ | In [[:wikipedia:R_(programming_language)|R]]: | ||
+ | |||
+ | <pre> | ||
+ | half.A <- 1.5 | ||
+ | req.n <- (qt(0.975, n - 1)^2 * var(S))/half.A^2 | ||
+ | req.n | ||
+ | |||
+ | ## [1] 301.2 | ||
+ | </pre> | ||
+ | |||
+ | We always need to round up! | ||
+ | |||
+ | <pre> | ||
+ | req.n <- ceiling(req.n) | ||
+ | </pre> | ||
+ | |||
+ | {{info|message=What the function <code>ceiling()</code> does|text=The function <code>ceiling()</code> ceiling takes a single numeric argument <code>x</code> and returns a numericvector containing the smallest integers not less than the corresponding elements of <code>x</code> E.g., 4.3 becomes 5. See also <code>round()</code>.}} | ||
+ | |||
+ | |||
+ | We estimate the width of the confidence interval using the new sample size of <math>n=302</math>. | ||
+ | |||
+ | |||
+ | ## [1] 2.759 | ||
[[category:Resource assessment basics in R (2014)|Required sample size determination]] | [[category:Resource assessment basics in R (2014)|Required sample size determination]] |
Revision as of 11:22, 23 June 2014
sorry: |
This section is still under construction! This article was last modified on 06/23/2014. If you have comments please use the Discussion page or contribute to the article! |
Previously we took a sample S
of size \(n=50\).
S ## [1] 22 8 18 43 21 44 17 25 32 10 11 17 9 10 56 14 14 10 20 8 37 14 55 29 33 ## [26] 17 10 15 29 8 21 9 9 24 21 28 19 58 16 16 15 20 5 9 14 30 11 9 12 27
The width of the confidence interval was,
sd(S)/sqrt(n) * qt(0.975, n - 1) * 2 ## [1] 7.364
Suppose a confidence interval of \(A=3\) cm is desired. How large should the sample size, \(n\), be? This can be estimated,
$A=t_{\alpha,n-1}\frac{s}{\sqrt{n} }\rightarrow n=\frac{t_{\alpha, n-1}^2s^2}{A^2}$ | 1 |
We will use the sample S
(\(n=50\)) to estimate how many observations we need in our sample.
In R:
half.A <- 1.5 req.n <- (qt(0.975, n - 1)^2 * var(S))/half.A^2 req.n ## [1] 301.2
We always need to round up!
req.n <- ceiling(req.n)
- What the function
ceiling()
does - The function
ceiling()
ceiling takes a single numeric argumentx
and returns a numericvector containing the smallest integers not less than the corresponding elements ofx
E.g., 4.3 becomes 5. See alsoround()
.
We estimate the width of the confidence interval using the new sample size of \(n=302\).
- [1] 2.759