Last active
May 11, 2021 15:10
-
-
Save allatambov/5e7e2066a4a67aaea0c1c240e1dd9214 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## PART 1: PROPORTIONS ## | |
### COUNT DATA ### | |
girls <- read.csv("https://allatambov.github.io/twimc/names-girls.csv") | |
boys <- read.csv("https://allatambov.github.io/twimc/names-boys.csv") | |
girls <- girls[girls$Month == "январь" & girls$Year == 2018, ] | |
table(girls$Name) | |
table(girls$Name_en) | |
N <- sum(girls$NumberOfPersons) | |
N_success <- 285 | |
### CONFIDENCE INTERVAL FOR THE PROPORTION ### | |
install.packages("DescTools") | |
library(DescTools) | |
BinomCI(N_success, N) | |
BinomCI(N_success, N, conf.level = 0.99) | |
### TESTING HYPOTHESES ABOUT ONE PROPORTION ### | |
# H0: p = 0.03, H1: p != 0.03 | |
prop.test(x = N_success, n = N, p = 0.03) | |
# H0: p = 0.03 H1: p > 0.03 | |
prop.test(x = N_success, n = N, p = 0.03, alternative = "greater") | |
## PART 2: MEANS ## | |
### LOAD DATA ### | |
cowles <- read.csv("https://allatambov.github.io/twimc/Cowles.csv") | |
### CONFIDENCE INTERVAL FOR THE MEAN ### | |
MeanCI(cowles$extraversion) | |
MeanCI(cowles$neuroticism, conf.level = 0.9) | |
### TESTING HYPOTHESES ABOUT ONE MEAN ### | |
# H0: mu = 15, H1: mu != 15 | |
t.test(cowles$extraversion, mu = 15) | |
# H0: mu = 15, H1: mu < 15 | |
t.test(cowles$extraversion, mu = 15, alternative = "less") | |
### TESTING HYPOTHESES ABOUT TWO MEANS ### | |
# H0: mu1 = mu2 | |
t.test(cowles$neuroticism ~ cowles$sex) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment