Skip to content

Instantly share code, notes, and snippets.

@Derek-Jones
Created December 7, 2023 13:42
Show Gist options
  • Save Derek-Jones/d6591afd333e60a2c20e1c365a2fff80 to your computer and use it in GitHub Desktop.
Save Derek-Jones/d6591afd333e60a2c20e1c365a2fff80 to your computer and use it in GitHub Desktop.
Fit regression models to Replit's attendence data
#
# replit-fishing.R, 7 Dec 23
#
# Data from plot in
# https://twitter.com/paulg/status/1732714720451330558
# extracted data using WebPlotDigitizer
library("colorspace")
par(bty="l")
par(las=1)
par(pch="+")
pal_col=rainbow(2)
# Data after code
rl=read.csv("../Default Dataset.csv")
plot(rl, log="xy", col=pal_col[2], cex=1.4)
# Day intervals estimated by looking at plot with log axis for Attend only
rl_15_mod=glm(log(Attend) ~ log(Day), data=rl, subset=(Day < 15))
summary(rl_15_mod)
pred=predict(rl_15_mod)
lines(rl$Day[1:13], exp(pred), col=pal_col[1])
rl_40_mod=glm(log(Attend) ~ log(Day), data=rl, subset=(Day >= 15) & (Day < 40))
summary(rl_40_mod)
pred=predict(rl_40_mod)
lines(rl$Day[14:33], exp(pred), col=pal_col[1])
rl_60_mod=glm(log(Attend) ~ log(Day), data=rl, subset=(Day >= 40) & (Day < 60))
summary(rl_60_mod)
pred=predict(rl_60_mod)
lines(rl$Day[34:50], exp(pred), col=pal_col[1])
dev.copy(dev=png, file="replit-attend-day.png")
dev.off()
# Extracted data
Day,Attend
1.255,2.082e+5
2.087,1.207e+5
2.986,8.810e+4
4.484,6.911e+4
5.383,6.002e+4
6.482,5.204e+4
7.680,4.634e+4
8.879,4.129e+4
10.08,3.732e+4
11.28,3.374e+4
12.47,3.124e+4
13.67,2.957e+4
14.87,2.733e+4
16.07,2.483e+4
17.27,2.239e+4
18.47,1.990e+4
19.67,1.855e+4
20.86,1.765e+4
22.06,1.668e+4
23.26,1.572e+4
24.46,1.482e+4
25.66,1.392e+4
26.86,1.244e+4
28.05,1.128e+4
29.25,1.032e+4
30.45,9419
31.65,8965
32.85,8384
34.05,8122
35.25,7222
36.44,6640
37.64,6634
38.84,5904
40.04,4066
41.24,3879
42.44,3415
43.63,3408
44.83,3083
46.03,2885
47.23,2879
48.43,2713
49.63,2355
50.83,2349
52.02,2343
53.22,2252
54.42,1820
55.62,1814
56.82,1807
58.02,1801
59.22,1795
60.41,1608
61.61,1272
62.81,1266
64.01,1259
65.21,1253
66.41,1247
67.60,1241
68.80,1235
70.00,1229
71.20,1223
72.40,1217
73.60,1210
74.80,1204
75.99,750.8
77.19,680.8
78.39,674.7
79.59,668.6
80.79,662.4
81.99,656.3
83.18,650.2
84.38,644.1
85.58,637.9
86.78,631.8
87.98,625.7
89.18,619.5
90.38,613.4
91.57,607.3
92.77,281.7
93.97,211.6
95.17,205.5
96.37,199.4
97.57,193.2
98.77,59.31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment