hypothesis-test

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 write a loop to run the t-test of a data frame?

牧云@^-^@ 提交于 2020-05-11 07:17:30
问题 I met a problem of running a t-test for some data stored in a data frame. I know how to do it one by one but not efficient at all. May I ask how to write a loop to do it? For example, I have got the data in the testData: testData <- dput(testData) structure(list(Label = structure(c(2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L ), .Label = c("Bad", "Good"), class = "factor"), F1 = c(0.647789237, 0.546087915, 0.461342005, 0.794212207, 0.569199511, 0

How to write a loop to run the t-test of a data frame?

谁说我不能喝 提交于 2020-05-11 07:16:46
问题 I met a problem of running a t-test for some data stored in a data frame. I know how to do it one by one but not efficient at all. May I ask how to write a loop to do it? For example, I have got the data in the testData: testData <- dput(testData) structure(list(Label = structure(c(2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L ), .Label = c("Bad", "Good"), class = "factor"), F1 = c(0.647789237, 0.546087915, 0.461342005, 0.794212207, 0.569199511, 0

How to write a loop to run the t-test of a data frame?

萝らか妹 提交于 2020-05-11 07:15:13
问题 I met a problem of running a t-test for some data stored in a data frame. I know how to do it one by one but not efficient at all. May I ask how to write a loop to do it? For example, I have got the data in the testData: testData <- dput(testData) structure(list(Label = structure(c(2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L ), .Label = c("Bad", "Good"), class = "factor"), F1 = c(0.647789237, 0.546087915, 0.461342005, 0.794212207, 0.569199511, 0

How to extract the dataset from an “htest” object when using formula in r

纵然是瞬间 提交于 2020-04-30 07:18:05
问题 The question is how to extract the dataset from an "htest" object when using formula. For example, library(gginference) t_test <- t.test(formula = pulse~ gender, data=questionnaire) t_test$data.name returns [1] "pulse by gender" Is there a way to extract the dataset (in this case "questionnaire")? 回答1: There is no way that you could extract the data from the list of the output of t.test(). The code for the components of the output of t.test() is this: rval <- list(statistic = tstat, parameter

Tableau error “All Fields must be aggregate or constant” when invoking TabPy SCRIPT_REAL

主宰稳场 提交于 2020-02-23 08:17:08
问题 I am calling a TabPy server via a calculated field in a Tableau worksheet to run a hypothesis test: does the rate of Bookings vary significantly by Group? I have a table such as: Group Bookings 0 A 1 1 A 0 3998 B 1 3999 B 0 In Python, on the same server (using the python 2.7 docker image) the test I want is simply: from scipy.stats import fisher_exact df_cont_tbl = pd.crosstab(df['Group'], df['Bookings']) prop_test = fisher_exact(df_cont_tbl) print 'Fisher exact test: Odds ratio = {:.2f}, p

doing t.test for columns for each row in data set

十年热恋 提交于 2019-12-23 03:12:48
问题 I have a set of data x which consists of 12 columns and 167 rows. The first column is compound Id for each row. I want to run a t.test for 3 column as one group and the other 3 groups as the second group, separately for each row. My code is as below but it does not work. for (i in 1:nrow(x)) { function(i)c(compound=i, t.test(x[2:4],x[8:10], x[x$compound==i, ], alternative='two.sided',conf.level=0.95) ) } print(c(compound=i,t.test(x[2:4],x[8:10],x[x$compound==i,], alternative='two.sided',conf

Testing the equality of multiple coefficients in R

不想你离开。 提交于 2019-12-22 00:26:24
问题 I have the following model: y = b1_group1*X1 + b1_group2*X1 + b2_group1*X2 + b2_group2*X2 + ... + b10_group1*X10 + b10_group2*X10 Easily made in R as follows: OLS <- lm(Y ~ t1:Group + t2:Group + t3:Group + t4:Group + t5:Group + t6:Group + t7:Group + t8:Group + t9:Group + t10:Group,weights = weight, Alldata) In STATA, I can now do the following test: test (b1_group1=b1_group2) (b2_group1=b2_group2) (b3_group1=b3_group2) b1_group1 - b1_group2 = 0 b2_group1 - b2_group2 = 0 b3_group1 - b3_group2

Error with t-test

余生长醉 提交于 2019-12-11 16:44:55
问题 I'm having errors with the normal t-test: data <- read.table("/Users/vdas/Documents/RNA-Seq_Smaples_Udine_08032013/GBM_29052013/UD_RP_25072013/filteredFPKM_matrix.txt",sep="",header=TRUE,stringsAsFactors=FALSE) PGT <- cbind(data[,2],data[,7],data[,24]) PDGT <- cbind(data[,6],data[,8]) pval2 <- NULL for(i in 1:length(PGT[,1])){ pval2 <- c(pval2,t.test(as.numeric(PDGT[i,]),as.numeric(PGT[i,]))$p.value) print(i) } Error: Error in t.test.default(as.numeric(PDGT[i, ]), as.numeric(PGT[i, ])) : not