solved Problem 1. A permutation test for a difference of medians

Problem 1. A permutation test for a difference of medians (instead of a difference of means) can be performed using twoSamplePermutationTestLocation() in package EnvStats by including the following argument: fcn=”median”.After using library(EnvStats) and attach(mtcars), use twoSamplePermutationTestLocation() with arguments of fcn =”median” and seed = 1 to perform a permutation test for the difference of medians between the 2 data vectors wt[vs == 0] and wt[vs==1].–“seed = 1” replaces set.seed(1) for this function twoSamplePermutationTestLocation(wt[vs == 0], wt[vs==1], fcn =”median”, seed = 1 )What is the p-value of the test with seed = 1?–The seed value must be included as an argument(Answer in 0e-00 format)Problem 2. The bootstrap can be applied equally easily to test the difference of medians, a difference of standard deviations, a difference of quantiles, etc.–Unlike KS-test for the difference in CDFs, must specify a statistic to calculate a bootstrapped differenceIs the bootstrapped difference of standard deviations (sd’s) for wt significantly different from 0 (at p < 0.05) for cars with am = 0 (data vector x) and cars with am = 1 in mtcars (data vector y)? What is the bootstrapped 95% upper confidence limit for the difference in sd’s for wt between x and y using the “Basic” bootstrap?–Remember to use set.seed(1)(Answer up to 3 decimal places)Problem 3. Use kruskal.test() to test whether mothers with different numbers of physician visits in first trimester (“ftv”) have the same median age, in the birthwt dataset in the MASS package–library(MASS)–attach(birthwt)–Use kruskal.test()What is the p-value for the test?(Answer up to 5 decimal places)Problem 4. Chi-squared tests (c2 tests) let us compare categorical data to the predictions from a model (goodness-of-fit test), or to compare finite distributions to each other to see whether they are the same (homogeneity test) and whether they are independent (independence test).library(MASS)attach(survey)# Create contingency table for smoking vs. exercise levelstbl = table(survey$Smoke, survey$Exer) # Perform a chi-square test for independence to test whether Smoke and Exer are independent. What is the p-value of the test? (Answer up to 4 decimal places)Interpretation: Can we reject the null hypothesis that Smoke and Exer are independent at a 5% significance level?

Looking for an Assignment Help? Order a custom-written, plagiarism-free paper

Order Now