Skip to content

Commit

Permalink
Change some css and add license
Browse files Browse the repository at this point in the history
  • Loading branch information
dirmeier committed Jun 4, 2020
1 parent e454d35 commit 4ff69ab
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 86 deletions.
70 changes: 23 additions & 47 deletions docs/custom.css
Original file line number Diff line number Diff line change
@@ -1,76 +1,52 @@
@import url('https://fonts.googleapis.com/css?family=Merriweather|Roboto|Inconsolata');


t {
font-family: "Lucida Console", Monaco, monospace;
}


.title {
font-family: "Lucida Console", Monaco, monospace;
font-size: 2.5em;
text-align: center;
}

.well {
white-space: pre;
word-wrap: break-word;
margin-top: 1.5rem;
margin-bottom: 0;
}

.MathJax_Display {
margin-top: 15px !important;
margin-bottom: 15px !important;
}

text {
font-family: "Lucida Console", Monaco, monospace;
}

body {
font-family: "Merriweather", serif;
font-size: 1.4rem !important;
color: black !important;
font-size: 14px !important;
color: #333333 !important;
line-height: 1.6 !important;
text-align: justify !important;
}


h1, h2, h3, h4, h5 {
font-family: "Merriweather", serif !important;
margin-top: 5% !important;
margin-bottom: 1% !important;
font-weight: 400 !important;
p {
color: #333333 !important;
}

h1, h2, h3 {
font-family: "Merriweather", serif !important;
font-style: italic;
font-weight: 400 !important;
margin-bottom: 2rem;
margin-top: 2rem;
line-height: 1.1 !important;
color: #333333 !important;
}


h1 {
margin-top: 1em !important;
font-size: 3.0rem !important;
line-height: 1.2 !important;
letter-spacing: -.1rem !important;
font-size: 3rem !important;
}


h2 {
font-size: 2.5rem !important;
line-height: 1.3 !important;
letter-spacing: -.1rem !important;
font-size: 2.5rem !important;
}


h3 {
font-size: 2.0rem !important;
line-height: 1.3 !important;
letter-spacing: -.1rem !important;
font-size: 2rem !important;
}

h4 {
font-size: 1.8rem !important;
line-height: 1.35 !important;
letter-spacing: -.08rem !important;
}

h5 {
font-size: 1.8rem !important;
line-height: 1.5 !important;
letter-spacing: -.05rem !important;
.blue, a, a:hover {
color: #1F407A;
}

64 changes: 33 additions & 31 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html>
<head><meta charset="utf-8" />

<title>mixed-models</title>
<title>Mixed models</title>

<script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.1.10/require.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
Expand Down Expand Up @@ -9129,15 +9129,15 @@
}
/* Flexible box model classes */
/* Taken from Alex Russell http://infrequently.org/2009/08/css-3-progress/ */
/* This file is a compatability layer. It allows the usage of flexible box
/* This file is a compatability layer. It allows the usage of flexible box
model layouts accross multiple browsers, including older browsers. The newest,
universal implementation of the flexible box model is used when available (see
`Modern browsers` comments below). Browsers that are known to implement this
`Modern browsers` comments below). Browsers that are known to implement this
new spec completely include:
Firefox 28.0+
Chrome 29.0+
Internet Explorer 11+
Internet Explorer 11+
Opera 17.0+
Browsers not listed, including Safari, are supported via the styling under the
Expand Down Expand Up @@ -12519,7 +12519,7 @@
background: #f7f7f7;
border-top: 1px solid #cfcfcf;
border-bottom: 1px solid #cfcfcf;
/* This injects handle bars (a short, wide = symbol) for
/* This injects handle bars (a short, wide = symbol) for
the resize handle. */
}
div#pager .ui-resizable-handle::after {
Expand Down Expand Up @@ -13033,14 +13033,14 @@
div.cell {
display: block;
page-break-inside: avoid;
}
div.output_wrapper {
}
div.output_wrapper {
display: block;
page-break-inside: avoid;
page-break-inside: avoid;
}
div.output {
div.output {
display: block;
page-break-inside: avoid;
page-break-inside: avoid;
}
}
</style>
Expand Down Expand Up @@ -13083,14 +13083,7 @@ <h1 id="Mixed-models">Mixed models<a class="anchor-link" href="#Mixed-models">&#
\end{align}<p>for data $(y_{ij}, \mathbf{x}_{ij})$ that is grouped into $i \in \{1, \dots, m \}$ groups (or clusters) and $j \in \{1, \dots, n_i\}$ observations per group. For an intro on the notation, usual assumptions, etc. please refer to <em>any</em> book on regression models, as this is not part of this notebook.</p>
<p>In the following we show, how $\boldsymbol \beta$ can be estimated and $\boldsymbol \gamma$ can be predicted for the Gaussian case and for the Poisson case. The implementations are not really efficient and don't use results from contemporary research (i.e., <code>lme4</code>'s PLS and PIRLS). Good references are for instance <a href="https://onlinelibrary.wiley.com/doi/book/10.1002/0471722073">McCulloch and Searle (2001)</a>, <a href="https://link.springer.com/book/10.1007/b98882">Pinheiro and Bates (2000)</a> and <a href="https://link.springer.com/book/10.1007/978-0-387-47946-0">Jiang (2007)</a>.</p>
<p>The relevant code can be found <a href="https://github.com/dirmeier/mixed-models">here</a>.</p>

</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>We first load some libraries we need.</p>
<p>Feedback and comments are welcome!</p>

</div>
</div>
Expand Down Expand Up @@ -13274,7 +13267,7 @@ <h2 id="Gaussian-LMMs">Gaussian LMMs<a class="anchor-link" href="#Gaussian-LMMs"
<div class="text_cell_render border-box-sizing rendered_html">
<p>To create the random effects matrix $\mathbf{U}$, let us first realize how $\mathbf{U}$ has to look: if we collect all cluster-specific responses $\mathbf{y}_i$ and the respective random effects $\boldsymbol \gamma_i$ into vectors, we get</p>
\begin{align}
\mathbf{y} =
\mathbf{y} =
\begin{pmatrix}
\mathbf{y}_1 \\
\vdots\\
Expand All @@ -13289,7 +13282,7 @@ <h2 id="Gaussian-LMMs">Gaussian LMMs<a class="anchor-link" href="#Gaussian-LMMs"
y_{m,n_m}
\end{pmatrix}
,\qquad
\boldsymbol \gamma =
\boldsymbol \gamma =
\begin{pmatrix}
\boldsymbol \gamma_{1}\\
\vdots\\
Expand Down Expand Up @@ -13525,7 +13518,7 @@ <h2 id="Gaussian-LMMs">Gaussian LMMs<a class="anchor-link" href="#Gaussian-LMMs"
<span class="n">opt</span> <span class="o">=</span> <span class="n">optim</span><span class="p">(</span><span class="n">fn</span><span class="p">,</span>
<span class="n">sp</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="mi">2</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mf">0.5</span><span class="p">,</span> <span class="mi">1</span><span class="p">]),</span>
<span class="p">((</span><span class="mf">0.01</span><span class="p">,</span> <span class="kc">None</span><span class="p">),</span> <span class="p">(</span><span class="kc">None</span><span class="p">,</span> <span class="kc">None</span><span class="p">),</span> <span class="p">(</span><span class="kc">None</span><span class="p">,</span> <span class="kc">None</span><span class="p">),</span> <span class="p">(</span><span class="kc">None</span><span class="p">,</span> <span class="kc">None</span><span class="p">)),</span>
<span class="n">args</span><span class="o">=</span><span class="p">(</span><span class="n">y</span><span class="p">,</span> <span class="n">X</span><span class="p">,</span> <span class="n">U</span><span class="p">))</span>
<span class="n">args</span><span class="o">=</span><span class="p">(</span><span class="n">y</span><span class="p">,</span> <span class="n">X</span><span class="p">,</span> <span class="n">U</span><span class="p">))</span>
<span class="n">sd_hat</span><span class="p">,</span> <span class="n">nu_hat</span> <span class="o">=</span> <span class="n">opt</span><span class="o">.</span><span class="n">x</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">opt</span><span class="o">.</span><span class="n">x</span><span class="p">[</span><span class="mi">1</span><span class="p">:]</span>
</pre></div>

Expand Down Expand Up @@ -13809,20 +13802,20 @@ <h3 id="Statsmodels">Statsmodels<a class="anchor-link" href="#Statsmodels">&#182
<div class="output_subarea output_stream output_stdout output_text">
<pre> Mixed Linear Model Regression Results
==========================================================
Model: MixedLM Dependent Variable: Reaction
No. Observations: 180 Method: REML
No. Groups: 18 Scale: 0.1045
Model: MixedLM Dependent Variable: Reaction
No. Observations: 180 Method: REML
No. Groups: 18 Scale: 0.1045
Min. group size: 10 Likelihood: -110.6631
Max. group size: 10 Converged: Yes
Mean group size: 10.0
Max. group size: 10 Converged: Yes
Mean group size: 10.0
----------------------------------------------------------
Coef. Std.Err. z P&gt;|z| [0.025 0.975]
----------------------------------------------------------
Intercept 2.027 0.058 34.921 0.000 1.913 2.140
Days 1.019 0.080 12.693 0.000 0.862 1.176
Group Var 0.025 0.068
Group x Days Cov 0.026 0.065
Days Var 0.115 0.130
Group Var 0.025 0.068
Group x Days Cov 0.026 0.065
Days Var 0.115 0.130
==========================================================

</pre>
Expand Down Expand Up @@ -13982,7 +13975,7 @@ <h2 id="Poisson-GLMMs">Poisson GLMMs<a class="anchor-link" href="#Poisson-GLMMs"
<span class="k">while</span> <span class="kc">True</span><span class="p">:</span>
<span class="n">y_tilde</span> <span class="o">=</span> <span class="n">working_response</span><span class="p">(</span><span class="n">y</span><span class="p">,</span> <span class="n">X</span><span class="p">,</span> <span class="n">U</span><span class="p">,</span> <span class="n">b_tilde</span><span class="p">,</span> <span class="n">g_tilde</span><span class="p">,</span> <span class="n">sp</span><span class="o">.</span><span class="n">exp</span><span class="p">,</span> <span class="n">sp</span><span class="o">.</span><span class="n">exp</span><span class="p">)</span>
<span class="n">w_tilde</span> <span class="o">=</span> <span class="n">working_weight</span><span class="p">(</span><span class="n">y</span><span class="p">,</span> <span class="n">X</span><span class="p">,</span> <span class="n">U</span><span class="p">,</span> <span class="n">b_tilde</span><span class="p">,</span> <span class="n">g_tilde</span><span class="p">,</span> <span class="n">sp</span><span class="o">.</span><span class="n">exp</span><span class="p">,</span> <span class="n">sp</span><span class="o">.</span><span class="n">exp</span><span class="p">)</span>

<span class="n">nu_hat</span> <span class="o">=</span> <span class="n">optim</span><span class="p">(</span><span class="n">fn</span><span class="p">,</span>
<span class="n">nu_hat</span><span class="p">,</span>
<span class="n">bounds</span><span class="o">=</span><span class="p">((</span><span class="kc">None</span><span class="p">,</span> <span class="kc">None</span><span class="p">),</span> <span class="p">(</span><span class="kc">None</span><span class="p">,</span> <span class="kc">None</span><span class="p">),</span> <span class="p">(</span><span class="kc">None</span><span class="p">,</span> <span class="kc">None</span><span class="p">)),</span>
Expand Down Expand Up @@ -14100,14 +14093,23 @@ <h2 id="Poisson-GLMMs">Poisson GLMMs<a class="anchor-link" href="#Poisson-GLMMs"
<div class="text_cell_render border-box-sizing rendered_html">
<h3 id="Statsmodels">Statsmodels<a class="anchor-link" href="#Statsmodels">&#182;</a></h3><p>Afaik <code>statsmodels</code> does not have implementations for frequentist GLMMS.</p>

</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h2 id="License">License<a class="anchor-link" href="#License">&#182;</a></h2><p><a rel="license" href="http://creativecommons.org/licenses/by-nc/4.0/"><img align="left" alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by-nc/4.0/88x31.png" /></a> <br></p>
<p>The case study is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc/4.0/">Creative Commons Attribution-NonCommercial 4.0 International License</a>.</p>

</div>
</div>
</div>
</div>
</div>
</body>




</html>
23 changes: 15 additions & 8 deletions docs/mixed-models.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,9 @@
"\n",
"In the following we show, how $\\boldsymbol \\beta$ can be estimated and $\\boldsymbol \\gamma$ can be predicted for the Gaussian case and for the Poisson case. The implementations are not really efficient and don't use results from contemporary research (i.e., `lme4`'s PLS and PIRLS). Good references are for instance [McCulloch and Searle (2001)](https://onlinelibrary.wiley.com/doi/book/10.1002/0471722073), [Pinheiro and Bates (2000)](https://link.springer.com/book/10.1007/b98882) and [Jiang (2007)](https://link.springer.com/book/10.1007/978-0-387-47946-0).\n",
"\n",
"The relevant code can be found [here](https://github.com/dirmeier/mixed-models)."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We first load some libraries we need."
"The relevant code can be found [here](https://github.com/dirmeier/mixed-models).\n",
"\n",
"Feedback and comments are welcome!"
]
},
{
Expand Down Expand Up @@ -832,6 +827,18 @@
"\n",
"Afaik `statsmodels` does not have implementations for frequentist GLMMS."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## License\n",
"\n",
"<a rel=\"license\" href=\"http://creativecommons.org/licenses/by-nc/4.0/\"><img align=\"left\" alt=\"Creative Commons License\" style=\"border-width:0\" src=\"https://i.creativecommons.org/l/by-nc/4.0/88x31.png\" /></a> <br>\n",
"\n",
"\n",
"The case study is licensed under a <a rel=\"license\" href=\"http://creativecommons.org/licenses/by-nc/4.0/\">Creative Commons Attribution-NonCommercial 4.0 International License</a>."
]
}
],
"metadata": {
Expand Down

0 comments on commit 4ff69ab

Please sign in to comment.