Hello! I am using R 2.5.1 on a Apple Power Book G4 with Mac OS X 10.4.10 and I am still R beginner. I try to calculate a t.test() using this code: TTest75<-t.test(Fem75, Mal75, alternative= "two.sided", paired= TRUE) This works properly, but I have two variables with a lot of missing data and therefore get the error message: TTest66<-t.test(Fem66, Mal66, alternative= "two.sided", paired= TRUE) Fehler in var(x) : 'x' ist leer One of the two vectors looks like this: [1] 5.0 NA 4.5 6.0 0.8 NA 7.0 4.5 NA NA NA NA 5.0 NA 6.0 NA 5.0 NA 5.0 8.0 NA NA NA 8.0 NA 8.0 5.0 NA NA NA NA 8.0 NA 1.0 [35] NA NA NA NA NA NA 5.0 NA 4.0 8.0 NA 6.0 6.0 4.5 3.5 NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA [69] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA [103] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA [137] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA [171] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA [205] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA [239] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA [273] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA [307] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA [341] NA NA NA NA NA NA NA NA Is it possible to run a TTest inspite of all the missing data? I really need two know if may two vectors are significantly different. (If this results are then reliable is an other question) By the way is there a better possibility (and I guess there is) to save or export the t.test() results as textfile? Thanks in advance for your help. Greetings Birgit Birgit Lemcke Institut für Systematische Botanik Zollikerstrasse 107 CH-8008 Zürich Switzerland Ph: +41 (0)44 634 8351 birgit.lemcke@systbot.uzh.ch [[alternative HTML version deleted]]
Birgit Lemcke wrote:> Hello! > > I am using R 2.5.1 on a Apple Power Book G4 with Mac OS X 10.4.10 and > I am still R beginner. > > I try to calculate a t.test() using this code: > > TTest75<-t.test(Fem75, Mal75, alternative= "two.sided", paired= TRUE) > > This works properly, but I have two variables with a lot of missing > data and therefore get the error message: > > TTest66<-t.test(Fem66, Mal66, alternative= "two.sided", paired= TRUE) > Fehler in var(x) : 'x' ist leer > > One of the two vectors looks like this: > > [1] 5.0 NA 4.5 6.0 0.8 NA 7.0 4.5 NA NA NA NA 5.0 NA 6.0 NA > 5.0 NA 5.0 8.0 NA NA NA 8.0 NA 8.0 5.0 NA NA NA NA 8.0 NA 1.0 > [35] NA NA NA NA NA NA 5.0 NA 4.0 8.0 NA 6.0 6.0 4.5 3.5 NA > NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA > [69] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA .... >> Is it possible to run a TTest inspite of all the missing data? > I really need two know if may two vectors are significantly > different. (If this results are then reliable is an other question) >Well, you're not showing the other one, but I have a hunch that any(complete.cases(Fem66, Mal66)) will come out false, in which case you don't have paired data and might get rid of paired=TRUE and have an ordinary two sample test. (BTW paired data for females and males? Couples?)> By the way is there a better possibility (and I guess there is) to > save or export the t.test() results as textfile? > > Thanks in advance for your help. > > Greetings > > Birgit > > Birgit Lemcke > Institut f?r Systematische Botanik > Zollikerstrasse 107 > CH-8008 Z?rich > Switzerland > Ph: +41 (0)44 634 8351 > birgit.lemcke at systbot.uzh.ch > > > > > > > [[alternative HTML version deleted]] > > > ------------------------------------------------------------------------ > > ______________________________________________ > R-help at r-project.org mailing list > 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. >-- O__ ---- Peter Dalgaard ?ster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
>>> Peter Dalgaard <P.Dalgaard at biostat.ku.dk> 14/09/2007 09:26:16 >>> >> So what can I do now to solve my problem? >> >> Do you think I should not use paired=TRUE? >You *can* only use it when you have pairs, and you must do it then, to >correct for intra-pair correlation. The drawback is that it looks only >at complete pairs, throwing away all the singlets. It is possible to >recover the information from the singlets , basically by combining a >paired test for the pairs and an unpaired one for the singlets. (Someone >must have written this down, but I'm afraid I don't have a nice reference).Question: Could you achieve this kind of outcome with lme? stack the two groups, mark the observations y by subject (ie the pair ID) and group (treatment, presumably), and do something like anova(lme(y~group, data=d, random=~1|subj, na.action=na.omit)) Or is that just disguising one of those nasty unbalanced 2-way anova problems? ******************************************************************* This email and any attachments are confidential. Any use, co...{{dropped}}
S Ellison wrote:> >>>> Peter Dalgaard <P.Dalgaard at biostat.ku.dk> 14/09/2007 09:26:16 >>> >>>> >>> So what can I do now to solve my problem? >>> >>> Do you think I should not use paired=TRUE? >>> >> You *can* only use it when you have pairs, and you must do it then, to >> correct for intra-pair correlation. The drawback is that it looks only >> at complete pairs, throwing away all the singlets. It is possible to >> recover the information from the singlets , basically by combining a >> paired test for the pairs and an unpaired one for the singlets. (Someone >> must have written this down, but I'm afraid I don't have a nice reference). >> > > Question: Could you achieve this kind of outcome with lme? stack the two groups, mark the observations y by subject (ie the pair ID) and group (treatment, presumably), and do something like > > anova(lme(y~group, data=d, random=~1|subj, na.action=na.omit)) > > Or is that just disguising one of those nasty unbalanced 2-way anova problems? >Yes, but.... I don't think lme() will do better than what you can do by hand: Get two independent estimates of mu1-mu2 (one estimate from the pairs and one from the singlets), compute a weighted average using the s.e.'s and test that against zero (possibly after testing them for equality for good measure). This is easy if you use a plug-in approach: first assume that the s.e. are known, then plug in their empirical value. The tricky bit is to calculate the DF in the style of Welch's test. -- O__ ---- Peter Dalgaard ?ster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907