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)),
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
# 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, |
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
``` 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() |
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(aPPR) | |
library(neocache) | |
library(logger) | |
library(here) | |
library(glue) | |
library(readr) | |
set.seed(27) | |
log_appender( |
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(aPPR) | |
library(logger) | |
set.seed(26) | |
log_appender( | |
appender_file( | |
"/paper/to/logfile.log" ## TODO: choose a path to log to | |
), | |
namespace = "aPPR" |
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
``` r | |
library(withr) # for local random seeds | |
library(tidymodels) | |
library(palmerpenguins) | |
splitting_seed <- 9023 | |
training_seed <- 2342 | |
penguins_complete <- na.omit(penguins) |
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(invertiforms) # RoheLab/invertiforms | |
library(igraphdata) | |
library(igraph) | |
library(RSpectra) | |
library(scales) | |
data("enron", package = "igraphdata") | |
A <- enron %>% |
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
#' @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))) | |
} |
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
# 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 |
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(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") |