t-test

T-test using two dfs in R

霸气de小男生 提交于 2021-02-11 17:43:02
问题 I am trying to run a t-test to determine if a column in one df is significantly different from a column in another df. I have two dfs, "block 1" and "block 2". I have tried this code: t.test(block1$Duration ~ block2$Duration, paired=FALSE, var.equal=TRUE) And I received this error message: Error in t.test.formula(block1$Duration ~ block2$Duration, paired = FALSE, : grouping factor must have exactly 2 levels Any insight into what I'm doing wrong is appreciated! 来源: https://stackoverflow.com

Testing whether the regression coefficient is significantly less than 1 (one-tailed t-test)

家住魔仙堡 提交于 2021-01-29 09:05:52
问题 I performed a simple linear regression and using summary() I get the result of a two-tailed t-test testing whether the regression coefficient is significantly different from 0. lmb <- lm(logspec ~ logfreq) I would like to perform a one-tailed t-test testing whether the regression coefficient is less than 1. I read in previous threads about the use of offset() to set the comparison value different from 0 but I am not sure if it does what I would like to see happen: t <- lm(logspec ~ logfreq +

How to perform a paired t-test in R when all the values are in one column?

浪子不回头ぞ 提交于 2021-01-29 04:06:09
问题 The common format of a data frame for peforming a Paired t-test in R is a given measurement divided in two columns, so that each row indicates a same subject or individual. For example: > # Before After > #1 31 32 > #2 22 34 > #3 41 35 However, this is not always the case in which the data are presented in a data frame. I have a data frame which structure is very common and looks like this: subject <- c("A1", "A2" ,"A1" ,"A3" ,"A3" ,"A2") value <- c(34, 43, 25, 43, 54, 22) group <- c("before"

One sample T-TEST IN R within groups [duplicate]

 ̄綄美尐妖づ 提交于 2020-01-15 09:21:07
问题 This question already has answers here : Perform multiple paired t-tests based on groups/categories (2 answers) Closed 2 years ago . I have been doing one sample t-tests in R but today I have got one big challenge. I have data grouped in by one variable and I want to perform a one sample t-test per group. I can do this perfectly well in SPSS but it's now a headache in R, whoever knows how to do this to assist.Sample scenario Location=rep(c("Area_A","Area_B"),4) temp=rnorm(length(Location),34

paired t-test with pairs and groups defined in another dataframe

本小妞迷上赌 提交于 2020-01-07 02:54:09
问题 I have a dataframe which looks like this > head(data) LH3003 LH3004 LH3005 LH3006 LH3007 LH3008 LH3009 LH3010 LH3011 cg18478105 0.02329879 0.08103364 0.01611778 0.01691191 0.01886975 0.01885553 0.01647439 0.02120779 0.01168622 cg14361672 0.09479536 0.07821380 0.02522833 0.06467310 0.05387729 0.05866673 0.08121820 0.10920162 0.04413263 cg01763666 0.03625680 0.04633759 0.04401555 0.08371531 0.09866403 0.17611284 0.07306743 0.12422579 0.11125146 cg02115394 0.10014794 0.09274320 0.08743445 0

One sided t-test for linear regression?

偶尔善良 提交于 2019-12-23 04:26:40
问题 I have problems with this. I am trying to do a linear regression and test the slope. The t-test checks if the slope is far away from 0. The slope can be negative or positive. I am only interested in negative slopes. In this example, the slope is positive which I am not interested in, so the P value should be large. But it is small because right now it tests if the slope is far away from 0, in either direction. (I am forcing an intercept of zero, which is what I want). Can someone help me with

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

How to calculate (statistical) power function vs. sample size in python?

不羁岁月 提交于 2019-12-21 06:12:49
问题 How can this be done in python? Calculate sample size for a given power and alpha? Calculate power for a given sample size and alpha? Note: I am totally confused :( with the functions that python gives for (statistical) power function calculation. Can someone help me to make an order here? There are two functions under statsmodels: from statsmodels.stats.power import ttest_power, tt_ind_solve_power() We have: tt_ind_solve_power(effect_size=effect_size, alpha=alpha, power=0.8, ratio=1,