forked from m-clark/m-clark.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
code.Rmd
214 lines (162 loc) · 16.4 KB
/
code.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
---
title: Code
output:
distill::distill_article:
toc: true
---
A lot of the following are things I do for fun or personal interest and development. Packages, code demos and more.
## R Packages
<span itemscope itemtype ="http://schema.org/WebApplication">
[<span itemprop="name">mixedup</span>](https://m-clark.github.io/mixedup/)
<span itemprop="description">
A package for extracting results from mixed models from several packages that are easy to use and viable for presentation.
</span>
</span>
<span itemscope itemtype ="http://schema.org/WebApplication">
[<span itemprop="name">confusionMatrix</span>](https://m-clark.github.io/confusionMatrix/)
<span itemprop="description">
Given predictions and a target variable, this package provides a wealth of summary statistics that can be calculated from a single confusion matrix, and return tidy results with as few dependencies as possible.
</span>
</span>
<span itemscope itemtype ="http://schema.org/WebApplication">
[<span itemprop="name">198R</span>](https://github.com/m-clark/NineteenEightyR/)
<span itemprop="description">
R with its collar flipped, or the movie Drive if it was all about R programming, writing R code on a beach in Miami as the sun sets, R wearing sunglasses at night, R asking you to take it home tonight because it doesn't want to let you go until you see the light, Countach > Testarrosa, but Delorean > all except R, R if Automan had lasted longer than 1 season, driving down Mulholland Dr. at night thinking about R code, R playing a cello at the end of a dock on a lake before taking a ride in a badass helicopter, R with its hair all done up with Aquanet... You get the idea.
</span>
</span>
<span itemscope itemtype ="http://schema.org/WebApplication">
[<span itemprop="name">visibly</span>](https://m-clark.github.io/visibly/)
<span itemprop="description">
This is a collection of functions that I use related to visualization, e.g. the palette generating function (`create_palette`) and clean visualization themes for ggplot and plotly. In addition, there are visualizations specific to mixed and additive models.
</span>
</span>
<span itemscope itemtype ="http://schema.org/WebApplication">
[<span itemprop="name">538 football club rankings</span>](https://m-clark.github.io/five38clubrankings/)
<span itemprop="description">
This package grabs the table located at [538](https://projects.fivethirtyeight.com/global-club-soccer-rankings/), and additionally does some summary by league and country.
</span>
</span>
<span itemscope itemtype ="http://schema.org/WebApplication">
[<span itemprop="name">gammit</span>](https://m-clark.github.io/gammit/)
<span itemprop="description">
The package provides a set of functions to aid using `mgcv` (possibly solely) for mixed models. Mostly superseded by mixedup.
</span>
</span>
<span itemscope itemtype ="http://schema.org/WebApplication">
[<span itemprop="name">tidyext</span>](https://m-clark.github.io/tidyext/)
<span itemprop="description">
This package is a collection of functions that do the things I commonly need to do with data while doing other processing within the dataverse. I work with data for myself and others everyday, and use these functions quite often.
</span>
</span>
<span itemscope itemtype ="http://schema.org/WebApplication">
[<span itemprop="name">lazerhawk</span>](https://github.com/m-clark/lazerhawk/)
<span itemprop="description">
While the name is more or less explanatory, to clarify, this is a package of miscellaneous functions that are mostly useful to me.
</span>
</span>
In addition to these, though they are not publicly available, I've created even more involved packages for specific project work.
## Code Snippets
The vast majority of these code snippets are conceptual demonstrations of more complicated models. The audience is generally faculty, researchers, and graduate students in applied fields who, like I did, want to go beyond their basic statistical training. However, I hope it helps anyone who happens to stumble across it. I don't really update this page anymore, as I've cleaned and moved much of these over to [<span itemprop="name keywords">Model Estimation by Example</span>](../models-by-example/), so I would look for something you see here in the corresponding chapter of that document. In general, you can find all of my code at [GitHub](https://github.com/m-clark).
<div style="font-size: 75%">
### Model Fitting
[standard linear regression](https://github.com/m-clark/Miscellaneous-R-Code/blob/master/ModelFitting/standard_lm.R),
[standard logistic regression](https://github.com/m-clark/Miscellaneous-R-Code/blob/master/ModelFitting/standard_logistic.R),
[penalized regression](https://github.com/m-clark/Miscellaneous-R-Code/blob/master/ModelFitting/penalized_ML.R),
[lasso regression](https://github.com/m-clark/Miscellaneous-R-Code/blob/master/ModelFitting/lasso.R),
[ridge regression](https://github.com/m-clark/Miscellaneous-R-Code/blob/master/ModelFitting/ridge.R),
[newton and IRLS](https://github.com/m-clark/Miscellaneous-R-Code/blob/master/ModelFitting/newton_irls.R),
nelder-mead [(Python)](https://github.com/m-clark/Miscellaneous-R-Code/blob/master/ModelFitting/nelder_mead.py) [(R)](https://github.com/m-clark/Miscellaneous-R-Code/blob/master/ModelFitting/nelder_mead.R),
[gradient descent](https://github.com/m-clark/Miscellaneous-R-Code/blob/master/ModelFitting/gradient_descent.R) [(stochastic)](https://github.com/m-clark/Miscellaneous-R-Code/blob/master/ModelFitting/stochastic_gradient_descent.R),
[bivariate probit](https://github.com/m-clark/Miscellaneous-R-Code/blob/master/ModelFitting/bivariateProbit.R),
[heckman selection](https://github.com/m-clark/Miscellaneous-R-Code/blob/master/ModelFitting/heckman_selection.R),
[tobit](https://github.com/m-clark/Miscellaneous-R-Code/blob/master/ModelFitting/tobit.R),
[naive bayes](https://github.com/m-clark/Miscellaneous-R-Code/blob/master/ModelFitting/naivebayes.R),
[multinomial regression](https://github.com/m-clark/Miscellaneous-R-Code/blob/master/ModelFitting/multinomial.R),
[ordinal regression](https://github.com/m-clark/Miscellaneous-R-Code/blob/master/ModelFitting/ordinal_regression.R),
[quantile regression](http://htmlpreview.github.io/?https://github.com/m-clark/Miscellaneous-R-Code/blob/master/ModelFitting/quantileRegression.html),
[hurdle poisson](https://github.com/m-clark/Miscellaneous-R-Code/blob/master/ModelFitting/hurdle.R),
[hurdle negbin](https://github.com/m-clark/Miscellaneous-R-Code/blob/master/ModelFitting/hurdle.R),
[zero-inflated poisson](https://github.com/m-clark/Miscellaneous-R-Code/blob/master/ModelFitting/poiszeroinfl.R),
[zero-inflated negbin](https://github.com/m-clark/Miscellaneous-R-Code/blob/master/ModelFitting/NBzeroinfl.R),
[Cox survival](https://github.com/m-clark/Miscellaneous-R-Code/blob/master/ModelFitting/survivalCox.R),
[confirmatory factor analysis](https://github.com/m-clark/Miscellaneous-R-Code/blob/master/ModelFitting/cfa_ml.R),
[Markov model](https://github.com/m-clark/Miscellaneous-R-Code/blob/master/ModelFitting/markov_model.R),
hidden Markov model [(R)](https://github.com/m-clark/Miscellaneous-R-Code/blob/master/ModelFitting/hmm_viterbi.R)
[(Python)](https://github.com/m-clark/Miscellaneous-R-Code/blob/master/ModelFitting/hmm_viterbi.py),
[stochastic volatility](https://github.com/m-clark/Miscellaneous-R-Code/blob/master/ModelFitting/stochasticVolatility.R),
[extreme learning machine](https://github.com/m-clark/Miscellaneous-R-Code/blob/master/ModelFitting/elm.R),
[Chinese restaurant process, Indian buffet process](https://github.com/m-clark/Miscellaneous-R-Code/blob/master/ModelFitting/crp.R),
[One-line models (an exercise)](https://github.com/m-clark/Miscellaneous-R-Code/blob/master/ModelFitting/one_line_models.R), ...
#### Mixed models
one factor random effects [(R)](https://github.com/m-clark/Miscellaneous-R-Code/blob/master/ModelFitting/Mixed Models/onefactorRE.R)
[(Julia)](https://github.com/m-clark/Miscellaneous-R-Code/blob/master/ModelFitting/Mixed Models/onefactorRE.jl)
[(Matlab)](https://github.com/m-clark/Miscellaneous-R-Code/blob/master/ModelFitting/Mixed Models/onefactorRE.m),
two factor random effects [(R)](https://github.com/m-clark/Miscellaneous-R-Code/blob/master/ModelFitting/Mixed Models/twofactorRE.R)
[(Julia)](https://github.com/m-clark/Miscellaneous-R-Code/blob/master/ModelFitting/Mixed Models/twofactorRE.jl)
[(Matlab)](https://github.com/m-clark/Miscellaneous-R-Code/blob/master/ModelFitting/Mixed Models/twofactorRE.m),
[mixed model via ML](https://m-clark.github.io/docs/mixedModels/mixedModelML.html),
[mixed model](https://github.com/m-clark/Miscellaneous-R-Code/blob/master/ModelFitting/Bayesian/rstan_MixedModelSleepstudy.R),
[mixed model with correlated random effects](https://github.com/m-clark/Miscellaneous-R-Code/blob/master/ModelFitting/Bayesian/rstan_MixedModelSleepstudy_withREcorrelation.R), See the documents section for more...
#### Bayesian
[BEST t-test](https://github.com/m-clark/Miscellaneous-R-Code/blob/master/ModelFitting/Bayesian/rstant_testBEST.R),
[linear regression](https://github.com/m-clark/Miscellaneous-R-Code/blob/master/ModelFitting/Bayesian/rstan_linregwithprior.R)
(Compare with [BUGS version](https://github.com/m-clark/Miscellaneous-R-Code/blob/master/ModelFitting/Bayesian/bugs_linreg.R), [JAGS](https://github.com/m-clark/Miscellaneous-R-Code/blob/master/ModelFitting/Bayesian/jags_linreg.R)),
[mixed model](https://github.com/m-clark/Miscellaneous-R-Code/blob/master/ModelFitting/Bayesian/rstan_MixedModelSleepstudy.R),
[mixed model with correlated random effects](https://github.com/m-clark/Miscellaneous-R-Code/blob/master/ModelFitting/Bayesian/rstan_MixedModelSleepstudy_withREcorrelation.R),
[beta regression](https://github.com/m-clark/Miscellaneous-R-Code/blob/master/ModelFitting/Bayesian/rstanBetaRegression.R),
mixed model with beta response [(Stan)](https://github.com/m-clark/Miscellaneous-R-Code/blob/master/ModelFitting/Bayesian/rstan_MixedModelBetaRegression.R) [(JAGS)](https://github.com/m-clark/Miscellaneous-R-Code/blob/master/ModelFitting/Bayesian/jags_MixedModelBetaRegression.R),
[mixture model](https://github.com/m-clark/Miscellaneous-R-Code/blob/master/ModelFitting/Bayesian/rstan_MixtureModel.R),
[topic model](https://github.com/m-clark/Miscellaneous-R-Code/blob/master/ModelFitting/Bayesian/topicModelgibbs.R),
[multinomial models](https://github.com/m-clark/Miscellaneous-R-Code/blob/master/ModelFitting/Bayesian/multinomial),
[multilevel mediation](https://github.com/m-clark/Miscellaneous-R-Code/blob/master/ModelFitting/Bayesian/rstan_multilevelMediation.R),
[variational bayes regression](https://github.com/m-clark/Miscellaneous-R-Code/blob/master/ModelFitting/Bayesian/variationalBayesRegression.Rmd),
[gaussian process](https://github.com/m-clark/Miscellaneous-R-Code/blob/master/ModelFitting//gp%20Examples/gaussianProcessStan.Rmd),
[horseshoe prior](https://github.com/m-clark/Miscellaneous-R-Code/blob/master/ModelFitting/Bayesian/horseshoe/README.md),
[item response theory](https://github.com/m-clark/Miscellaneous-R-Code/blob/master/ModelFitting/Bayesian/StanBugsJags/IRT_models), ...
#### EM
[EM mixture univariate](https://github.com/m-clark/Miscellaneous-R-Code/blob/master/ModelFitting/EM%20Examples/EM%20Mixture.R),
[EM mixture multivariate](https://github.com/m-clark/Miscellaneous-R-Code/blob/master/ModelFitting/EM%20Examples/EM%20Mixture%20MV.R),
[EM probit](https://github.com/m-clark/Miscellaneous-R-Code/blob/master/ModelFitting/EM%20Examples/EM%20algorithm%20for%20probit%20example.R),
[EM pca](https://github.com/m-clark/Miscellaneous-R-Code/blob/master/ModelFitting/EM%20Examples/EM%20for%20pca.R),
[EM probabilistic pca](https://github.com/m-clark/Miscellaneous-R-Code/blob/master/ModelFitting/EM%20Examples/EM%20algorithm%20for%20ppca.R),
[EM state space model](https://github.com/m-clark/Miscellaneous-R-Code/blob/master/ModelFitting/EM%20Examples/EM%20for%20state%20space%20unobserved%20components.R)
#### Wiggly
##### Gaussian processses
[Gaussian Process noisy](https://github.com/m-clark/Miscellaneous-R-Code/blob/master/ModelFitting/gp%20Examples/gaussianprocessNoisy.R),
[Gaussian Process noise-free](https://github.com/m-clark/Miscellaneous-R-Code/blob/master/ModelFitting/gp%20Examples/gaussianprocessNoiseFree.R),
[reproducing kernel hilbert space regression](https://github.com/m-clark/Miscellaneous-R-Code/blob/master/ModelFitting/RKHSReg/RKHSReg.md),
[Bayesian Gaussian process](https://github.com/m-clark/Miscellaneous-R-Code/blob/master/ModelFitting//gp%20Examples/gaussianProcessStan.Rmd), ...
##### Additive models
[cubic spline](https://github.com/m-clark/Miscellaneous-R-Code/blob/master/ModelFitting/cubicsplines.R), ...
### Programming Shenanigans
FizzBuzz test [(R)](https://github.com/m-clark/Miscellaneous-R-Code/blob/master/Other/fizzbuzz.R) [(julia)](https://github.com/m-clark/Miscellaneous-R-Code/blob/master/Other/fizzbuzz.jl) [(Python)](https://github.com/m-clark/Miscellaneous-R-Code/blob/master/Other/fizzbuzz.py),
Reverse a string recursively [(R)](https://github.com/m-clark/Miscellaneous-R-Code/blob/master/Other/Programming_Shenanigans/stringReverseRecursively.R) [(Python)](https://github.com/m-clark/Miscellaneous-R-Code/blob/master/Other/Programming_Shenanigans/stringReverseRecursively.py),
Recursive Word Wrap [(R)](https://github.com/m-clark/Miscellaneous-R-Code/blob/master/Other/Programming_Shenanigans/wordWrap.R) [(Python)](https://github.com/m-clark/Miscellaneous-R-Code/blob/master/Other/Programming_Shenanigans/wordWrap.py),
[calculate compound interest recursively](https://github.com/m-clark/Miscellaneous-R-Code/blob/master/Other/Programming_Shenanigans/compound.R),
[get US Congress roll call data](https://github.com/m-clark/Miscellaneous-R-Code/blob/master/Other/getRollCall.R),
Scrape xkcd [(R)](https://github.com/m-clark/Miscellaneous-R-Code/blob/master/Other/xkcdscrape.R) [(Python)](https://github.com/m-clark/Miscellaneous-R-Code/blob/master/Other/xkcdscrape.py),
[Shakespearean Insulter](https://github.com/m-clark/Miscellaneous-R-Code/blob/master/Other/shakespeareanInsulter.R),
[spurious correlation with ratios](https://github.com/m-clark/Miscellaneous-R-Code/blob/master/Other/spuriousCorrelationwithRatios.R),
[R matrix speedups](https://github.com/m-clark/Miscellaneous-R-Code/blob/master/Other/Programming_Shenanigans/matrixOperations.md), ...
</div>
## Shiny Apps
<span itemscope itemtype ="http://schema.org/WebApplication">
[<span itemprop="name">Historical Football Data</span>](http://micl.shinyapps.io/football/)
<span itemprop="description">My annual dive into the frustration of Shiny has produced an [app to explore historical football/soccer data](https://micl.shinyapps.io/football/) for various European leagues (<span itemprop="keywords">Premier</span>, <span itemprop="keywords">La Liga</span>, <span itemprop="keywords">Serie A</span> etc.) and <span itemprop="keywords">MLS</span>. One can create tables for a given country/league and year selected, with some leagues having multiple tiers available, and stretching back many decades. Beyond that, one can get a specific team's historical finishing position, league games for a specific season, all-time tables, and all-time head-to-head results (within a league).
</span>
</span>
<span itemscope itemtype ="http://schema.org/WebApplication">
[<span itemprop="name">Bayesian Demonstration</span>](http://micl.shinyapps.io/prior2post/)
<span itemprop="description">A simple interactive demonstration for those just starting on their <span itemprop="keywords">Bayesian</span> journey.
</span>
</span>
<span itemscope itemtype ="http://schema.org/WebApplication">
[<span itemprop="name">A History of Tornados</span>](http://micl.shinyapps.io/tornados/)
<span itemprop="description">Because I had too much time on my hands and wanted to try out the <span itemprop="keywords">dashboard</span> feature of <span itemprop="keywords">R Markdown</span>. Maps <span itemprop="keywords">tornado</span> activity from 1950-2015. At some point I'll go back and fix the lag issue, but otherwise it's interesting data.
</span>
</span>
<span itemscope itemtype ="http://schema.org/ScholarlyArticle http://schema.org/TechArticle">
[<span itemprop="name">Last Statements of the Texas Executed</span>](http://micl.shinyapps.io/texEx/texEx.Rmd)
<span itemprop="description">A demonstration of both <span itemprop="keywords">text analysis</span> and <span itemprop="keywords">literate programming</span>/document generation with a dynamic and interactive research document. The texts regard the last statements of offenders in Texas.
</span>
</span>