Skip to content

Instantly share code, notes, and snippets.

View chelseaparlett's full-sized avatar

Chelsea Parlett Pelleriti chelseaparlett

View GitHub Profile
import numpy as np
def randomPrior():
'''randomly chooses a type of distribution then randomly selects
parameters based on limitations of said distribution'''
possPriors = {"Cauchy": {"loc": [-100,100], "scale": [0,100]},
"Normal": {"mean": [-100,100],
"sd": [0,100]},
"InverseGamma": {"a": [0,100], "b":[0,100]},
#1-----------------------
a = 19
b = 20
c = 18
(a+b+c)/3
#2-----------------------
color = input("What is your favorite color? ")
sentence = "Your favorite color is " + color
library(ranger)
y <- rnorm(1000)
x1 <- rnorm(1000)
x2 <- rnorm(1000)
df <- data.frame(y,x1,x2)
rf <- ranger(y~ x1 + x2, data = df, importance = "permutation")
rf$variable.importance
library(pwr)
ratioSS <- function(n){
#calculate SESOI based on 33% power
SESOI <- pwr.t.test(n = n, sig.level = 0.05,
power = 0.33, type = "one.sample",
alternative = "two.sided")$d
#calculate exact n needed to get 80% power on inferiority test
getRandSamples <- function(seed = NA){
if (!is.na(seed)){
set.seed(seed) #incase you need repeatable data generation.
#but remember to set a different seed for each person if you want them to get different items at each time point.
}
True_New <- sample(1:20,20,replace = F) #items that are true + new
True_Rep <- sample(21:40,20,replace = F) #items that are true + repeated
False_New <- sample(41:60,20,replace = F) #items that are false + new
False_Rep <-sample(61:80,20,replace = F) # items that are false + repeated
library(ggplot2)
library(pwr)
#funcs and params-----------------------------
pwrf <- function(ef,pow){
normal <- pwr.t.test(d = ef, type = "two.sample",
alternative = "two.sided",
power = pow)$n
half <- pwr.t.test(d = (ef/2), type = "two.sample",
alternative = "two.sided",