Skip to content

Instantly share code, notes, and snippets.

View gzt's full-sized avatar

g z thompson gzt

View GitHub Profile
@gzt
gzt / init.el
Created July 11, 2022 19:45
Some things for an init.el file
;; .emacs
;; now init.el
;; Added by Package.el. This must come before configurations of
;; installed packages. Don't delete this line. If you don't want it,
;; just comment it out by adding a semicolon to the start of the line.
;; You may delete these explanatory comments.
(require 'package)
(let* ((no-ssl (and (memq system-type '(windows-nt ms-dos))
(not (gnutls-available-p))))
@gzt
gzt / manual-simple-lin-regression.R
Created November 14, 2020 16:38
somebody had a question about manually computing reg coefficients
# somebody had a question about manually computing reg coefficients
# and accidentally did it with no slope, so I'm demonstrating
# might as well make it a gist
set.seed(20201114)
x <- runif(100, 0, 20)
y <- 0.5 + 0.5 * x + rnorm(100, 0, 2)
coef(lm(y ~ x))
coef(lm(y ~ -1 + x))
cor(y, x) * sd(y) / sd(x)
X <- as.matrix(x)
@gzt
gzt / kappaadjrand.R
Created December 12, 2018 04:59
noting the relation between Cohen's kappa, adjusted Rand index, and the simple proportion that agree when the assumptions are met
devtools::install_github('gzt/catsim')
library('catsim')
length = 10000
rescohen = numeric(1000)
resrand = numeric(1000)
numvec = numeric(1000)
probabilities = 10:1/sum(10:1)
for(i in 1:1000){
x <- sample(1:10, length, replace = TRUE, probabilities)
y <- x
@gzt
gzt / wage_gap.R
Created May 25, 2018 23:17
wage gap example in R code
# https://www.reddit.com/r/IAmA/comments/8m21kw/i_am_dr_jordan_b_peterson_u_of_t_professor/dzkha8k/
# this economist produces a clean example in STATA of why controlling for occupation when exploring
# the wage gap is wrong. I reproduce it in R because somebody asked.
female = c(rep(0,100),rep(1,100))
tech_job_cost =rep((1:100)/100,2)
tech_job = ifelse(((female & tech_job_cost>=0.6) | (!female & tech_job_cost>=0.5)),1,0)
# not the cleanest way of doing it, but whatevs!
wage_1 = ifelse( (!female & tech_job), 1, 0)
@gzt
gzt / keybase.md
Created March 15, 2017 04:02
saying who i am on keybase

Keybase proof

I hereby claim:

  • I am gzt on github.
  • I am gzthompson (https://keybase.io/gzthompson) on keybase.
  • I have a public key whose fingerprint is F9F0 FBDC 6222 DD1B EAB4 472F 0A6F 3578 AC65 300E

To claim this, I am signing this object: