šŸ“Š Week 5: Sampling and Estimation

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!

šŸŽÆ What You'll Learn This Week

šŸŽ² Reproducible Research - Use set.seed() for consistent random sampling
šŸ“ Z-Score Standardization - Convert data to standard normal distribution
šŸ“Š Normal Distribution Functions - Master pnorm(), qnorm(), and rnorm()
šŸŽÆ Confidence Intervals - Estimate population parameters with uncertainty
šŸ“ Sample Size Calculations - Determine required sample sizes for studies
šŸ“ˆ Margin of Error - Understand precision trade-offs in estimation

šŸš€ Getting Started: Step-by-Step Guide

Step 1: Launch Week 5 Binder Environment 🌐

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.

Step 2: Navigate to Class Activity šŸ“š

Once Binder loads, you'll see the Jupyter Notebook interface. In the left panel, you'll see:

Click on the class_activity folder to access this week's content.

Step 3: Open the Week 5 Lab Notebook šŸ“–

Inside the class_activity folder, double-click on Week5_Sampling_Estimation.ipynb to open the interactive lab notebook.

Step 4: Explore Sampling Concepts šŸ“Š

This week we'll work with sampling distributions and estimation! The notebook will guide you through:

šŸŽÆ Interactive Learning Tools

Practice with Sampling and Estimation Tools

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!

🧮 Key R Functions This Week

Sample Size and Confidence Intervals

qnorm(0.975) # Z-value for 95% confidence
ceiling(n) # Round up sample size
mean(data) + c(-1,1) * margin_error # Confidence interval
sqrt(p * (1-p) / n) # Standard error for proportions
z^2 * p * (1-p) / d^2 # Sample size formula

Normal Distribution Functions

pnorm(x, mean = 0, sd = 1) # Calculate probabilities
qnorm(p, mean = 0, sd = 1) # Find critical values
rnorm(n, mean = 0, sd = 1) # Generate random normal data
scale(data) # Standardize data (z-scores)

Reproducible Research

set.seed(123) # Set random seed
sample(population, n, replace=FALSE) # Random sampling
replicate(1000, experiment) # Repeat simulations
mean(replicated_results) # Average over simulations

šŸ“ Assignment 5: Sample Size Calculations

Step 1: Access Assignment Folder šŸ“‹

From the main directory, click on the assignment folder to access Assignment 5.

Step 2: Open Assignment 5 Notebook šŸ“„

Double-click on Assignment5.ipynb to open your assignment on sample size calculations.

Assignment Overview (20 points total)

šŸ“

Question 1: Basic Sample Size Calculation (6 points)

Calculate sample size for 95% confidence and 5% margin of error

šŸ“Š

Question 2: Effect of Prevalence Rate (5 points)

Analyze how prevalence affects required sample size

šŸ“

Question 3: Effect of Margin of Error (5 points)

Understand precision trade-offs in sample size planning

šŸŽÆ

Question 4: Effect of Confidence Level (4 points)

Compare sample sizes for different confidence levels

Step 3: Calculate Sample Sizes for Health Studies šŸ„

The assignment focuses on sample size determination for public health research:

Learn to make informed decisions about study design and resource allocation!

🌾 Why This Matters in Agriculture

🌱 Seed Germination Studies - Estimate germination rates with confidence intervals
🌾 Crop Yield Estimation - Sample fields to predict total harvest
šŸ› Pest Occurrence Surveys - Calculate sample sizes for pest monitoring
šŸ”¬ Quality Control Testing - Design sampling plans for product standards
šŸ’° Agricultural Insurance - Quantify risks using statistical estimation

Sampling Skills Help You:

šŸ’¾ Saving Your Work

āš ļø Important: Binder environments are temporary! Always save your work locally.

Download Your Notebook šŸ“„

When you're done working, save your progress:

  1. Save your notebook: File → Save
  2. Download .ipynb file: File → Download
  3. Export HTML/PDF: File → Save and Export Notebook As → HTML

Continue Your Progress Later šŸ”„

To resume your work:

  1. Launch Binder again
  2. Click Upload button
  3. Upload your saved .ipynb file
  4. Continue where you left off!

šŸ“¤ Submission Requirements

For Assignment 5, submit TWO files to UC Davis Canvas:

šŸ“„

HTML/PDF Report

Your completed assignment with all calculations and analysis

šŸ’¾

.ipynb File

Your notebook code as backup

Due Date: Check Canvas for assignment deadline

šŸŽÆ Learning Objectives

By the end of this week, you will be able to:

āœ… Calculate required sample sizes for different precision levels
āœ… Construct confidence intervals for means and proportions
āœ… Understand the relationship between confidence level and margin of error
āœ… Use normal distribution functions for statistical inference
āœ… Apply z-score standardization to compare different datasets
āœ… Design studies with appropriate statistical power

ā“ Need Help?

šŸ“§ Contact Information

Mohammadreza Narimani
šŸ“§ mnarimani@ucdavis.edu
šŸ« Department of Biological and Agricultural Engineering, UC Davis

šŸ”§ Common Issues

šŸ“š Additional Resources

🌟 Tips for Success

šŸ’” Best Practices

⚔ Key Formulas

n = z²p(1-p)/d² Sample size for proportions
xĢ„ ± z(s/√n) Confidence interval for means
z = (x-μ)/σ Z-score standardization
SE = s/√n Standard error

šŸŽ‰ Ready to Start?

Click the Binder badge below to launch Week 5!

Happy sampling and estimating! šŸ“ŠšŸŒ¾