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]]
Hi, Joel, I think, according to the help page of mi.t.test, mi.t.test(implist, x = "pre_test", y = "post_test", alternative = "greater", paired = TRUE, var.equal = TRUE, conf.level = 0.95) should do it (untested). Hth -- Gerrit --------------------------------------------------------------------- Dr. Gerrit Eichner Mathematical Institute, Room 212 gerrit.eichner at math.uni-giessen.de Justus-Liebig-University Giessen Tel: +49-(0)641-99-32104 Arndtstr. 2, 35392 Giessen, Germany Fax: +49-(0)641-99-32109 http://www.uni-giessen.de/eichner --------------------------------------------------------------------- Am 06.04.2017 um 18:32 schrieb Joel Gagnon:> 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]] > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >
Dear Joel, are you trying to apply function mi.t.test from my package MKmisc? Could you please try: mi.t.test(implist, "pre_test", "post_test", alternative "greater", paired = TRUE, var.equal = TRUE, conf.level = 0.95) x and y are the names of the variables, not the variables themselves. Best Matthias Am 06.04.2017 um 18:32 schrieb Joel Gagnon:> 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]] > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >-- Prof. Dr. Matthias Kohl www.stamats.de
Dear Dr. Eichner and Dr. Kohl, First, thank you for your response. I tried your code and R it worked perfectly I just had to add: mi.t.test(implist*$imputation,* "pre_test", "post_test", alternative = "greater", paired = TRUE, var.equal = TRUE, conf.level = 0.95) for the code to run. Thank you very much again for taking the time. Best, Joel On Fri, Apr 7, 2017 at 3:26 PM, Prof. Dr. Matthias Kohl < Matthias.Kohl at stamats.de> wrote:> Dear Joel, > > are you trying to apply function mi.t.test from my package MKmisc? > > Could you please try: > mi.t.test(implist, "pre_test", "post_test", alternative > "greater", paired = TRUE, var.equal = TRUE, conf.level = 0.95) > > x and y are the names of the variables, not the variables themselves. > > Best > Matthias > > Am 06.04.2017 um 18:32 schrieb Joel Gagnon: > >> 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]] >> >> ______________________________________________ >> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide http://www.R-project.org/posti >> ng-guide.html >> and provide commented, minimal, self-contained, reproducible code. >> >> > -- > Prof. Dr. Matthias Kohl > www.stamats.de >[[alternative HTML version deleted]]