 # Grouping variables for t-test

Hello everyone!

I want to conduct a paired t-test for one variable (number of inventions) only for the TG at time points 1 (T1) and time point two (T2).

I’ve divided into training group (TG), control group (CG) (and one goup of something in between which I will not take into account for my calculations) based on the number of sessions in which the students have participated:
group_control <- ug123\$train_a == 0
group_train <- ug123\$train_a >= 5
group_none <- ug123\$train_a > 0 & ug123\$train_a < 5

For the first t-test I want to compare the number of early inventions in T1 and T2 only fot the trainings group.
How can I compute a variable for this?
Does it make sense to put the group into brackets [group_train] like the following:
t.test(ug123\$t1_inventions[group_train], ug123\$ t2_inventions[group_train], paired = T) ?

I’m thankful for any recommendations!

Svenja (R beginner)

It looks perfectly fine and should give you the output you want (i.e paired t-test on the students who have `train_a>=5`)

Just make sure you're doing the appropriate assumption tests before this, e.g. `shapiro.test()` to establish whether the data is normally distributed and `bartlett.test()` to check the variances are equal in each group. If `shapiro.test()` implies non-Normal, switch to `wilcox.test()` instead of `t.test()`. If Bartlett's test returns non-equal variances, then you can still use a `t.test()`, but you needed to set `var.equal = F` as an argument when you run it.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

Thank you! That was really helpful!
I'll try to conduct the tests for normal distribution and equal variances, too now, Thanks! 