## ----knitr_init, echo=FALSE, cache=FALSE, warning=FALSE, message=FALSE--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
options(knitr.table.format = "html")
options(max.print=100, scipen=999, width = 800)
knitr::opts_chunk$set(echo=FALSE,
cache=FALSE,
prompt=FALSE,
eval = TRUE,
tidy=TRUE,
root.dir = "..",
fig.height = 8,
fig.width = 20,
comment=NA,
message=FALSE,
warning=FALSE)
knitr::opts_knit$set(width=100, figr.prefix = T, figr.link = T)
knitr::knit_hooks$set(inline = function(x) {
prettyNum(x, big.mark=",")
})
## ----load-libraries-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
library(BAS)
library(broom)
library(caret)
library(corrplot)
library(data.table)
library(dplyr)
library(extrafont)
library(ggplot2)
library(graphics)
library(gridExtra)
library(reshape2)
library(statsr)
library(vcd)
## ----source-functions---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
source("../R/bestPredictions.R")
source("../R/bma.R")
source("../R/bmaAnalysis.R")
source("../R/bmaComplexity.R")
source("../R/bmaEvaluation.R")
source("../R/bmaPerformance.R")
source("../R/bmaPerformanceReport.R")
source("../R/bmaImage.R")
source("../R/bmaPredict.R")
source("../R/bmaPredictModels.R")
source("../R/bmaPDC.R")
source("../R/bmaPIP.R")
source("../R/bmaPIPPlots.R")
source("../R/corrAssociation.R")
source("../R/preprocess.R")
source("../R/univariate.R")
source("../R/univariateQual.R")
source("../R/univariateQuant.R")
source("../R/bivariate.R")
source("../R/bivariateQual.R")
source("../R/bivariateQuant.R")
source("../R/visualization.R")
source("../R/analysis.R")
## ----set_run------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
run <- TRUE
if (run == FALSE) {
load("./analysis/yX.Rdata")
load("./analysis/processedData.Rdata")
load("./analysis/models.Rdata")
load("./analysis/analysis.Rdata")
load("./analysis/report.Rdata")
load("./analysis/eval.Rdata")
load("./analysis/performance.Rdata")
}
dir.create("./analysis", showWarnings = FALSE)
## ----load-data----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
load("../inst/extdata/movies.RData")
## ----preprocess---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
processedData <- preprocess(movies)
save(processedData, file = "./analysis/processedData.Rdata")
## ----univariate---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
edaUni <- univariate(data = processedData)
## ----bivariate----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
edaBi <- bivariate(data = processedData)
## ----removetitle--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
if (run == TRUE) {
yX <- processedData %>% select(-title)
save(yX, file = "./analysis/yX.Rdata")
}
## ----bma----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
if (isTRUE(run)) {
models <- bma(yX = yX)
save(models, file = "./analysis/models.Rdata")
}
## ----bmaAnalysis--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
analysis <- bmaAnalysis(models = models)
save(analysis, file = "./analysis/analysis.Rdata")
## ----bmaPerformance-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
trials <- 5
if (run == TRUE) {
performance <- bmaPerformance(yX, trials = trials)
save(performance, file = "./analysis/performance.Rdata")
}
## ----bmaPerformanceReport-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
if (isTRUE(run)) {
report <- bmaPerformanceReport(performance = performance)
save(report, file = "./analysis/report.Rdata")
}
## ----bmaEval------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
if (isTRUE(run)) {
eval <- bmaEvaluation(mList = models, candidates = report$best)
save(eval, file = "./analysis/eval.Rdata")
}
## ----bestPredictions----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
cases <- read.csv(file = "../inst/extdata/movies2predict.csv", stringsAsFactors = FALSE)
predictions <- bestPredictions(best = report$best[c(1:4),], models = models, newdata = cases)
save(predictions, file = "./analysis/predictions.Rdata")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.