Master Sample Size Calculations and Confidence Intervals šÆ
Welcome to Week 5! This week, we explore sampling distributions and statistical estimation - critical skills for designing agricultural studies and interpreting research results. Learn to calculate sample sizes, construct confidence intervals, and understand estimation precision!
Click the "Launch Week 5" button above to start your R environment. This will take 2-5 minutes to load with all necessary packages for sampling and estimation.
Once Binder loads, you'll see the Jupyter Notebook interface. In the left panel, you'll see:
assignment/ - Assignment 5 on sample size calculationsclass_activity/ - Week 5 lab tutorialClick on the class_activity folder to access this week's content.
Inside the class_activity folder, double-click on Week5_Sampling_Estimation.ipynb to open the interactive lab notebook.
This week we'll work with sampling distributions and estimation! The notebook will guide you through:
Use these interactive tools to understand sampling concepts before working with R code:
š” Tip: Use these tools to visualize sampling distributions and confidence intervals before applying them in your R notebook!
qnorm(0.975) # Z-value for 95% confidenceceiling(n) # Round up sample sizemean(data) + c(-1,1) * margin_error # Confidence intervalsqrt(p * (1-p) / n) # Standard error for proportionsz^2 * p * (1-p) / d^2 # Sample size formula
pnorm(x, mean = 0, sd = 1) # Calculate probabilitiesqnorm(p, mean = 0, sd = 1) # Find critical valuesrnorm(n, mean = 0, sd = 1) # Generate random normal datascale(data) # Standardize data (z-scores)
set.seed(123) # Set random seedsample(population, n, replace=FALSE) # Random samplingreplicate(1000, experiment) # Repeat simulationsmean(replicated_results) # Average over simulations
From the main directory, click on the assignment folder to access Assignment 5.
Double-click on Assignment5.ipynb to open your assignment on sample size calculations.
Calculate sample size for 95% confidence and 5% margin of error
Analyze how prevalence affects required sample size
Understand precision trade-offs in sample size planning
Compare sample sizes for different confidence levels
The assignment focuses on sample size determination for public health research:
Learn to make informed decisions about study design and resource allocation!
ā ļø Important: Binder environments are temporary! Always save your work locally.
When you're done working, save your progress:
To resume your work:
.ipynb fileFor Assignment 5, submit TWO files to UC Davis Canvas:
Your completed assignment with all calculations and analysis
Your notebook code as backup
Due Date: Check Canvas for assignment deadline
By the end of this week, you will be able to:
Mohammadreza Narimani
š§ mnarimani@ucdavis.edu
š« Department of Biological and Agricultural Engineering, UC Davis
?qnorm for help with normal functionsClick the Binder badge below to launch Week 5!
Happy sampling and estimating! šš¾