Hi,
nvars <- 902 data <- as.data.frame(matrix(runif(100*nvars),ncol=nvars)) colnames(data)[901] <- c('phenotype') colnames(data)[902] <- c('outcome') ### catch all aic values ### res <- matrix(nrow=900,ncol=2) for (i in 1:(length(data)-2)) { res[i,1] <- names(data)[i] res[i,2] <- glm(outcome~data[,i]*phenotype, data=data)$aic } res
Dear R users, Could you help my with the following problem? I want to repeat a glm analysis with 2 independent variables for all 900 variables (snps) in my data set. So, I want to check whether snp1 has a different effect on my outcome variable in patients and controls(phenotype). And repeat that for snp2 to snp900. Is there an easy way to get a summary of the data, e.g. a list of P values of all 900 variables? I tried something with a loop: for (i in 1:length(data)) { print (summary (glm (outcome~data[[i]]*phenotype, data=data))) } # This works, but gives 900 written summaries for (i in 1:length(data)) { coef (summary (glm (outcome~data[[i]]*phenotype, data=data))) } # changing print to coef gives no output for (i in 1:length(data)) { glm.data <- glm (outcome~data[[i]]*phenotype, data=data)) } summary (glm.data) # gives only output of the last variable for (i in 1:length(data)) { glm.data[[i]] <- glm (outcome~data[[i]]*phenotype, data=data)) } summary (glm.data[[i]]) # gives only output of the last variable Or should I use tapply or something like that? In what way? Thanks! Afke Terwisscha email: aterw...@umcutrecht.nl <mailto:aterw...@umcutrecht.nl> ------------------------------------------------------------------------------ De informatie opgenomen in dit bericht kan vertrouwelijk zijn en is uitsluitend bestemd voor de geadresseerde. Indien u dit bericht onterecht ontvangt, wordt u verzocht de inhoud niet te gebruiken en de afzender direct te informeren door het bericht te retourneren. Het Universitair Medisch Centrum Utrecht is een publiekrechtelijke rechtspersoon in de zin van de W.H.W. (Wet Hoger Onderwijs en Wetenschappelijk Onderzoek) en staat geregistreerd bij de Kamer van Koophandel voor Midden-Nederland onder nr. 30244197. Denk s.v.p aan het milieu voor u deze e-mail afdrukt. ------------------------------------------------------------------------------ This message may contain confidential information and is...{{dropped:14}} ______________________________________________ R-help@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.
______________________________________________ R-help@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.