Reference no: EM132378027
Assignment
The drawback of permutation tests
Permutation tests give a numerical procedure to approximate a p-value. Its main drawback is that it is computationally expensive: often one has to average over a large number of simulations to get a reliable estimate of the p-value. This exercise demonstrates this point. The bottom line is: if you knew an exact formula for the p-value, you should always use it.
Consider setup 2. of the soda taste test experiment from the last homework again. That is, the tester tasted 10 cups, knew that there were 5 of each type. Let S be the number of cups that a taste tester got right under random guessing.
1. Write a function so that it takes an argument m and repeat the previous task m times and return their outputs as a vector. That is, your function returns the output of m independent simulations of S. Call your function sodashuffle.
2. Use sodashuffle to draw n = 1000 draws from the distribution of S. From this data, compute a numerical approximation pˆ for p := P (S = 10). How far is this approximation from the true value of p, which is 1/252?
3. Write a function to take n (number of draws) as an argument, and return the error |pˆ- p| when one performs step 2 with n draws.
4. Write a function to take r (number of repeats per draw) AND n (number of draws) as arguments, and a vector obtained from repeating the function in step 3 r times.
5. Plot your error distribution of |pˆ - p| as a series of boxplots, one for each n, for n =
25 , 26 , 27 , 28 , 29 , 210 , 211 , 212 , 213 .
6. What can you conclude from this plot?
(Tuesday HackR worksheet) Titanic dataset.
You can find this under homework4/titanic.csv. Read the file description from homework4/titanic-descrip.txt
1. Compare the distribution of base salary in teachers with BA vs MA. Include an appropriate plot.
Is there a significant difference in survival rate between classes?
2. Set up the problem as a hypothesis testing problem. State the Null, the Alternative, and the event E
3. Compute an estimation of the p-value using the permutation test (NO other tests accepted).
4. Draw conclusions.
Teacher dataset.
Consider the dataset teacher in the library OIdata. This data set contains teacher salaries from 2009-2010 for 71 teachers employed by the St. Louis Public School in Michigan, as well as several other variables. Load the data in R with
install.packages("0Idata") #first time, if you don't have the OIdata package yet
library(0Idata)
data(teacher)
for documentation, type
?teacher
1. Compare the distribution of base salary in full time teachers with BA vs MA. Include an appropriate plot.
Do full time teachers with an MA start with a significantly higher minimum base salary compared to full time teachers with a BA?
2. Set up the problem as a hypothesis testing problem. State the Null, the Alternative, and the event E
3. Compute an estimation of the p-value using the permutation test. (NO other tests accepted).
4. Draw conclusions.
Is there a significant difference in the standard deviation of base salary between full time teachers with BA and teachers with MA?
2. Set up the problem as a hypothesis testing problem. State the Null, the Alternative, and the event E
3. Compute an estimation of the p-value using the permutation test. (NO other tests accepted).
4. Draw conclusions.
Reading - OpenIntro Statistics By David Diez and Mine C ¸ etinkaya-Rundel.
Attachment:- Titanic.rar