Skip to content

Commit

Permalink
vignette few changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Bruder committed Nov 24, 2023
1 parent 5f42b42 commit 93f7b12
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
6 changes: 4 additions & 2 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
destination: docs

url: https://kkmann.github.io/adoptr
url: https://imbi-heidelberg.github.io/adoptr

navbar:
left:
Expand All @@ -20,13 +20,15 @@ navbar:
href: articles/composite-scores.html
- text: Definining New Scores
href: articles/defining-new-scores.html
- text: Non-normal endpoints
href: articles/other-endpoints.html
- text: Changelog
href: news/index.html
- text: Reference
href: reference/index.html
right:
- icon: fa-github fa-lg
href: https://github.com/kkmann/adoptr
href: https://github.com/imbi-heidelberg/adoptr

template:
params:
Expand Down
24 changes: 14 additions & 10 deletions vignettes/other-endpoints.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: "Designs for non-normal Endpoints with approximately normal test statistics"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{Using other endpoints}
%\VignetteIndexEntry{Designs for non-normal Endpoints with approximately normal test statistics}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
Expand Down Expand Up @@ -115,7 +115,9 @@ datadist <- Binomial(0.3, two_armed = TRUE)
Let us furthermore postulate a normal prior distribution for $\theta$ with expectation $\mu=0.2$ and standard deviation $\sigma=0.2$, which was truncated to the interval $(-.29,0.69)$. It is necessary to use a truncation to ensure that $p_T \in (0,1)$.
```{r}
H_0 <- PointMassPrior(.0, 1)
prior <- ContinuousPrior(function(x) 1/(pnorm(0.69,0.2,0.2)-pnorm(-0.29,0.2,0.2))*dnorm(x,0.2,0.2),
prior <- ContinuousPrior(function(x) 1 / (pnorm(0.69, 0.2, 0.2) -
pnorm(-0.29, 0.2, 0.2)) *
dnorm(x, 0.2, 0.2),
support = c(-0.29,0.69),
tighten_support = TRUE)
```
Expand All @@ -138,7 +140,8 @@ ess <- ExpectedSampleSize(datadist,prior)
init <- get_initial_design(0.2,0.025,0.2)
opt_design <- minimize(ess,subject_to(toer_cnstr,epow_cnstr),initial_design = init, check_constraints = TRUE)
opt_design <- minimize(ess,subject_to(toer_cnstr,epow_cnstr),
initial_design = init, check_constraints = TRUE)
plot(opt_design$design)
```
Expand Down Expand Up @@ -320,24 +323,25 @@ hazard ratio. For our example, we assume $\theta=1$ for the null hypothesis,
and a point alternative hypothesis of $\theta=1.7$.

```{r}
H_0 <- PointMassPrior(1,1)
H_1 <- PointMassPrior(1.7,1)
H_0 <- PointMassPrior(1, 1)
H_1 <- PointMassPrior(1.7, 1)
```

Our desired design should have a maximal type I error $\alpha\leq 0.025$ and a minimum power of $(1-\beta)\geq 0.8$.

```{r}
alpha <- 0.025
min_power <- 0.8
toer_con <- Power(datadist,H_0)<=alpha
pow_con <- Power(datadist,H_1)>=min_power
toer_con <- Power(datadist,H_0) <= alpha
pow_con <- Power(datadist,H_1) >= min_power
```


```{r}
exp_no_events <- ExpectedNumberOfEvents(datadist,H_1)
init <- get_initial_design(1.7,0.025,0.2,dist=datadist)
opt_survival <- minimize(exp_no_events,subject_to(toer_con,pow_con),initial_design = init,check_constraints=TRUE)
exp_no_events <- ExpectedNumberOfEvents(datadist, H_1)
init <- get_initial_design(1.7, 0.025, 0.2, dist=datadist)
opt_survival <- minimize(exp_no_events, subject_to(toer_con,pow_con),
initial_design = init, check_constraints=TRUE)
summary(opt_survival$design)
```
Expand Down

0 comments on commit 93f7b12

Please sign in to comment.