I am trying to do three steps with my data file.
- Resample from the data file 100 times with replacement. My code is below
Q3<-question.3
Q.3<-data.frame(question.3)
resample<-Q.3[sample(100, replace = TRUE),]'
x1 x2
61 9.49 10.17
18 10.96 9.42
30 10.12 8.08
51 10.72 10.23
70 10.52 9.14
87 10.32 8.32
42 10.21 9.77
72 8.66 10.80
87.1 10.32 8.32
76 8.78 10.15
25 11.11 9.42
29 11.68 12.37
87.2 10.32 8.32
66 7.91 7.96
51.1 10.72 10.23
22 9.24 11.57
90 9.99 10.19
92 10.02 9.30
75 10.04 10.23
8 9.83 8.96
41 9.60 9.86
79 8.59 8.93
5 9.51 9.19
10 9.27 7.50
36 10.15 10.85
68 11.26 8.47
88 9.03 8.71
79.1 8.59 8.93
6 9.75 9.83
58 11.05 8.58
6.1 9.75 9.83
21 9.94 13.32
34 8.56 10.21
10.1 9.27 7.50
67 9.10 9.90
35 9.59 9.65
82 10.61 9.46
62 11.18 8.71
58.1 11.05 8.58
77 11.50 10.94
4 11.01 11.77
71 10.92 9.51
24 10.35 9.23
26 9.91 9.49
29.1 11.68 12.37
96 9.33 8.62
76.1 8.78 10.15
81 13.52 8.69
66.1 7.91 7.96
34.1 8.56 10.21
91 9.93 11.53
100 10.52 9.94
76.2 8.78 10.15
86 11.55 10.26
30.1 10.12 8.08
59 9.22 11.00
44 8.76 10.40
83 9.93 10.49
77.1 11.50 10.94
73 8.34 8.90
7 8.55 7.09
58.2 11.05 8.58
4.1 11.01 11.77
37 10.29 10.80
84 10.20 9.78
87.3 10.32 8.32
50 10.23 9.72
8.1 9.83 8.96
44.1 8.76 10.40
76.3 8.78 10.15
74 11.55 11.30
51.2 10.72 10.23
28 11.25 10.13
53 10.54 9.43
51.3 10.72 10.23
47 7.65 8.56
99 10.26 11.21
96.1 9.33 8.62
23 7.58 11.08
43 9.20 8.84
40 8.68 9.94
31 10.16 10.32
36.1 10.15 10.85
62.1 11.18 8.71
55 10.40 10.14
20 9.95 9.71
100.1 10.52 9.94
80 10.34 7.09
86.1 11.55 10.26
6.2 9.75 9.83
56 9.01 9.77
51.4 10.72 10.23
45 7.86 7.09
77.2 11.50 10.94
9 8.43 9.79
48 10.28 9.52
36.2 10.15 10.85
69 10.92 10.14
3 8.07 11.98
38 9.41 9.60
- Conduct an independent sample t-test for each of the re-sampled data to obtain 100 p-values.
I am stuck here. I can conduct a T-test for the 2 columns but I am stuck on how to do this for reach row?
I tried unlisting my re-sample and using notation to work within the R object resample to collect T.test but this doesn't work.
resample1<-unlist(resample)
resample1[t.test(resample1,mu = .05),] #didnt work
resample1[t.test(resample,mu = .05, alternative = "greater",)] #didnt work
- I then want to extract the 100 p-values from each T-test. I want to code p-values <0.05 as 1 and p-values >0.05 as 0.
If I had the 100 values I would use a if else statement and the $ to fun the if statement in each row. I would use a for loop and if else statement to extract the p-values and code them as 1's and 0's
- I want to compute the mean to see if it is close to 0.05.
thanks
P.S I am using CTRL-K to make the code be in the right format for asking a question but its not working for some reason
Aucun commentaire:
Enregistrer un commentaire