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
# Load necessary libraries | |
library(gamlss) | |
library(rstan) | |
library(ggplot2) | |
# Step 1: Generate Johnson's SU distributed data | |
set.seed(42) | |
N <- 10000 # Sample size | |
gamma <- 0.5 # Shape parameter (nu) | |
delta <- 1 # Shape parameter (tau) |
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(sandwich) | |
library(lmtest) | |
library(lme4) | |
patients <- 3e3 | |
seq_len(patients) %>% | |
map_df(function(id) { | |
rnorm(1, 0, 1) -> patient_effect |
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 pandas as pd | |
import statsmodels.api as sm | |
from sklearn.model_selection import train_test_split | |
from sklearn.linear_model import LinearRegression | |
class AIDataEngineer: | |
def __init__(self): | |
self.data = None | |
self.model = None | |
self.X_train = None |
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(brms) | |
library(tidybayes) | |
# https://docs.google.com/spreadsheets/d/1vG0WdjZaYlS4_7_if-OaE3uMv3aX6zfvQMx5JvDREF0/edit?usp=sharing | |
# Chi.sq | |
prop.test(c(103, 135), c(5947, 5609), | |
alternative = "less", | |
conf.level = 0.99) |
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) | |
read_csv("~/Downloads/Religion by Firearm Deaths Data - Firearm Deaths by State.csv", | |
skip = 4) %>% | |
janitor::clean_names() -> firearm_deaths | |
read_csv("~/Downloads/Religion by Firearm Deaths Data - Religiousity by State.csv", | |
skip = 3) %>% | |
janitor::clean_names() %>% | |
rename(state = region) %>% | |
mutate(religious = 1 - irreligion_percent/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) | |
# CPI | |
# https://data.bls.gov/timeseries/CUSR0000SA0&output_view=pct_1mth | |
readxl::read_xlsx("~/Downloads/SeriesReport-20220817182003_bb0f80.xlsx", skip = 10) %>% | |
mutate(date = seq.POSIXt(as.POSIXct("1957-02-01"), by = "month", length.out = n())) %>% | |
select(date, cpi = Value) %>% | |
inner_join( | |
# Short-term Interest Rates - https://fred.stlouisfed.org/series/DGS1MO | |
read_csv("~/Downloads/DGS1MO (1).csv", col_types = cols( |
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) | |
# CPI | |
# https://data.bls.gov/timeseries/CUSR0000SA0&output_view=pct_1mth | |
readxl::read_xlsx("~/Downloads/SeriesReport-20220807120638_733b06.xlsx", skip = 10) %>% | |
mutate(date = seq.POSIXt(as.POSIXct("1947-02-01"), by = "month", length.out = n())) %>% | |
select(date, cpi = Value) -> cpi | |
cpi %>% | |
filter(date >= as.POSIXct("1949-01-01")) %>% |
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(forecast) | |
library(urca) | |
library(dynlm) | |
library(lmtest) | |
library(sandwich) | |
# https://data.bls.gov/timeseries/CUSR0000SA0&output_view=pct_1mth | |
read_csv("~/Downloads/inflation.csv", skip = 11) %>% | |
janitor::clean_names() %>% |
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(gamlss); select <- dplyr::select | |
library(fmpapi) | |
library(Quandl) | |
fmp_daily_prices("ASAN") -> d | |
fmp_daily_prices("TEAM") -> team | |
Quandl("USTREASURY/YIELD") -> yc | |
yc %>% |
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(lmtest) | |
library(sandwich) | |
5e2 -> students | |
20 -> schools | |
tibble(student_id = 1:students) %>% | |
mutate(school_id = rep(1:schools, max(student_id) / schools)) %>% | |
left_join(tibble(school_id = 1:schools, school_effect = rnorm(schools)), |
NewerOlder