This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\newcommand{\pfn}{\text{pfn}} | |
\newcommand{\bset}{\mathcal{B}} | |
\newcommand{\splitfn}{\text{splitfn}} | |
\newcommand{\bZ}{\bm{Z}} | |
\newcommand{\bS}{\bm{S}} | |
\newcommand{\bz}{\bm{z}} | |
\newcommand{\bOne}{\bm{1}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import subprocess | |
import sys | |
import csv | |
# uses the GitPython module | |
import git | |
from pathlib import Path | |
## Notice need to install GitPython | |
## Recommended: | |
## python3 -m venv .venv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
library(DeclareDesign) | |
my_designer <- function(N, tau1, tau2) { | |
# N - total sample size | |
# tau1 - difference in proportion control versus "easy" message | |
# tau2 - difference in proportion control versus "right" message | |
fixed_pop <- fabricate( | |
N = N, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(estimatr) | |
library(fabricatr) | |
library(DeclareDesign) | |
set.seed(12345) | |
dat <- | |
fabricate( | |
N = 50, | |
x = sample(1:40, N, replace = TRUE), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## We have many group homes (like nursing homes) and few COVID tests. | |
## We want to test a simple random sample within each home to estimate the proportion positive with COVID (or detect | |
## any COVID) | |
## So, each place has a fixed population (N) and we will sample from this place. | |
## The population should be unique for combination of N and covidprob (which is just .02 in the simulations, but higher for | |
## testing here). | |
## I'd like to use the nice DeclareDesign functions like redesign() to assess | |
## power to detect COVID given different proportions of sampling for each population size |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> pop <- declare_population(N, | |
+ covid=rbinom(N,size=1,prob=covidprob)) | |
> samp <- declare_sampling(n=n) | |
> sim_design <- pop + samp | |
> set.seed(12345) | |
> tmp <- draw_data(redesign(sim_design,N=40,n=20,covidprob=.5)) | |
> table(tmp$covid) | |
0 1 | |
9 11 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#' Wrap a basic one-way t-test so that it's usable by the tidy functions | |
#' @param data The data that we pass in. See discussion of tidy_estimator and handlers in declare_estimator | |
#' @returns A data frame that contains quantities useful for assessing the design and estimator | |
our_ttest <- function(data) { | |
require(coin) | |
res <- coin::oneway_test( | |
outcome ~ factor(Xclus), | |
data = data, | |
distribution = "asymptotic" | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Example of simulating data from a design with one-sided non-compliance | |
types <- c("Always-Taker", "Never-Taker", "Complier", "Defier") | |
direct_effect_of_encouragement <- 0.0 | |
proportion_defiers <- 0.0 | |
design <- declare_population( | |
N = 500, | |
type = sample( types, N, replace = TRUE, | |
prob = c(0.1, 0.1, 0.8 - proportion_defiers, proportion_defiers) | |
), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<meta charset="utf-8"> | |
<!-- build:css v/cmx.css --> | |
<link rel="stylesheet" href="styles/cmx.css"> | |
<link rel="stylesheet" href="styles/cmx-overlay.css"> | |
<!-- endbuild --> | |
<!-- build:js v/cmx.js --> | |
<script data-main="scripts/main" src="scripts/vendor/require.js"></script> | |
<!-- endbuild --> | |
<style>.cmx-user-scene4 .cmx-text-border .cmx-path {stroke: orange}</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<meta charset="utf-8"> | |
<!-- build:css v/cmx.css --> | |
<link rel="stylesheet" href="http://cmx.io/v/0.1/cmx.css"/> | |
<script src="http://cmx.io/v/0.1/cmx.js"></script> | |
<!-- <link rel="stylesheet" href="styles/cmx-overlay.css"> --> | |
<!-- endbuild --> | |
<!-- build:js v/cmx.js --> | |
<!-- <script data-main="scripts/main" src="scripts/vendor/require.js"></script> --> | |
<!-- endbuild --> |
NewerOlder