Skip to content

Instantly share code, notes, and snippets.

View alexpghayes's full-sized avatar

alex hayes alexpghayes

View GitHub Profile
x <- c(
-0.54660789, 2.43686553, 1.24397260, -0.73957557, 2.33131378,
-0.97341652, -0.48911950, 0.35658630, -0.77824579, 1.55796356,
0.10641176, 0.89764371, 0.64903636, 1.89822592, -0.35568742,
1.52124163, 0.01328800, 1.33453143, -1.08829020, 0.83033763,
0.68018922, 1.93419047, 1.14073253, 2.56650893, 1.90859128,
1.39105347, 1.37547130, -0.07223141, 0.43142589, 1.78035482,
1.90837367, 1.84173396, -0.09760825, 1.66610817, 0.03379679,
0.97277154, 0.78599263, 0.75538460, 1.23006396, 0.83001685
)
library(tidyverse)
data <- read_csv("data.csv")
X <- as.matrix(data) # i presume this is the starting state of the data
plot_at_threshold <- function(mat, threshold) {
colnames(mat) <- 1:NCOL(mat)
rownames(mat) <- 1:NROW(mat)
library(sandwich)

n <- 10
d <- 3

p <- 4

X <- matrix(
  rnorm(n * d),
library(fastRG)
library(estimatr)
library(tidyverse)
set.seed(27)
get_one_estimate <- function() {
k <- 5
n <- 1000
B <- matrix(stats::runif(k * k), nrow = k, ncol = k)
``` r
library(dplyr)
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
library(tidyverse)

x <- seq(0, 10, length.out = 100)

unobserved <- tibble(
  x = x, 
  true_curve1 = sin(x),
  true_curve2 = tanh(x) - 0.5,
 coin = as.logical(rbinom(length(x), size = 1, prob = 0.5)),
# rotate Y to align it to X
mypro <- function(X, Y) {
XY <- crossprod(X, Y)
s <- svd(XY)
rotation <- s$v %*% t(s$u)
Yrot <- Y %*% rotation
diff <- X - Yrot
sum_squared_error <- sum(diff^2)
list(
s = s,
``` r
# from https://github.com/ASKurz/non-linear-RCT/blob/master/Simulate%20the%20data.Rmd
library(tidyverse)
library(faux)
#>
#> ************
#> Welcome to faux. For support and examples visit:
#> https://debruine.github.io/faux/
#> - Get and set global package options with: faux_options()
library(aPPR)
library(neocache)
library(logger)
library(here)
library(glue)
library(readr)
set.seed(27)
log_appender(
library(aPPR)
library(logger)
set.seed(26)
log_appender(
appender_file(
"/paper/to/logfile.log" ## TODO: choose a path to log to
),
namespace = "aPPR"