Популярное

Музыка Кино и Анимация Автомобили Животные Спорт Путешествия Игры Юмор

Интересные видео

2025 Сериалы Трейлеры Новости Как сделать Видеоуроки Diy своими руками

Топ запросов

смотреть а4 schoolboy runaway турецкий сериал смотреть мультфильмы эдисон
dTub
Скачать

Stratified Sampling in R (part 1)

Автор: Jalayer Academy

Загружено: 2017-02-09

Просмотров: 24883

Описание:

Stratified Sampling explained and demonstrated with a simulated example.

part 2 of this series:    • Stratified Sampling in R (part 2)  
part 3 of this series:    • Stratified Sampling in R (part 3)  

R code:
#Stratified Sampling
#alternative to SRS
#divide population into k non-overlapping distinct subpopulations called strata
#Why Stratify?
#1 - interested in learning about the subpopulation; perhaps to compare them later
#2 - convenient for organizing data collection
#3 - improve precision of your estimate; smaller error of estimation; especially
when strata are homogenous; efficiency gain

set.seed(9850)
df = data.frame(gender=rep(c("F","M"),c(6000,4000)), ht=c(rnorm(6000, mean=60, sd=5),rnorm(4000, mean=90, sd=5)))

#Population parameters (mu, sigma, strata, etc)
mean(df$ht)
table(df$gender)
var(df$ht)
sd(df$ht)
aggregate(df$ht ~ df$gender, FUN=mean)
aggregate(df$ht ~ df$gender, FUN=sd)

#Generating 1000 SRS, size n=50, for purposes of measuring precision of estimate for mu
set.seed(9850)
xbar = apply(replicate(1000, sample(df$ht, 50)), 2, FUN=mean)
mean(xbar)
var(xbar)
sd(xbar)
sigmasq_xbar = ((var(df$ht) * (length(df$ht) - 1)) / length(df$ht)) / 50
sigmasq_xbar_hat = var(xbar)

#proportional stratified RS using gender for strata
table(df$gender) / nrow(df) * 50
#30 F and 20 M
xbarStrat = NA
set.seed(9850)
for (i in 1:1000) {xbarStrat[i] = mean( c(df[sample(6000, 30), "ht"], df[sample(6001:10000, 20), "ht"]) ) }
mean(xbarStrat)
var(xbarStrat)
sigmasq_xbarStrat = (6000/10000)^2*(((var(df[df$gender %in% "F", "ht"])*(6000-1)) / 6000)/30)*((6000-30)/(6000-1)) +
(4000/10000)^2*(((var(df[df$gender %in% "M", "ht"]) * (4000 - 1)) / 4000)/20)*((4000-20)/(4000-1))

#visualizing the precision differential between the two sampling techniques
par(mfrow=c(1,2))
hist(xbar, freq=F, xlim=c(65,85))
lines(density(xbar), col="red")
hist(xbarStrat, freq=F, xlim=c(65,85))
lines(density(xbarStrat), col="red")

Stratified Sampling in R (part 1)

Поделиться в:

Доступные форматы для скачивания:

Скачать видео mp4

  • Информация по загрузке:

Скачать аудио mp3

Похожие видео

Stratified Sampling in R (part 2)

Stratified Sampling in R (part 2)

R Square - clearly explained (part 2)

R Square - clearly explained (part 2)

Introduction to Applied Statistics with R

Introduction to Applied Statistics with R

Intro to Applied Statistics

Intro to Applied Statistics

Machine Learning, Data Mining, Statistics with R

Machine Learning, Data Mining, Statistics with R

R - Downloading R for Windows and Mac

R - Downloading R for Windows and Mac

Меры изменчивости

Меры изменчивости

Intro to Probability

Intro to Probability

Сравнение двух пропорций: проверка гипотезы и доверительный интервал

Сравнение двух пропорций: проверка гипотезы и доверительный интервал

Graphical Summaries of Data (part 1) Categorical

Graphical Summaries of Data (part 1) Categorical

Distribution Shapes - Skewed Bellshaped Normal Modes Tails and more

Distribution Shapes - Skewed Bellshaped Normal Modes Tails and more

R - import data, save history, getting started in R

R - import data, save history, getting started in R

CART Tree Basics

CART Tree Basics

Chi Square Test of Independence Lecture

Chi Square Test of Independence Lecture

Importing Data in R - alternative easier method

Importing Data in R - alternative easier method

Mean versus Median

Mean versus Median

Graphical Summaries of Data (part 2) Numerical

Graphical Summaries of Data (part 2) Numerical

Paired Sample T test comparing means

Paired Sample T test comparing means

Random Variables

Random Variables

Conditional Probability and Independence

Conditional Probability and Independence

© 2025 dtub. Все права защищены.



  • Контакты
  • О нас
  • Политика конфиденциальности



Контакты для правообладателей: infodtube@gmail.com