r - Get Index of variables from stepAIC -
i regressing gene on gene subset. use stepaic reduce number of explanatory genes. how index of non-omitted variables, analyse them?
gene_subset=c(y=genes[,i], genes[,other_genes]); reduced_model=stepaic(y~.,data=gene_subset,trace=false);
here 1 solution got r-help mail list, other more efficient ways welcome.
# create example data frame y <- rnorm(30) gene_subset <- data.frame(y, x1=rnorm(30), x2=rnorm(30), x3=100*y+rnorm(30)) # fit full linear model fit <- lm(y ~ ., df) # reduce model reduced_model <- stepaic(fit, trace=false) # non-omitted variables (excluding response) keepx <- names(reduced_model$model)[-1] index <- match(keepx, names(gene_subset))
Comments
Post a Comment