# Libraries to load pkgs <-c("here","tidyverse","forecast","lmtest","urca","glue","ggpubr","tseries","ggrepel","ggsci","cowplot","knitr")## --------------------------------------------------## install any that are missing (thanks chatgpt!)## --------------------------------------------------to_install <- pkgs[!pkgs %in%rownames(installed.packages())]if (length(to_install)) install.packages(to_install)## --------------------------------------------------## attach them; TRUE/FALSE invisibly indicates success## --------------------------------------------------invisible(lapply(pkgs, library, character.only =TRUE))
here() starts at /Users/bkaplowitz/Developer/work/poker
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr 1.1.4 ✔ readr 2.1.5
✔ forcats 1.0.0 ✔ stringr 1.5.1
✔ ggplot2 3.5.2 ✔ tibble 3.2.1
✔ lubridate 1.9.4 ✔ tidyr 1.3.1
✔ purrr 1.0.4
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag() masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
Registered S3 method overwritten by 'quantmod':
method from
as.zoo.data.frame zoo
Loading required package: zoo
Attaching package: 'zoo'
The following objects are masked from 'package:base':
as.Date, as.Date.numeric
Attaching package: 'ggpubr'
The following object is masked from 'package:forecast':
gghistogram
Attaching package: 'cowplot'
The following object is masked from 'package:ggpubr':
get_legend
The following object is masked from 'package:lubridate':
stamp
Since the test statistic is ~0.48 well above 0.05, we fail to reject the null hypothesis that the data is uncorrelated.
Stationary tests
adf.test(x_ts, alternative="stationary")
Warning in adf.test(x_ts, alternative = "stationary"): p-value smaller than
printed p-value
Augmented Dickey-Fuller Test
data: x_ts
Dickey-Fuller = -66.549, Lag order = 66, p-value = 0.01
alternative hypothesis: stationary
pp.test(x_ts)
Warning in pp.test(x_ts): p-value smaller than printed p-value
Phillips-Perron Unit Root Test
data: x_ts
Dickey-Fuller Z(alpha) = -297180, Truncation lag parameter = 29,
p-value = 0.01
alternative hypothesis: stationary
# ADF will not go lower than 0.01 in adf.test so we use mckannon test as alternative test of cointegration/unit roots:summary(ur.df(x_ts, type ="drift", lags =0))
###############################################
# Augmented Dickey-Fuller Test Unit Root Test #
###############################################
Test regression drift
Call:
lm(formula = z.diff ~ z.lag.1 + 1)
Residuals:
Min 1Q Median 3Q Max
-20043.3 -317.1 82.1 235.2 20008.0
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 17.640634 3.476800 5.074 3.9e-07 ***
z.lag.1 -0.998718 0.001829 -546.086 < 2e-16 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 1901 on 298975 degrees of freedom
Multiple R-squared: 0.4994, Adjusted R-squared: 0.4994
F-statistic: 2.982e+05 on 1 and 298975 DF, p-value: < 2.2e-16
Value of test-statistic is: -546.0858 149104.8
Critical values for test statistics:
1pct 5pct 10pct
tau2 -3.43 -2.86 -2.57
phi1 6.43 4.59 3.78
studentized Breusch-Pagan test
data: lm_mean
BP = 0.61205, df = 1, p-value = 0.434
null is homoskedasticity. Hence we fail to reject null at 5% significance that it is homoskedastic, at least under simple trend model. What about just for first 100 samples?
This shows the dramatic over-concentration of values at 100
Other analysis
# fraction of values much larger than +/-5000 large_values<-tibble(x) %>%filter(abs(x)>=2000) fraction_large<-count(large_values)/length(x) *100str_glue('As big blind we get least +/-2000 winnings {fraction_large}% of the time')
As big blind we get least +/-2000 winnings 6.24828582705082% of the time
x_hundred <-tibble(x) %>%filter(x==100) fraction_hundred <-count(x_hundred)/length(x) *100str_glue('As big blind we make opponent fold: {fraction_hundred}% of the time.')
As big blind we make opponent fold: 20.9045481607342% of the time.