p-value

p-value from fisher.test() does not match phyper()

感情迁移 提交于 2021-02-19 04:42:16
问题 The Fisher's Exact Test is related to the hypergeometric distribution, and I would expect that these two commands would return identical pvalues. Can anyone explain what I'm doing wrong that they do not match? #data (variable names chosen to match dhyper() argument names) x = 14 m = 20 n = 41047 k = 40 #Fisher test, alternative = 'greater' (fisher.test(matrix(c(x, m-x, k-x, n-(k-x)),2,2), alternative='greater'))$p.value #returns 2.01804e-39 #geometric distribution, lower.tail = F, i.e. P[X >

p-value from fisher.test() does not match phyper()

流过昼夜 提交于 2021-02-19 04:42:05
问题 The Fisher's Exact Test is related to the hypergeometric distribution, and I would expect that these two commands would return identical pvalues. Can anyone explain what I'm doing wrong that they do not match? #data (variable names chosen to match dhyper() argument names) x = 14 m = 20 n = 41047 k = 40 #Fisher test, alternative = 'greater' (fisher.test(matrix(c(x, m-x, k-x, n-(k-x)),2,2), alternative='greater'))$p.value #returns 2.01804e-39 #geometric distribution, lower.tail = F, i.e. P[X >

How to calculate p-values from cross-correlation function in R

风流意气都作罢 提交于 2021-02-10 05:20:40
问题 I calculated a cross-correlation of two time series using ccf() in R. I know how to derive the confidence limits as: ccf1 <- ccf(x=x,y=y,lag.max=5,na.action=na.pass, plot=F) upperCI <- qnorm((1+0.95)/2)/sqrt(ccf1$n.used) lowerCI <- -qnorm((1+0.95)/2)/sqrt(ccf1$n.used) But what I really need is the p-value of the maximum correlation. ind.max <- which(abs(ccf1$acf[1:11])==max(abs(ccf1$acf[1:11]))) max.cor <- ccf1$acf[ind.max] lag.opt <- ccf1$lag[ind.max] How do I calculate this p-value? I have

ggsignif package error stat_signif requires the following missing aesthetics: y

半腔热情 提交于 2021-02-09 14:28:24
问题 This is an invented example of my data: x <- c("Control", "Case", "Case", "Case", "Control", "Control", "Control", "Case", "Case", "Case") y <- c("Dead", "Dead", "Dead", "Alive", "Alive", "Dead", "Dead", "Dead", "Alive", "Dead") I'm trying to represent this data in the form of a bar plot and then indicate a statistically significant difference in the proportion of alive and dead patients between the two experimental groups (cases and controls). I performed a Pearson's chi square test and the

ggsignif package error stat_signif requires the following missing aesthetics: y

笑着哭i 提交于 2021-02-09 14:27:52
问题 This is an invented example of my data: x <- c("Control", "Case", "Case", "Case", "Control", "Control", "Control", "Case", "Case", "Case") y <- c("Dead", "Dead", "Dead", "Alive", "Alive", "Dead", "Dead", "Dead", "Alive", "Dead") I'm trying to represent this data in the form of a bar plot and then indicate a statistically significant difference in the proportion of alive and dead patients between the two experimental groups (cases and controls). I performed a Pearson's chi square test and the

How to manually compute the p-value of t-statistic in linear regression

让人想犯罪 __ 提交于 2021-02-04 17:36:09
问题 I did a linear regression for a two tailed t-test with 178 degrees of freedom. The summary function gives me two p-values for my two t-values. t value Pr(>|t|) 5.06 1.04e-06 *** 10.09 < 2e-16 *** ... ... F-statistic: 101.8 on 1 and 178 DF, p-value: < 2.2e-16 I want to calculate manually the p-value of the t-values with this formula: p = 1 - 2*F(|t|) p_value_1 <- 1 - 2 * pt(abs(t_1), 178) p_value_2 <- 1 - 2 * pt(abs(t_2), 178) I don't get the same p-values as in the model summary. Therefore, I

Why did my p-value equals 0 and statistic equals 1 when I use ks test in python?

我的未来我决定 提交于 2021-01-29 10:05:22
问题 Thanks to anyone who have a look first. My codes are : import numpy as np from scipy.stats import kstest data=[31001, 38502, 40842, 40852, 43007, 47228, 48320, 50500, 54545, 57437, 60126, 65556, 71215, 78460, 81299, 96851, 106472, 108398, 118495, 130832, 141678, 155703, 180689, 218032, 222238, 239553, 250895, 274025, 298231, 330228, 330910, 352058, 362993, 369690, 382487, 397270, 414179, 454013, 504993, 518475, 531767, 551032, 782483, 913658, 1432195, 1712510, 2726323, 2777535, 3996759,

Why does adonis() from vegan returns a different p-value every time it is?

最后都变了- 提交于 2021-01-29 05:13:05
问题 The function adonis from the vegan package performs a non-parametric MANOVA, also known as PERMANOVA. The issue (nor not, maybe I just don't fully understand how the test works) is that every time I run it using the same data, I get a slightly different p-value. Here is an example data. dframetest <- data.frame(X = rnorm(20), Y = rnorm(20), Z = rnorm(20), Label = c(rep("A",10),rep("B",10))) adonis(dframetest[,1:3] ~ Label, permutations = 1000, data = dframetest, method = "euclidean") If you

Subset variables by significant P value

帅比萌擦擦* 提交于 2021-01-28 01:32:28
问题 I'm trying to subset variables by significant P-values, and I attempted with the following code, but it only selects all variables instead of selecting by condition. Could anyone help me to correct the problem? myvars <- names(summary(backward_lm)$coefficients[,4] < 0.05) happiness_reduced <- happiness_nomis[myvars] Thanks! 回答1: An alternative solution to Martin's great answer (in the comments section) using the broom package. Unfortunately, you haven't posted an data, so I'm using the mtcars

Extract lists of p-values for each regression coefficients (1104 linear regressions) with R

北战南征 提交于 2021-01-27 19:45:16
问题 I try to do 1104 linear regressions with the same model. My independent variable does not change. However, my dependant variable does. Indeed, I have 1104 dependent variables. I can only extract all the coefficients (intercepts included), t-stats and R-square stats. I would also like to extract all the p-values lists of each coefficients within the 1104 linear regressions. How to do that with an easy way ? Here are my codes: run 1104 regressions for M1 bigtest<-as.data.frame(bigtest) test <-