Created
November 6, 2015 14:39
-
-
Save mbannert/d0863cf8a98f758a5bc8 to your computer and use it in GitHub Desktop.
made up example list wise PCA with AIC
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# just an implementation example that does not make a whole lot of sense... | |
library(MASS) | |
y <- mtcars$mpg | |
ll <- list(cars1 = mtcars[,-1], cars2 = mtcars[,-1]*100) | |
out_put_list <- lapply(ll,function(x){ | |
pca <- prcomp(x,scale.=T) | |
pca_scores <- as.data.frame(pca$x) | |
# maybe give back the result and do it | |
# multiple dfs | |
fit1 <- lm(y ~ .,data =pca_scores) | |
best_model <- stepAIC(fit1) | |
best_model | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment