Quality Learning Support For Better Outcomes
First time here? Checkout the FAQs!
x
MathsGee is Zero-Rated (You do not need data to access) on: Telkom |Dimension Data | Rain | MWEB

1 like 0 dislike
47 views
How can you resample statistical tests in R language?
in Data Science & Statistics by Diamond (80,728 points) | 47 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 (80,728 points)

Related questions

0 like 0 dislike
1 answer
0 like 0 dislike
0 answers
0 like 0 dislike
0 answers
asked Mar 11, 2019 in Data Science & Statistics by Edzai Zvobwo Bronze Status (8,642 points) | 44 views
0 like 0 dislike
0 answers
asked Mar 11, 2019 in Data Science & Statistics by Edzai Zvobwo Bronze Status (8,642 points) | 41 views
0 like 0 dislike
1 answer
asked Mar 11, 2019 in Data Science & Statistics by Edzai Zvobwo Bronze Status (8,642 points) | 37 views
0 like 0 dislike
0 answers
1 like 0 dislike
1 answer
0 like 0 dislike
0 answers
0 like 0 dislike
0 answers
asked Mar 12, 2019 in Data Science & Statistics by MathsGee Diamond (80,728 points) | 41 views
0 like 0 dislike
0 answers

Join the MathsGee Answer Hub community and get study support for success - MathsGee Answer Hub provides answers to subject-specific educational questions for improved outcomes.



On MathsGee Answers, you can:


  1. Ask questions
  2. Answer questions
  3. Comment on Answers
  4. Vote on Questions and Answers
  5. Donate to your favourite users
  6. Create/Take Live Video Lessons

Posting on MathsGee


  1. Remember the human
  2. Behave like you would in real life
  3. Look for the original source of content
  4. Search for duplicates before posting
  5. Read the community's rules
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

MathsGee ZOOM | eBook