Determine or test signficance for certain levels in a variable using r

86 views Asked by At

In this dataset, I mainly have one dependent variable (Reaction Time) and two independent variables (Prime Type (5 levels) and Related (2 levels)). I wanted to see the Reaction Time (RT) significance of Related for each Prime Type level. For example, how significantly related (level 1) condition differ from the unrelated (level 2) for PrimeType 2. One of the basic ways I tried to do this is with t.test, but was only able to run it as the following code (Related for all PrimeType):

t.test(RT~Related, alternative='two.sided', conf.level=.95, var.equal=FALSE,
  data=mydata)

How should I write the code for R to only look at PrimeType 2 with regard to the Related variable?


@BenBolker -- Thank you for your comment. How is the following output should be interpreted? and are the Prime types are compared to an intercept? what is it?

> lm3 <- lmList(RT~Related|PrimeType, mydata)
> summary(lm3)
Call:
Coefficients:
(Intercept) 
    Estimate Std. Error   t value Pr(>|t|)
1 690.2596   6.255575 110.34311        0
2 677.0929   6.673277 101.46332        0
 ....
Related1 
Estimate Std. Error    t value     Pr(>|t|)
1 -13.307825   9.146849 -1.4549081 1.457611e-01
2   1.408043   9.483289  0.1484763 8.819733e-01
3  -7.737740   9.518978 -0.8128750 4.163306e-01
....
1

There are 1 answers

1
Sven Hohenstein On BEST ANSWER

You can create a subset of your data

subset(mydata, PrimeType == 2)

for the t.test function:

t.test(RT ~ Related, alternative='two.sided', conf.level=.95, var.equal=FALSE, 
       data = subset(mydata, PrimeType == 2))