Skip to content

Commit

Permalink
make code changes
Browse files Browse the repository at this point in the history
  • Loading branch information
rachaelvp committed May 3, 2022
1 parent 5540cd1 commit ae064d4
Show file tree
Hide file tree
Showing 9 changed files with 210 additions and 222 deletions.
2 changes: 1 addition & 1 deletion R_code/02-roadmap.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## ----simple-DAG---------------------------------------------------------------
## ----simple-DAG, out.width = "60%"--------------------------------------------
library(dagitty)
library(ggdag)

Expand Down
4 changes: 2 additions & 2 deletions R_code/03-tlverse.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@


## ----renviron-example, results="asis", eval=FALSE-----------------------------
## GITHUB_PAT=yourPAT
##
## GITHUB_PAT <- yourPAT

35 changes: 0 additions & 35 deletions R_code/04-data.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,38 +18,3 @@ if (knitr::is_latex_output()) {
skim(dat)
}


## ----load_ist_data_intro, message=FALSE, warning=FALSE------------------------
# read in data
ist <- read_csv(
paste0(
"https://raw.githubusercontent.com/tlverse/tlverse-handbook/master/",
"data/ist_sample.csv"
)
)


## ----skim_ist_data, results="asis", echo=FALSE--------------------------------
if (knitr::is_latex_output()) {
knitr::kable(skim_no_sparks(ist), format = "latex")
} else {
skim(ist)
}


## ----load_nhefs_data_intro----------------------------------------------------
# read in data
nhefs_data <- read_csv(
paste0(
"https://raw.githubusercontent.com/tlverse/tlverse-handbook/master/",
"data/NHEFS.csv"
)
)


## ----skim_nhefs_data, results="asis", echo=FALSE------------------------------
if (knitr::is_latex_output()) {
knitr::kable(skim_no_sparks(nhefs_data), format = "latex")
} else {
skim(nhefs_data)
}
12 changes: 7 additions & 5 deletions R_code/05-origami.R
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ t <- length(AP)


## ---- fig.cap="Rolling origin CV", results="asis", echo=FALSE-----------------
knitr::include_graphics(path = "img/image/rolling_origin.png")
knitr::include_graphics(path = "img/png/rolling_origin.png")


## ----rolling_origin-----------------------------------------------------------
Expand All @@ -86,7 +86,7 @@ folds[[2]]


## ---- fig.cap="Rolling window CV", results="asis", echo=FALSE-----------------
knitr::include_graphics(path = "img/image/rolling_window.png")
knitr::include_graphics(path = "img/png/rolling_window.png")


## ----rolling_window-----------------------------------------------------------
Expand All @@ -99,11 +99,11 @@ folds[[2]]


## ---- fig.cap="Rolling origin V-fold CV", results="asis", echo=FALSE----------
knitr::include_graphics(path = "img/image/rolling_origin_v_fold.png")
knitr::include_graphics(path = "img/png/rolling_origin_v_fold.png")


## ---- fig.cap="Rolling window V-fold CV", results="asis", echo=FALSE----------
knitr::include_graphics(path = "img/image/rolling_window_v_fold.png")
knitr::include_graphics(path = "img/png/rolling_window_v_fold.png")


## ----setup_ex-----------------------------------------------------------------
Expand Down Expand Up @@ -227,7 +227,8 @@ cv_rf <- function(fold, data, reg_form) {
# now, let's cross-validate...
folds <- make_folds(washb_data)
cvrf_results <- cross_validate(
cv_fun = cv_rf, folds = folds, data = washb_data, reg_form = "whz ~ .",
cv_fun = cv_rf, folds = folds,
data = washb_data, reg_form = "whz ~ .",
use_future = FALSE
)
mean(cvrf_results$SE)
Expand Down Expand Up @@ -300,3 +301,4 @@ mses <- cross_validate(
)
mses$mse
colMeans(mses$mse[, c("arima", "arima2")])

Loading

0 comments on commit ae064d4

Please sign in to comment.