Here's one way to do it ... # create example data frame y <- rnorm(30) gene_subset <- data.frame(y, x1=rnorm(30), x2=rnorm(30), x3=100*y+rnorm(30))
# fit a full linear model fit <- lm(y ~ ., df) # reduce the model reduced_model <- stepAIC(fit, trace=FALSE) # NON-omitted variables (excluding the response) keepx <- names(reduced_model$model)[-1] index <- match(keepx, names(gene_subset)) Jean On Mon, Aug 26, 2013 at 12:51 AM, Sachinthaka Abeywardana < sachin.abeyward...@gmail.com> wrote: > I am regressing a gene on another gene subset. Then I use stepAIC to reduce > the number of explanatory genes. How do I get the index of the NON-omitted > variables, so that I could analyse them? > > gene_subset=c(y=genes[,i], genes[,other_genes]); > reduced_model=stepAIC(y~.,data=gene_subset,trace=false); > > [[alternative HTML version deleted]] > > ______________________________________________ > 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. > [[alternative HTML version deleted]] ______________________________________________ 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.