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(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", |
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
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 |
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(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 |
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(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 |
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
#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 |
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
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]}, |
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) | |
# 1 | |
d <- read.csv(url("https://raw.githubusercontent.com/cmparlettpelleriti/CPSC392ParlettPelleriti/master/Data/Beyonce_data.csv")) | |
ggplot(d,aes(x = factor(mode), y = danceability)) + geom_boxplot(aes(fill = factor(mode))) + | |
scale_fill_manual(values = c("#f83703", "#000000")) + | |
labs(title = "Dancibility of Beyonce Songs by Major and Minor Key", x = "mode") + | |
theme(legend.position = "none", panel.background = element_rect(fill = "#78a741", colour = "#83ba7d"), | |
panel.grid.major = element_line(colour = "burlywood3"), |
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) | |
calculateWeights <- function(dfData, row){ | |
wi <- dnorm(dfData$x, row[,"means"], row[,"var"]) | |
return(wi) | |
} | |
normalize.choose <- function(weights, dfDist){ | |
wis <- sapply(1:ncol(weights), | |
function(x) (weights[,x]*dfDist[,"ak"])/sum(weights[,x]*dfDist[,"ak"])) | |
chosen <- sapply(1:ncol(weights), function(x) which.max(wis[,x])) |
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 <- read.csv(url("https://raw.githubusercontent.com/cmparlettpelleriti/CPSC392ParlettPelleriti/master/Data/PopDivas_data.csv")) | |
b <- read.csv(url("https://raw.githubusercontent.com/cmparlettpelleriti/CPSC392ParlettPelleriti/master/Data/cereal.csv")) | |
c <- read.csv(url("https://raw.githubusercontent.com/cmparlettpelleriti/CPSC392ParlettPelleriti/master/Data/BreastCancer.csv")) | |
#red yellow blue purple green pink black white rainbow | |
library(ggplot2) | |
red <- ggplot(a, aes(x = artist_name, y = energy, fill = artist_name)) + | |
geom_violin() + scale_fill_manual(values = c("red", "red1", "red2", "red3", "red4", "firebrick4")) + | |
geom_boxplot() + ggtitle("Pop Divas Song Energy") | |
red |
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(ggplot2) | |
library(palmerpenguins) | |
library(MASS) | |
#penguin-------------------------------------------------- | |
penguins <- na.omit(penguins) | |
ggplot(penguins, aes(x = bill_length_mm, bill_depth_mm)) + | |
geom_point() + | |
facet_wrap(sex~species) + |
OlderNewer