[R] Paired sample t-test with mi.t.test
Joel Gagnon
gagnonjoel24 at gmail.com
Thu Apr 6 18:32:53 CEST 2017
Dear all,
It is my first time posting on this list so forgive me for any rookie
mistakes I could make.
I want to conduct t-tests on a dataset that has been imputed using the mice
package:
imput_pps <- mice(pps, m=20, maxit=20, meth='pmm') # pps is my dataset. It
contains items from an 11-item questionnaire gather at pre and post test.
So the data set has 22 columns.
I then proceed to compute the total scores for the pre and post test on my
imputed datasets:
long_pps <- complete(imput_pps, action ="long", include = TRUE)
long_pps$pre_test <- rowSums(long_pps[ ,c(3:13)])
long_pps$post_test <- rowSums(long_pps[ , c(14:24)])
I then used as.mids to convert back to mids object:
mids_pps <- as.mids(long_pps)
Next, I created an imputation list object using mitools:
implist <- lapply(seq(mids_pps$m), function(im) complete(mids_pps, im))
implist <- imputationList(implist)
Now, I want to conduct t-tests using the mi.t.test package. I tried the
following code:
mi.t.test(implist, implist$pre_test, implist$post_test, alternative =
"greater", paired = TRUE, var.equal = TRUE, conf.level = 0.95)
When I run this code, R tells me that Y is missing. I know this may sound
stupid, but I thought that I specified Y with this line: implist$pre_test,
implist$post_test - with implist$pre_test being X and implist$post_test
being Y - like I usually do for a normal t-test using the t.test function.
It seems I don't quite understand what the Y variable is supposed to
represent. Could someone help me figure out what I am doing wrong? You
help would be very much appreciated.
Best regards,
Joel Gagnon, Ph.D(c),
Department of Psychology,
Université du Québec à Trois-Rivières
Québec, Canada
[[alternative HTML version deleted]]
More information about the R-help
mailing list