I have a matrix of t-statistics. I would like to perform a two-tailed t-test. The matrix has both negative and positive values.
When the t-statistic is negative then the appropriate test is:
2*(pt(t, 48))
When the t-statistic is positive then the appropriate test is:
2*(1-pt(t, 48))
I would like a function that applies the appropriate t-test on each element and results in a matrix with p-values as the elements.
Data:
structure(c(NA, 0.239348325523128, 0.287295289074944, NA, NA,
NA, NA, -0.47787610619469, -3.29364477531891, 1.40207492460775,
0.472401684451984, -0.295998187473438, NA, NA, -1.15044247787611,
0.214858657262033, 0.198896738590346, 3.18236188504482, NA, NA,
NA, NA, 6.29220713506836, -0.983839682634638, -2.21858868624661,
-0.312442531221963, -1.32075471698113, NA, NA, NA, -0.754544770207821,
0.0795081285359171, -0.982829878482466, 0, -0.743061363280779,
NA, NA, -0.0368327293685825, -0.365730336349923, 0.542663343701304,
0.152507618276505, NA, NA, NA, NA, NA, NA, NA, -0.69512192048847
), .Dim = c(7L, 7L), .Dimnames = list(i = c("Aaa", "Aa", "A",
"Baa", "Ba", "B", "Caa"), j = c("Aaa", "Aa", "A", "Baa", "Ba",
"B", "Caa")))