0

The following error is put out when I want to perform a paired t-test:

t.test(materix_first_timepoint[,1], materix_second_timepoint[0,1], paired=TRUE)

Error in complete.cases(x, y) : not all arguments have the same length

This is the str of my matrices:

str(materix_first_timepoint)
 num [1:35, 1:4] 23.28 12 3.81 28.63 10.25 ...
 - attr(*, "dimnames")=List of 2
  ..$ : NULL
  ..$ : chr [1:4] "1 hour" "2 hours" "3 hours" "4 hours"

 str(materix_second_timepoint)
 num [1:35, 1:4] 13.9 25.5 17.8 18.9 22.7 ...
 - attr(*, "dimnames")=List of 2
  ..$ : NULL
  ..$ : chr [1:4] "1 hour" "2 hours" "3 hours" "4 hours"

If I perform a t-test with paired=FALSE it works. I do not understand what going wrong.

NelsonGon
  • 13,015
  • 7
  • 27
  • 57
ghs101
  • 103
  • 6
  • Could you check `length(materix_first_timepoint[,1])`, and `length(materix_second_timepoint[0,1])`? See what you get – Zhiqiang Wang Nov 18 '19 at 07:05
  • I think you should think back to the statistics behind what you're doing i.e what do you think `paired` is used for? It is important to know what the argument is supposed to do and use it according to known theory. The lengths need to be the same because according to [the theory](http://www.statstutor.ac.uk/resources/uploaded/paired-t-test.pdf), you need to "pair" the observations. – NelsonGon Nov 18 '19 at 07:27

1 Answers1

2

Basically, you are trying to compare one column of the first matrix (materix_first_timepoint[,1]) with 0 values in the materix_second_timepoint[0,1], so it can't work.

Instead try t.test(materix_first_timepoint[,1], materix_second_timepoint[,1], paired = T).

dc37
  • 15,840
  • 4
  • 15
  • 32