Skip to content

Instantly share code, notes, and snippets.

View alexpghayes's full-sized avatar

alex hayes alexpghayes

View GitHub Profile
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"
``` r
library(withr) # for local random seeds
library(tidymodels)
library(palmerpenguins)
splitting_seed <- 9023
training_seed <- 2342
penguins_complete <- na.omit(penguins)
library(tidyverse)
library(invertiforms) # RoheLab/invertiforms
library(igraphdata)
library(igraph)
library(RSpectra)
library(scales)
data("enron", package = "igraphdata")
A <- enron %>%
#' @references http://arxiv.org/abs/2101.10880
usp1 <- function(I, J, epsilon = 0) {
P <- matrix(0, nrow = I, ncol = J)
for (i in 1:I) {
for (j in 1:J) {
P[i, j] <- 2^(-(i + j)) / ((1 - 2^(-I)) * (1 - 2^(-J)))
}
# a Pandas dataframe with columns:
#
# - doi<string>
# - search_term<string>
# - year<int>
# - authors<list<string>>
# - cites<list<string>>: DOIs of papers cited by this paper
#
# where doi and search_term together form a primary key and cites is a list
# that contains a foreign key to some table of metadata for all papers
library(Matrix)
library(tidyverse)
# need these two packages that are not on CRAN
# if something goes wrong, let me know, i wrote them and will fix
# to install:
#
# > install.packages("pak")
# > pak::pkg_install("RoheLab/fastRG")