anders superanders
2005-Nov-29 19:51 UTC
[R] permutation test for linear models with continuous covariates
Hi I was wondering if there is a permutation test available in R for linear models with continuous dependent covariates. I want to do a test like the one shown here. bmi<-rnorm(100,25) x<-c(rep(0,75),rep(1,25)) y<-rnorm(100)+bmi^(1/2)+rnorm(100,2)*x+bmi*x H0<-lm(y~1+x+bmi) H1<-lm(y~1+x+bmi+x*bmi) anova(H0,H1) summary(lm(y~1+x+bmi)) But I want to use permutation testing to avoid an inflated p-value due to a y that is not totally normal distributed and I do not want to log transform y. Thanks Anders
Peter Dalgaard
2005-Nov-30 14:11 UTC
[R] permutation test for linear models with continuous covariates
"anders superanders" <andersdetermigigen at hotmail.com> writes:> Hi I was wondering if there is a permutation test available in R for linear > models with continuous dependent covariates. I want to do a test like the > one shown here. > > bmi<-rnorm(100,25) > x<-c(rep(0,75),rep(1,25)) > y<-rnorm(100)+bmi^(1/2)+rnorm(100,2)*x+bmi*x > > H0<-lm(y~1+x+bmi) > H1<-lm(y~1+x+bmi+x*bmi) > anova(H0,H1) > summary(lm(y~1+x+bmi)) > > > But I want to use permutation testing to avoid an inflated p-value due to a > y that is not totally normal distributed and I do not want to log transform > y.Er, what would you permute? For an interaction test like this (notice by the way that "*" in your model formula does not mean what you think it does) I do not think a permutation test exists. You could try bootstrapping to get an improved approximation the distribution of the interaction term. -- 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
Tim Hesterberg
2005-Dec-12 19:52 UTC
[R] permutation test for linear models with continuous covariates
What do you want to test? To test H0: Y is independent of all X's, you can permute Y. To test H0: a particular X does not contribute to predicting Y, conditional on the other X's you have to be careful. If you permute that X, the size is wrong; the type I error can be nearly 50%, because you've lost the correlation between that X and others. I don't know of a suitable permutation test in general for testing individual X's. S+Resample has a permutationTest() function that lets you specify which columns to permute. The Canty/Davison/Hinkley "boot" library (in R or S-PLUS) offers "permutation" as one of the options for sampling in the boot() function; to use this you would specify the Y variable as the data set and pass the X's separately to the statistic. Tim Hesterberg>Hi I was wondering if there is a permutation test available in R for linear >models with continuous dependent covariates. I want to do a test like the >one shown here. > >bmi<-rnorm(100,25) >x<-c(rep(0,75),rep(1,25)) >y<-rnorm(100)+bmi^(1/2)+rnorm(100,2)*x+bmi*x > >H0<-lm(y~1+x+bmi) >H1<-lm(y~1+x+bmi+x*bmi) >anova(H0,H1) >summary(lm(y~1+x+bmi)) > > >But I want to use permutation testing to avoid an inflated p-value due to a >y that is not totally normal distributed and I do not want to log transform >y. > >Thanks > >Anders=======================================================| Tim Hesterberg Research Scientist | | timh at insightful.com Insightful Corp. | | (206)802-2319 1700 Westlake Ave. N, Suite 500 | | (206)283-8691 (fax) Seattle, WA 98109-3012, U.S.A. | | www.insightful.com/Hesterberg | =======================================================Download the S+Resample library from www.insightful.com/downloads/libraries Two Research Scientist positions: data mining frailty/mixed effects http://www.insightful.com/company/jobs.asp Speak out about biased science in Washington D.C. http://home.comcast.net/~timhesterberg/ScientificIntegrity.html