{{ message }}

Instantly share code, notes, and snippets.

# Jonas Moss JonasMoss

Created Sep 23, 2021
Bullshit
View bullshit.csv
 free_market_ideology bullshit_receptivity 1 40 3.1 2 30 2.66666666666667 3 70 3.3 4 10 1.9 5 50 3.56666666666667 6 35 3.93333333333333 7 50 2.03333333333333 8 50 2.53333333333333 9 25 1
Created Sep 22, 2021
Talent data set.
View talent.csv
 country points talent 1 Spain 1485 85 2 Germany 1300 76 3 Brazil 1242 48 4 Portugal 1189 16 5 Argentina 1175 35 6 Switzerland 1149 9 7 Uruguay 1147 9 8 Colombia 1137 3 9 Italy 1104 67
Last active Aug 28, 2019
View causality_first_meeting.md

On the Consistency Rule in Causal Inference Axiom, Definition, Assumption, or Theorem? (Pearl, 2010, 4 page) One of the big problems with the causality literature is the terminology and the lack of foundationas for everyone to agree on.(Think about a vector space -- everyone agrees what it is. That's where we want to be.) The consistency rule appears to me to be the corner-stone of an axiomatic development of causality theory.

The following papers are mentioned in the Pearl paper and are a part of the assignment:

Created Jul 12, 2019
Define functions inside enclosing environment.
View H.R
 #' Hide non-function variables from function. #' #' @param ... Named functions and function definitions. #' @return Nothing. H = function(...) { function_names = names(as.list(substitute((...)))[-1]) function_defs = list(...) envir = parent.env(parent.frame())
Last active Dec 19, 2018
An example of strange R squared values.
View strange_rsq.R
 # Create a covariance matrix for the covariates. rho12 = -0.1 rho13 = 0.65 rho23 = -0.3 covariance = matrix(c(1, rho12, rho13, rho12, 1, rho23, rho13, rho23, 1), nrow = 3) # Simulate a linear regression with all betas equal to 1.
Last active Apr 30, 2018
Illustration of negative binomial.
View negative_binomial.R
 #' Graph of number of tries needed to obtain K successes. #' @param K number of studies. #' @return NULL. plotter = function(K){ kk = 0:(K*70) plot(kk + K, dnbinom(kk, K, 0.05), bty = "l", type = "b", pch = 20, xlab = "Number of studies", ylab = "Probability", main = paste0("Number of studies before ", K, " successes"))
Created Apr 28, 2018
Reproducible simulations for 'optional_stopping_streaks'.
View optional_stopping_streaks.R
 #' Find the cumulative maximal streak length in a vector of bools. #' #' @param bools Logical vector. #' @return An integer vector. The \code{i}th element is the maximal streak #' length in \code{x[1:i]}. #' @example #' bools1 = c(FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, FALSE) #' streaks(bools1)  0 1 1 1 2 3 3 #' #' bools2 = c(FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE)
Last active Apr 25, 2018
A function that evaluates a call as if it was defined in a specified environment.
View S.R
 #' Evaluates a call as if its function was defined in a specified environment #' #' When a name is encountered in the definition of a function, the search path #' for that name is given by the defining environment of the function. This is #' good behaviour, since it allows simple reasoning about how a function should #' behave: If two calls to a function defined in a constant environment \code{e} #' yield different results, this must be because they are given different #' arguments. #' #' Sometimes, a function is defined to make messy code more readable, but is
Last active Apr 23, 2018
A function that allows the arguments in function calls to be self-referential.
View R.R
 #' Allow self-referential arguments in functions. #' #' @param call A function call. #' @param quote Logical; if \code{TRUE}, the supplied \code{call} is interpreted #' as a quote, so \code{substitute} is applied. #' @return The evaluated function call with the self-refering arguments #' evaluated. #' @examples #' R(plot(y = 1:10, x = y^2)) #' R(plot(x = y^2, y = 1:10))
Last active Mar 25, 2018
Idealistic simulation of true powers in psychology.
View power_simulation.R
 ## A small simulation of how powers could be distributed in psychology. ## 'sn' is the skew-normal distribution, which I suppose is useful in this case. ## The package is available from CRAN: ## install.packages("sn") set.seed(313) N = 100000 thetas = sn::rsn(N, xi = 0.05, omega = 0.15, alpha = 2) # Sample of true thetas. ## I assume the effect sizes (thetas) are sampled from the following