MathsGee Answers is Zero-Rated (You do not need data to access) on: Telkom |Dimension Data | Rain | MWEB
First time here? Checkout the FAQs!
x
Institutions: Global |ALU | Ekurhuleni Libraries | Joburg Libraries | Tshwane Libraries | TUT | UCT | UJ | UNISA | UP | UZ | Wits | Invest in Zim

MathsGee is Zero-Rated (You do not need data to access) on: Telkom |Dimension Data | Rain | MWEB

1 like 0 dislike
35 views
How can you resample statistical tests in R language?
in Causal Data Science by Diamond (60,788 points) | 35 views

1 Answer

0 like 0 dislike
Best answer

 

BOOTSTRAPPING

Bootstrapping is the process of resampling with replacement (all values in the sample have an equal probability of being selected, including multiple times, so a value could have a duplicate). Resample, calculate a statistic (e.g. the mean), repeat this hundreds or thousands of times and you are able to estimate a precise/accurate uncertainty of the mean (confidence interval) of the data’s distribution. There are less assumptions about the underlying distribution using bootstrap compared to calculating the standard error directly.

PERMUTATION TESTING

Similar to bootstrapping, except permutation testing resamples without replacement (meaning when a value is selected, it can not be selected again, so no value can be a duplicate). This simply shuffles the values. In the case of a univariate statistic (e.g. mean), this will not change anything. However, when there are two or more variables, reshuffling one variable will change the test statistic (e.g. correlation or regression). Usually this is done on the response/outcome/y variable, and usually for tests that use discrete or categorical (“yes”, “no”) variables.

ds <- data.frame(y = runif(10), x = runif(10))
ds
##             y          x
## 1  0.26248353 0.60789022
## 2  0.27608331 0.81612978
## 3  0.35928985 0.47067467
## 4  0.34308694 0.86670014
## 5  0.61019344 0.23596764
## 6  0.31907683 0.53597891
## 7  0.51808777 0.77629172
## 8  0.39792031 0.09387856
## 9  0.04529551 0.75595895
## 10 0.56524394 0.44996910
# Using spearman correlation to be consistent with the next example
cor(ds$y, ds$x, method = "spearman") 
## [1] -0.5393939
# Resampled the y only (reshuffled the order)
ds$resample_y <- sample(ds$y)
ds
## [1] -0.07878788

 

library(coin)
## Loading required package: methods
## Loading required package: survival
## 
## Attaching package: 'survival'
## The following object is masked from 'package:boot':
## 
##     aml
ds <- data.frame(y, x)
## Error in data.frame(y, x): object 'y' not found
spearman_test(y ~ x, data = ds)
## 
## 	Asymptotic Spearman Correlation Test
## 
## data:  y by x
## Z = -1.6182, p-value = 0.1056
## alternative hypothesis: true rho is not equal to 0

There are many more tests found within the coin package. Check them out in the vignette:

vignette("coin", package = "coin")
by Diamond (60,788 points)

Related questions

0 like 0 dislike
0 answers
0 like 0 dislike
1 answer
asked Mar 12, 2019 in Causal Data Science by MathsGee Diamond (60,788 points) | 41 views
0 like 0 dislike
0 answers
asked Mar 11, 2019 in Causal Data Science by Edzai Zvobwo Bronze Status (7,838 points) | 34 views
0 like 0 dislike
1 answer
asked Mar 11, 2019 in Causal Data Science by Edzai Zvobwo Bronze Status (7,838 points) | 31 views
0 like 0 dislike
0 answers
asked Mar 11, 2019 in Causal Data Science by Edzai Zvobwo Bronze Status (7,838 points) | 28 views

Welcome to MathsGee Answer Hub, a free online study network where students can ask, answer, and explore 24/7 for improved outcomes.



MathsGee Supporting City of Joburg

Enter your email address:

MathsGee Tools

Math Worksheet Generator

Math Algebra Solver

Trigonometry Simulations

Vectors Simulations

Matrix Arithmetic Simulations

Matrix Transformations Simulations

Quadratic Equations Simulations

Probability & Statistics Simulations

PHET Simulations

Visual Statistics

Interactive Courseware

ZeroEd Search Engine

Article Rewriter Tool

Word Counter Tool

Other Tools

STEM Gender Equality | ZOOM | Slack | eBook

14,433 questions
10,906 answers
109 comments
13,750 users