Question

Write a function in R that will provide the sample size needed (using the confidence interval method) to estimate the true population mean. You will have to pass several input variables to this function: confidence level, margin of error, and estimated standard deviation.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

To calculate the sample size we have the formula;


n = (zα∕222)/(e2)


Here n = Sample Size
zα∕2 is the 100(1 − α∕2) percentile of the standard normal distribution
e = margin of error
σ2= standard deviation

#Let us assume we have to calculate at a conf interval of 95%, standard deviation =10, margin of error = 1.5

z = qnorm(.975) #Since there are two tails of the normal distribution, the 95% confidence level would imply the 97.5th percentile of the normal distribution at the upper tail.
sigma = 10 # Value of sd given
e = 1.5 # margin of error

n <- z^2 ∗ sigma^2/ e^2 #n is the sample size

print(n) # Printing the value of n

#Output
[1] 170.7315

Based on the assumption of population standard deviation being 10, it needs a sample size of 171 to achieve a 1.5 margin of error at 95% confidence level.

However we know that the quality of a sample survey can be improved by increasing the sample size.

Add a comment
Know the answer?
Add Answer to:
Write a function in R that will provide the sample size needed (using the confidence interval...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT