Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Book updated with minor edits in chapters 04, 05, 06, 13 and 14 #4

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion 404.html
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@
</ul></li>
<li class="chapter" data-level="13.5" data-path="modeling-continuous-relationships.html"><a href="modeling-continuous-relationships.html#objetivos-de-aprendizaje-12"><i class="fa fa-check"></i><b>13.5</b> Objetivos de aprendizaje</a></li>
<li class="chapter" data-level="13.6" data-path="modeling-continuous-relationships.html"><a href="modeling-continuous-relationships.html#lecturas-sugeridas-9"><i class="fa fa-check"></i><b>13.6</b> Lecturas sugeridas</a></li>
<li class="chapter" data-level="13.7" data-path="modeling-continuous-relationships.html"><a href="modeling-continuous-relationships.html#apéndice-4"><i class="fa fa-check"></i><b>13.7</b> Apéndice:</a>
<li class="chapter" data-level="13.7" data-path="modeling-continuous-relationships.html"><a href="modeling-continuous-relationships.html#apéndice-4"><i class="fa fa-check"></i><b>13.7</b> Apéndice</a>
<ul>
<li class="chapter" data-level="13.7.1" data-path="modeling-continuous-relationships.html"><a href="modeling-continuous-relationships.html#cuantificando-la-desigualdad-el-índice-gini"><i class="fa fa-check"></i><b>13.7.1</b> Cuantificando la desigualdad: El índice Gini</a></li>
<li class="chapter" data-level="13.7.2" data-path="modeling-continuous-relationships.html"><a href="modeling-continuous-relationships.html#análisis-de-correlación-bayesiana"><i class="fa fa-check"></i><b>13.7.2</b> Análisis de correlación bayesiana</a></li>
Expand Down
Binary file modified StatsThinking21.epub
Binary file not shown.
Binary file modified StatsThinking21.pdf
Binary file not shown.
124 changes: 51 additions & 73 deletions StatsThinking21.tex

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions bayesian-statistics.html
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@
</ul></li>
<li class="chapter" data-level="13.5" data-path="modeling-continuous-relationships.html"><a href="modeling-continuous-relationships.html#objetivos-de-aprendizaje-12"><i class="fa fa-check"></i><b>13.5</b> Objetivos de aprendizaje</a></li>
<li class="chapter" data-level="13.6" data-path="modeling-continuous-relationships.html"><a href="modeling-continuous-relationships.html#lecturas-sugeridas-9"><i class="fa fa-check"></i><b>13.6</b> Lecturas sugeridas</a></li>
<li class="chapter" data-level="13.7" data-path="modeling-continuous-relationships.html"><a href="modeling-continuous-relationships.html#apéndice-4"><i class="fa fa-check"></i><b>13.7</b> Apéndice:</a>
<li class="chapter" data-level="13.7" data-path="modeling-continuous-relationships.html"><a href="modeling-continuous-relationships.html#apéndice-4"><i class="fa fa-check"></i><b>13.7</b> Apéndice</a>
<ul>
<li class="chapter" data-level="13.7.1" data-path="modeling-continuous-relationships.html"><a href="modeling-continuous-relationships.html#cuantificando-la-desigualdad-el-índice-gini"><i class="fa fa-check"></i><b>13.7.1</b> Cuantificando la desigualdad: El índice Gini</a></li>
<li class="chapter" data-level="13.7.2" data-path="modeling-continuous-relationships.html"><a href="modeling-continuous-relationships.html#análisis-de-correlación-bayesiana"><i class="fa fa-check"></i><b>13.7.2</b> Análisis de correlación bayesiana</a></li>
Expand Down Expand Up @@ -548,10 +548,11 @@ <h2><span class="header-section-number">11.1</span> Modelos Generativos</h2>
<p>Digamos que estás caminando por la calle y unx amigx tuyx camina a tu lado pero no te saluda. Probablemente vas a tratar de decidir por qué pasó esto, ¿no te vieron? ¿están enojadxs contigo? ¿De repente traes una capa de invisibilidad y no te has dado cuenta? Una de las ideas básicas de la estadística Bayesiana es que queremos inferir los detalles de cómo son generados los datos, basándonos en los datos mismos. En este caso, tú quieres usar los datos (por ejemplo, el hecho de que tu amigx no te saludó), para inferir el proceso que generó esos datos (si de verdad no te vieron, cómo se sienten con respecto tuyo, etc.).</p>
<!--The idea behind a generative model is that a *latent* (unseen) process generates the data we observe, usually with some amount of randomness in the process. When we take a sample of data from a population and estimate a parameter from the sample, what we are doing in essence is trying to learn the value of a latent variable (the population mean) that gives rise through sampling to the observed data (the sample mean). Figure \@ref(fig:GenerativeModel) shows a schematic of this idea.-->
<p>La idea detrás de los modelos generativos es que un proceso <em>latente</em> (que no se ha visto) genera los datos que observamos, usualmente con una cantidad de aleatoridad en el proceso. Cuando tomamos una muestra de datos de una población y estimamos el parámetro a partir de la muestra, lo que estamos haciendo en esencia es tratar de conocer el valor de la variable latente (la media de la población), la cual da lugar a través del muestreo a los datos observados (la media de la muestra). La Figura <a href="bayesian-statistics.html#fig:GenerativeModel">11.1</a> muestra un esquema de esta idea.</p>
<!-- A schematic of the idea of a generative model. -->
<div class="figure"><span style="display:block;" id="fig:GenerativeModel"></span>
<img src="images/BayesianInference.png" alt="A schematic of the idea of a generative model." width="80%" />
<img src="images/BayesianInference.png" alt="Una representación esquematizada de la idea de un modelo generativo." width="80%" />
<p class="caption">
Figura 11.1: A schematic of the idea of a generative model.
Figura 11.1: Una representación esquematizada de la idea de un modelo generativo.
</p>
</div>
<!--If we know the value of the latent variable, then it's easy to reconstruct what the observed data should look like. For example, let's say that we are flipping a coin that we know to be fair, such that we would expect it to land on heads 50% of the time. We can describe the coin by a binomial distribution with a value of $P_{heads}=0.5$, and then we could generate random samples from such a distribution in order to see what the observed data should look like. However, in general we are in the opposite situation: We don't know the value of the latent variable of interest, but we have some data that we would like to use to estimate it.-->
Expand Down
2 changes: 1 addition & 1 deletion ci-effect-size-power.html
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@
</ul></li>
<li class="chapter" data-level="13.5" data-path="modeling-continuous-relationships.html"><a href="modeling-continuous-relationships.html#objetivos-de-aprendizaje-12"><i class="fa fa-check"></i><b>13.5</b> Objetivos de aprendizaje</a></li>
<li class="chapter" data-level="13.6" data-path="modeling-continuous-relationships.html"><a href="modeling-continuous-relationships.html#lecturas-sugeridas-9"><i class="fa fa-check"></i><b>13.6</b> Lecturas sugeridas</a></li>
<li class="chapter" data-level="13.7" data-path="modeling-continuous-relationships.html"><a href="modeling-continuous-relationships.html#apéndice-4"><i class="fa fa-check"></i><b>13.7</b> Apéndice:</a>
<li class="chapter" data-level="13.7" data-path="modeling-continuous-relationships.html"><a href="modeling-continuous-relationships.html#apéndice-4"><i class="fa fa-check"></i><b>13.7</b> Apéndice</a>
<ul>
<li class="chapter" data-level="13.7.1" data-path="modeling-continuous-relationships.html"><a href="modeling-continuous-relationships.html#cuantificando-la-desigualdad-el-índice-gini"><i class="fa fa-check"></i><b>13.7.1</b> Cuantificando la desigualdad: El índice Gini</a></li>
<li class="chapter" data-level="13.7.2" data-path="modeling-continuous-relationships.html"><a href="modeling-continuous-relationships.html#análisis-de-correlación-bayesiana"><i class="fa fa-check"></i><b>13.7.2</b> Análisis de correlación bayesiana</a></li>
Expand Down
14 changes: 7 additions & 7 deletions comparing-means.html
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@
</ul></li>
<li class="chapter" data-level="13.5" data-path="modeling-continuous-relationships.html"><a href="modeling-continuous-relationships.html#objetivos-de-aprendizaje-12"><i class="fa fa-check"></i><b>13.5</b> Objetivos de aprendizaje</a></li>
<li class="chapter" data-level="13.6" data-path="modeling-continuous-relationships.html"><a href="modeling-continuous-relationships.html#lecturas-sugeridas-9"><i class="fa fa-check"></i><b>13.6</b> Lecturas sugeridas</a></li>
<li class="chapter" data-level="13.7" data-path="modeling-continuous-relationships.html"><a href="modeling-continuous-relationships.html#apéndice-4"><i class="fa fa-check"></i><b>13.7</b> Apéndice:</a>
<li class="chapter" data-level="13.7" data-path="modeling-continuous-relationships.html"><a href="modeling-continuous-relationships.html#apéndice-4"><i class="fa fa-check"></i><b>13.7</b> Apéndice</a>
<ul>
<li class="chapter" data-level="13.7.1" data-path="modeling-continuous-relationships.html"><a href="modeling-continuous-relationships.html#cuantificando-la-desigualdad-el-índice-gini"><i class="fa fa-check"></i><b>13.7.1</b> Cuantificando la desigualdad: El índice Gini</a></li>
<li class="chapter" data-level="13.7.2" data-path="modeling-continuous-relationships.html"><a href="modeling-continuous-relationships.html#análisis-de-correlación-bayesiana"><i class="fa fa-check"></i><b>13.7.2</b> Análisis de correlación bayesiana</a></li>
Expand Down Expand Up @@ -590,7 +590,7 @@ <h2><span class="header-section-number">15.1</span> Probar el valor de una media
<p>Esto nos muestra que la media de presión sanguínea diastólica en la base de datos (69.5) es realmente mucho menor que 80, por lo que nuestra prueba sobre si la media es superior a 80 está muy lejos de resultar significativa.</p>
<!-- Remember that a large p-value doesn't provide us with evidence in favor of the null hypothesis, since we had already assumed that the null hypothesis is true to start with. However, as we discussed in the chapter on Bayesian analysis, we can use the Bayes factor to quantify evidence for or against the null hypothesis: -->
<p>Recuerda que un valor p grande no nos provee de evidencia en favor de la hipótesis nula, porque hemos asumido desde el inicio que la hipótesis nula es verdadera. Sin embargo, como discutimos en el capítulo sobre análisis Bayesiano, podemos usar el factor de Bayes para cuantificar la evidencia a favor o en contra de la hipótesis nula:</p>
<div class="sourceCode" id="cb31"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb31-1"><a href="comparing-means.html#cb31-1" aria-hidden="true" tabindex="-1"></a><span class="fu">ttestBF</span>(NHANES_sample<span class="sc">$</span>BPDiaAve, <span class="at">mu=</span><span class="dv">80</span>, <span class="at">nullInterval=</span><span class="fu">c</span>(<span class="sc">-</span><span class="cn">Inf</span>, <span class="dv">80</span>))</span></code></pre></div>
<div class="sourceCode" id="cb30"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb30-1"><a href="comparing-means.html#cb30-1" aria-hidden="true" tabindex="-1"></a><span class="fu">ttestBF</span>(NHANES_sample<span class="sc">$</span>BPDiaAve, <span class="at">mu=</span><span class="dv">80</span>, <span class="at">nullInterval=</span><span class="fu">c</span>(<span class="sc">-</span><span class="cn">Inf</span>, <span class="dv">80</span>))</span></code></pre></div>
<pre><code>## Bayes factor analysis
## --------------
## [1] Alt., r=0.707 -Inf&lt;d&lt;80 : 2.7e+16 ±NA%
Expand Down Expand Up @@ -871,11 +871,11 @@ <h2><span class="header-section-number">15.8</span> Apéndice</h2>
<h3><span class="header-section-number">15.8.1</span> La prueba t de muestras relacionadas como un modelo lineal</h3>
<!-- We can also define the paired t-test in terms of a general linear model. To do this, we include all of the measurements for each subject as data points (within a tidy data frame). We then include in the model a variable that codes for the identity of each individual (in this case, the ID variable that contains a subject ID for each person). This is known as a *mixed model*, since it includes effects of independent variables as well as effects of individuals. The standard model fitting procedure ```lm()``` can't do this, but we can do it using the ```lmer()``` function from a popular R package called *lme4*, which is specialized for estimating mixed models. The ```(1|ID)``` in the formula tells `lmer()` to estimate a separate intercept (which is what the ```1``` refers to) for each value of the ```ID``` variable (i.e. for each individual in the dataset), and then estimate a common slope relating timepoint to BP. -->
<p>También podemos definir la prueba t para muestras relacionadas en términos del modelo lineal general. Para hacer esto, incluimos todas las mediciones para cada participante como el conjunto de datos (dentro de un <em>dataframe</em> ordenado). Luego incluimos una variable en el modelo que codifique la identidad de cada persona (en este caso, la variable ID que contiene un ID para cada persona). Esto es conocido como un <em>modelo mixto</em>, porque incluye efectos de variables independientes así como efectos de individuos. El procedimiento para ajustar el modelo estándar <code>lm()</code> no puede hacer esto, pero podemos realizarlo usando la función <code>lmer()</code> del popular paquete <em>lme4</em> en R, que se especializa en estimar modelos mixtos. La parte <code>(1|ID)</code> en la fórmula le dice a la función <code>lmer()</code> que estime una constante separada (que es a lo que se refiere el <code>1</code>) para cada valor de la variable <code>ID</code> (i.e. para cada persona en el conjunto de datos), y luego que estime una pendiente común que relacione el momento en el tiempo con la presión sanguínea (BP, <em>blood pressure</em>).</p>
<div class="sourceCode" id="cb41"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb41-1"><a href="comparing-means.html#cb41-1" aria-hidden="true" tabindex="-1"></a><span class="co"># compute mixed model for paired test</span></span>
<span id="cb41-2"><a href="comparing-means.html#cb41-2" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb41-3"><a href="comparing-means.html#cb41-3" aria-hidden="true" tabindex="-1"></a>lmrResult <span class="ot">&lt;-</span> <span class="fu">lmer</span>(BPsys <span class="sc">~</span> timepoint <span class="sc">+</span> (<span class="dv">1</span> <span class="sc">|</span> ID), </span>
<span id="cb41-4"><a href="comparing-means.html#cb41-4" aria-hidden="true" tabindex="-1"></a> <span class="at">data =</span> NHANES_sample_tidy)</span>
<span id="cb41-5"><a href="comparing-means.html#cb41-5" aria-hidden="true" tabindex="-1"></a><span class="fu">summary</span>(lmrResult)</span></code></pre></div>
<div class="sourceCode" id="cb40"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb40-1"><a href="comparing-means.html#cb40-1" aria-hidden="true" tabindex="-1"></a><span class="co"># compute mixed model for paired test</span></span>
<span id="cb40-2"><a href="comparing-means.html#cb40-2" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb40-3"><a href="comparing-means.html#cb40-3" aria-hidden="true" tabindex="-1"></a>lmrResult <span class="ot">&lt;-</span> <span class="fu">lmer</span>(BPsys <span class="sc">~</span> timepoint <span class="sc">+</span> (<span class="dv">1</span> <span class="sc">|</span> ID), </span>
<span id="cb40-4"><a href="comparing-means.html#cb40-4" aria-hidden="true" tabindex="-1"></a> <span class="at">data =</span> NHANES_sample_tidy)</span>
<span id="cb40-5"><a href="comparing-means.html#cb40-5" aria-hidden="true" tabindex="-1"></a><span class="fu">summary</span>(lmrResult)</span></code></pre></div>
<pre><code>## Linear mixed model fit by REML. t-tests use Satterthwaite&#39;s method [
## lmerModLmerTest]
## Formula: BPsys ~ timepoint + (1 | ID)
Expand Down
6 changes: 3 additions & 3 deletions data-visualization.html
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@
</ul></li>
<li class="chapter" data-level="13.5" data-path="modeling-continuous-relationships.html"><a href="modeling-continuous-relationships.html#objetivos-de-aprendizaje-12"><i class="fa fa-check"></i><b>13.5</b> Objetivos de aprendizaje</a></li>
<li class="chapter" data-level="13.6" data-path="modeling-continuous-relationships.html"><a href="modeling-continuous-relationships.html#lecturas-sugeridas-9"><i class="fa fa-check"></i><b>13.6</b> Lecturas sugeridas</a></li>
<li class="chapter" data-level="13.7" data-path="modeling-continuous-relationships.html"><a href="modeling-continuous-relationships.html#apéndice-4"><i class="fa fa-check"></i><b>13.7</b> Apéndice:</a>
<li class="chapter" data-level="13.7" data-path="modeling-continuous-relationships.html"><a href="modeling-continuous-relationships.html#apéndice-4"><i class="fa fa-check"></i><b>13.7</b> Apéndice</a>
<ul>
<li class="chapter" data-level="13.7.1" data-path="modeling-continuous-relationships.html"><a href="modeling-continuous-relationships.html#cuantificando-la-desigualdad-el-índice-gini"><i class="fa fa-check"></i><b>13.7.1</b> Cuantificando la desigualdad: El índice Gini</a></li>
<li class="chapter" data-level="13.7.2" data-path="modeling-continuous-relationships.html"><a href="modeling-continuous-relationships.html#análisis-de-correlación-bayesiana"><i class="fa fa-check"></i><b>13.7.2</b> Análisis de correlación bayesiana</a></li>
Expand Down Expand Up @@ -632,7 +632,7 @@ <h3><span class="header-section-number">4.2.2</span> Maximiza la proporción dat
data/ink\ ratio = \frac{amount\, of\, ink\, used\, on\, data}{total\, amount\, of\, ink}
\]</span></p>
<!--The point of this is to minimize visual clutter and let the data show through. For example, take the two presentations of the dental health data in Figure \@ref(fig:dataInkExample). Both panels show the same data, but panel A is much easier to apprehend, because of its relatively higher data/ink ratio.-->
<p>El punto de esto es minimizar la contaminazión visual y permitir mostrar los datos. Por ejemplo, toma las dos presentaciones sobre la salud dental en la Figura <a href="data-visualization.html#fig:dataInkExample">4.5</a>. Ambos paneles muestran los mismos datos, pero el panel A es mucho más sencillo de comprender, porque es relativamente alta la proporción de datos/tinta.</p>
<p>El punto de esto es minimizar la contaminación visual y permitir mostrar los datos. Por ejemplo, toma las dos presentaciones sobre la salud dental en la Figura <a href="data-visualization.html#fig:dataInkExample">4.5</a>. Ambos paneles muestran los mismos datos, pero el panel A es mucho más sencillo de comprender, porque es relativamente alta la proporción de datos/tinta.</p>
<!-- An example of the same data plotted with two different data/ink ratios. -->
<div class="figure"><span style="display:block;" id="fig:dataInkExample"></span>
<img src="StatsThinking21_files/figure-html/dataInkExample-1.png" alt="Un ejemplo de los mismos datos graficados en dos porporciones datos/tinta diferentes." width="768" height="50%" />
Expand Down Expand Up @@ -708,7 +708,7 @@ <h3><span class="header-section-number">4.2.4</span> Evita distorsionar los dato
<div id="ajustarse-a-las-limitaciones-humanas" class="section level2" number="4.3">
<h2><span class="header-section-number">4.3</span> Ajustarse a las limitaciones humanas</h2>
<!--Humans have both perceptual and cognitive limitations that can make some visualizations very difficult to understand. It's always important to keep these in mind when building a visualization.-->
<p>Les humanes tienen limitaciones perceptuales y cognitivas que pueden hacer ciertas visializaciones difíciles de entender. Siempre es importante tener esto en cuenta cuando se construye una visualización.</p>
<p>Les humanes tienen limitaciones perceptuales y cognitivas que pueden hacer ciertas visualizaciones difíciles de entender. Siempre es importante tener esto en cuenta cuando se construye una visualización.</p>
<!--### Perceptual limitations-->
<div id="limitaciones-perceptuales" class="section level3" number="4.3.1">
<h3><span class="header-section-number">4.3.1</span> Limitaciones perceptuales</h3>
Expand Down
Loading