Required packages for install (and their dependencies) MASS relaimpo Rcmdr quantreg BMA RegModel.1 = lm(depression~fatalism+simplicity, data=Ginzberg) summary(RegModel.1) #Variable Importance library(relaimpo) calc.relimp(RegModel.1, rela=TRUE) #Rela=T tells it to return the percentage of Rsq attributable to the predictor. I prefer this since I would be reporting a bias-adjusted Rsq not the original boot.import=boot.relimp(depression ~ fatalism + simplicity, data = Ginzberg, b=500) infer.import=booteval.relimp(boot.import, bty="bca") infer.import #Robust regression based on M-estimators library(MASS) RegModel.robust = rlm(depression~fatalism+simplicity, data=Ginzberg) summary(RegModel.robust) RegModel.robust$w #Polynomial regression. Tests the model dep predicted by fatalism + fatalism^2 RegModel.curve = lm(depression~poly(fatalism,degree=2), data=Ginzberg) summary(RegModel.curve) #Interaction (moderation) RegModel.moderate = lm(depression~fatalism+simplicity+fatalism:simplicity, data=Ginzberg) summary(RegModel.moderate) library(effects) plot(all.effects(RegModel.moderate), ask=FALSE) #this is Rcmdr code. Simply do it by menu though. #Quantile regression library(quantreg) RegModel.quant = rq(depression~fatalism+simplicity, tau=c(.1,.25,.5,.75,.9),data=Ginzberg) summary(RegModel.quant) plot(summary(RegModel.quant)) plot(summary(RegModel.quant), col=c("black","papayawhip")) #I don't like that default gray band #Bayesian Model Averaging. This will automatically dummy code factors also. library(BMA) world=read.table("http://www.unt.edu:8080/rss/class/mike/data/world.txt", header=T) #with world data, took out categorical predictors due to low N and redundant predictors (e.g. took out literacy for male and female, kept overall literacy), though some are highly correlated still. worldpred=world[,c(2:4,6,8:9,11,13,20:21)] aidsrate=world[,17] RegModel.bayes=bicreg(worldpred, aidsrate) summary(RegModel.bayes) imageplot.bma(RegModel.bayes) #Ridge regression library(MASS) RegModel.ridge = lm.ridge(depression~fatalism+simplicity, data=Ginzberg) RegModel.ridge$coef #Compare to original model #Lasso, a variation on the Ridge theme. Don't ask, I just know about it but few details. Requires data to be in matrix/vector rather than data frame form. library(lars) x=matrix(c(Ginzberg$simplicity,Ginzberg$fatalism), ncol=2) RegModel.lasso=lars(x,Ginzberg$depression, type = "lasso") RegModel.lasso summary(RegModel.lasso) coef(RegModel.lasso)