1. LON-CAPA Logo
  2. Help
  3. Log In
 

Browsing resource, all submissions are temporary.


T-Tests vs Wilcoxon Tests

Copy and paste the following code to your R console.

set.seed(6786675)
x1 <- rnorm(1e4,mean=2,sd=2)
x2 <- rnorm(1e4,mean=2,sd=2)

By construction, x1 and x2 are numeric vectors each with 10,000 random numbers drawn from a normal distribution with mean = 2 and standard deviation = 2.

a. Calculate the means and sample standard deviations of x1 and x2. Enter your answers to 3 decimal places.

Mean of x1 =       sample standard deviation of x1 =

 Tries [_1]

Mean of x2 =       sample standard deviation of x2 =

 Tries [_1]

b. Perform a two-sample t-test on x1 and x2. Don't forget to use the option var.equal=TRUE. Enter the (two-sided) p-value to 3 significant figures.

P-value of the t-test =

Reject the null at 5% significance level?


 Tries [_1]

c. Perform a Wilcoxon test on x1 and x2. Enter the p-value to 3 significant figures.

P-value of the Wilcoxon test =

Reject the null at 5% significance level?


 Tries [_1]

Use the following code to create a new vector x3.

set.seed(6786675)
x3 <- rchisq(1e4, 2)

By construction, x3 contains 10,000 random numbers drawn from the χ2 distribution with 2 degrees of freedom.

d. What is the mean and sample standard deviation of x3? Enter your answers to 3 decimal places.

Mean of x3 =       sample standard deviation of x3 =

 Tries [_1]

e. Perform a t-test on x1 and x3. Enter the (two-sided) p-value to 3 significant figures. Enter 0 if the p-value is less than 10-10.

P-value of the t-test =

 Tries [_1]

What do you conclude?

There is evidence to reject the null hypothesis that x1 and x3 are random samples drawn from




 Tries [_1]

f. Perform a Wilcoxon test on x1 and x3. Enter the p-value to 3 significant figures. Enter 0 if the p-value is less than 10-10.

P-value of the Wilcoxon test =

 Tries [_1]

What do you conclude?

There is evidence to reject the null hypothesis that x1 and x3 are random samples drawn from




 Tries [_1]

Use the following code to create a new vector x4.

set.seed(6786675)
x4 <- rnorm(1e4, 2*log(2), 0.2)

By construction, x4 contains 10,000 random numbers drawn from the normal distribution with mean = 2ln(2) and sd=0.2.

g. Perform a t-test on x3 and x4. Enter the (two-sided) p-value to 3 significant figures. Enter 0 if the p-value is less than 10-10.

P-value of the t-test =

 Tries [_1]

h. Perform a Wilcoxon test on x3 and x4. Enter the p-value to 3 significant figures. Enter 0 if the p-value is less than 10-10.

P-value of the Wilcoxon test =

 Tries [_1]

Next we want to perform an F test and a Kruskal-Wallis test on x1, x2, x3 and x4. To do these, we first need to combine x1, x2, x3, x4 to a single numeric vector and create a factor vector to specify the group of the corresponding element of the numeric vector.

Use the command x <- c(x1,x2,x3,x4) to combine x1, x2, x3, x4 to a numeric vector x of length 40,000. For the factor variable, we create it using the gl() function mentioned in Week 8's notes:

group <- gl(4,1e4,labels=c("x1","x2","x3","x4"))

The first 10,000 elements of 'group' are level "x1"; the next 10,000 elements are level "x2"; the next 10,000 elements are level "x3"; and the last 10,000 elements are level "x4". These levels match precisely the groups in 'x'.

i. Perform an F test for x1, x2, x3 and x4. Enter the p-value to 3 significant figures. Enter 0 if the p-value is less than 10-10.

P-value of the F test =

 Tries [_1]

j. Perform pairwise t-tests with Bonferroni correction to adjust the p-values. Which of the following pairs are significantly different? (Select all that apply)
x1, x2
x1, x3
x1, x4
x2, x3
x2, x4
x3, x4

 Tries [_1]

k. Perform a Kruskal-Wallis test for x1, x2, x3 and x4. Enter the p-value to 3 significant figures. Enter 0 if the p-value is less than 10-10.

P-value of the Kruskal-Wallis test =

 Tries [_1]

l. Perform pairwise Wilcoxon tests with Bonferroni correction to adjust the p-values. Which of the following pairs are significantly different? (Select all that apply)
x1, x2
x1, x3
x1, x4
x2, x3
x2, x4
x3, x4

 Tries [_1]