Skip to content

Commit

Permalink
Updating for pkgdown
Browse files Browse the repository at this point in the history
  • Loading branch information
jwbowers committed Oct 14, 2024
1 parent 595e9b4 commit dc12608
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 6 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main]
pull_request:
branches: [main]
release:
types: [published]
workflow_dispatch:

name: pkgdown

permissions: read-all

jobs:
pkgdown:
runs-on: ubuntu-latest
# Only restrict concurrency for non-PR jobs
concurrency:
group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }}
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
permissions:
contents: write
steps:
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-pandoc@v2

- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::pkgdown, local::.
needs: website

- name: Build site
run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE)
shell: Rscript {0}

- name: Deploy to GitHub pages 🚀
if: github.event_name != 'pull_request'
uses: JamesIves/[email protected]
with:
clean: false
branch: gh-pages
folder: docs
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ Remotes:
LinkingTo: Rcpp, RcppArmadillo, RcppDist, Rfast
NeedsCompilation: yes
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.1
RoxygenNote: 7.3.2.9000
13 changes: 9 additions & 4 deletions R/padj_sim_fns.R
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ padj_test_fn <- function(idat, bdat, blockid, trtid = "trt", fmla = Y ~ trtF | b
bdatnew <- bdatnew[newcovb]
}

## Create potential outcome to treatment using a tau_fn and tau_size etc.
datnew$y1new <- create_effects(
idat = datnew, ybase = ybase, blockid = blockid,
tau_fn = tau_fn, tau_size = tau_size,
Expand Down Expand Up @@ -136,7 +137,8 @@ padj_test_fn <- function(idat, bdat, blockid, trtid = "trt", fmla = Y ~ trtF | b
#' @export
reveal_po_and_test <- function(idat, bdat, blockid, trtid, fmla = NULL, ybase, y1var,
prop_blocks_0, tau_fn, tau_size, pfn, p_adj_method = "fdr",
afn = NULL, splitfn = NULL, splitby = NULL, thealpha = .05, copydts = FALSE, stop_splitby_constant = FALSE, ncores = 1, return_details = FALSE) {
afn = NULL, splitfn = NULL, splitby = NULL, thealpha = .05, copydts = FALSE,
stop_splitby_constant = FALSE, ncores = 1, return_details = FALSE) {
stopifnot(is.null(splitfn) | splitfn == "NULL")
# make no effects within block by shuffling treatment, this is the engine of variability in the sim
idat[, newZ := sample(get(trtid)), by = blockid]
Expand Down Expand Up @@ -383,11 +385,11 @@ calc_errs <- function(testobj,

# This is calculated at the level of blocks not nodes.
deterrs <- detobj[, .(
nreject = sum(hitb),
nreject = sum(hitb), # number of rejected blocks
naccept = sum(1 - hitb),
prop_reject = mean(hitb),
prop_accept = mean(1 - hitb),
tot_true0 = sum(true0),
tot_true0 = sum(true0), # number of true 0 blocks.
tot_truenot0 = sum(truenot0),
tot_reject_true0 = sum(hitb * true0),
tot_not_reject_true0 = sum((1 - hitb) * true0),
Expand All @@ -397,9 +399,12 @@ calc_errs <- function(testobj,
# Proportion of the total blocks that have an effect where we detect that effect:
correct_pos_effect_prop = sum(hitb * truenot0) / max(1, sum(truenot0)),
correct_pos_nulls_prop = sum(hitb * true0) / max(1, sum(true0)),
## if hitb=1 (reject) and truenot0=1 then this is a correct rejection. Use in power calculations.
true_pos_prop = mean(hitb * truenot0),
## Proportion of rejections of a true null out of the total number of tests
false_pos_prop = mean(hitb * true0),
## if hitb=1 (meaning rejection) and true0=1 (meaning no true effect, true effect = 0) then a false positive
false_pos_prop = mean(hitb * true0), # number blocks rejected when truly 0 / total number of blocks.
# also sum(hitb*true0)/nrow(detobj)
# If we do not reject and all blocks are truly null, then we have no error.
prop_not_reject_true0 = mean((1 - hitb) * true0),
# If we do not reject/detect and at least one of the blocks actually has an effect, we have
Expand Down
5 changes: 4 additions & 1 deletion R/simulation_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,10 @@ tau_norm_outliers <- function(ybase, tau_sds, covariate) {
rnorm(n, mean = tau_sds * sd(ybase), sd = sd(ybase) / 2)
} else {
# 2 large outliers
c(rnorm(n - num_outliers, mean = sd(ybase) * tau_sds, sd = sd(ybase) / 2), rnorm(num_outliers, mean = sd(ybase) * tau_sds * 4, sd = sd(ybase) * 4))
c(
rnorm(n - num_outliers, mean = sd(ybase) * tau_sds, sd = sd(ybase) / 2),
rnorm(num_outliers, mean = sd(ybase) * tau_sds * 4, sd = sd(ybase) * 4)
)
}
}

Expand Down
4 changes: 4 additions & 0 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
url: ~
template:
bootstrap: 5

0 comments on commit dc12608

Please sign in to comment.