Skip to content

Commit

Permalink
all
Browse files Browse the repository at this point in the history
  • Loading branch information
dadosdelaplace committed Nov 17, 2024
1 parent c0b5292 commit 24e6729
Show file tree
Hide file tree
Showing 159 changed files with 10,317 additions and 580 deletions.
Binary file modified .DS_Store
Binary file not shown.
2,705 changes: 2,606 additions & 99 deletions R-biostats/diapos/index.html

Large diffs are not rendered by default.

3,768 changes: 3,766 additions & 2 deletions R-biostats/diapos/index.qmd

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified R-datascience/.DS_Store
Binary file not shown.
Binary file modified R-datascience/diapos/.DS_Store
Binary file not shown.
2,149 changes: 1,739 additions & 410 deletions R-datascience/diapos/index.html

Large diffs are not rendered by default.

2,107 changes: 2,089 additions & 18 deletions R-datascience/diapos/index.qmd

Large diffs are not rendered by default.

24 changes: 24 additions & 0 deletions biostats-ISCIII/diapos/datos/challenger.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
"flight" "date" "nfails.field" "nfails.nozzle" "fail.field" "fail.nozzle" "temp" "pres.field" "pres.nozzle"
"1" "12/04/81" 0 0 0 0 18.9 50 50
"2" "12/11/81" 1 0 1 0 21.1 50 50
"3" "22/03/82" 0 0 0 0 20.6 50 50
"5" "11/11/82" 0 0 0 0 20 50 50
"6" "04/04/83" 0 2 0 1 19.4 50 50
"7" "18/06/83" 0 0 0 0 22.2 50 50
"8" "30/08/83" 0 0 0 0 22.8 100 50
"9" "28/11/83" 0 0 0 0 21.1 100 100
"41-B" "03/02/84" 1 1 1 1 13.9 100 100
"41-C" "06/04/84" 1 1 1 1 17.2 200 200
"41-D" "30/08/84" 1 1 1 1 21.1 200 200
"41-G" "05/10/84" 0 0 0 0 25.6 200 200
"51-A" "08/11/84" 0 0 0 0 19.4 200 200
"51-C" "24/01/85" 2 2 1 1 11.7 200 200
"51-D" "12/04/85" 0 2 0 1 19.4 200 200
"51-B" "29/04/85" 0 2 0 1 23.9 200 100
"51-G" "17/06/85" 0 2 0 1 21.1 200 200
"51-F" "29/07/85" 0 0 0 0 27.2 200 200
"51-I" "27/08/85" 0 0 0 0 24.4 200 200
"51-J" "03/10/85" 0 0 0 0 26.1 200 200
"61-A" "30/10/85" 2 0 1 0 23.9 200 200
"61-B" "26/11/85" 0 2 0 1 24.4 200 200
"61-C" "12/01/86" 1 2 1 1 14.4 200 200
Binary file added biostats-ISCIII/diapos/datos/manif.rda
Binary file not shown.
Binary file added biostats-ISCIII/diapos/datos/titanic.RData
Binary file not shown.
Binary file modified biostats-ISCIII/material/.DS_Store
Binary file not shown.
24 changes: 24 additions & 0 deletions biostats-ISCIII/material/datos/challenger.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
"flight" "date" "nfails.field" "nfails.nozzle" "fail.field" "fail.nozzle" "temp" "pres.field" "pres.nozzle"
"1" "12/04/81" 0 0 0 0 18.9 50 50
"2" "12/11/81" 1 0 1 0 21.1 50 50
"3" "22/03/82" 0 0 0 0 20.6 50 50
"5" "11/11/82" 0 0 0 0 20 50 50
"6" "04/04/83" 0 2 0 1 19.4 50 50
"7" "18/06/83" 0 0 0 0 22.2 50 50
"8" "30/08/83" 0 0 0 0 22.8 100 50
"9" "28/11/83" 0 0 0 0 21.1 100 100
"41-B" "03/02/84" 1 1 1 1 13.9 100 100
"41-C" "06/04/84" 1 1 1 1 17.2 200 200
"41-D" "30/08/84" 1 1 1 1 21.1 200 200
"41-G" "05/10/84" 0 0 0 0 25.6 200 200
"51-A" "08/11/84" 0 0 0 0 19.4 200 200
"51-C" "24/01/85" 2 2 1 1 11.7 200 200
"51-D" "12/04/85" 0 2 0 1 19.4 200 200
"51-B" "29/04/85" 0 2 0 1 23.9 200 100
"51-G" "17/06/85" 0 2 0 1 21.1 200 200
"51-F" "29/07/85" 0 0 0 0 27.2 200 200
"51-I" "27/08/85" 0 0 0 0 24.4 200 200
"51-J" "03/10/85" 0 0 0 0 26.1 200 200
"61-A" "30/10/85" 2 0 1 0 23.9 200 200
"61-B" "26/11/85" 0 2 0 1 24.4 200 200
"61-C" "12/01/86" 1 2 1 1 14.4 200 200
Binary file added biostats-ISCIII/material/datos/manif.rda
Binary file not shown.
Binary file added biostats-ISCIII/material/datos/titanic.RData
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@ format:
> Descárgate el fichero `colesterol.csv`, muévelo a la carpeta de tu proyecto y carga el archivo. Carga antes las librerías que vayas a necesitar
```{r}
#| eval: false
library(...)
datos <- ...
library(readr)
datos <- read_csv(file = "./colesterol.csv")
datos
```

Expand All @@ -24,10 +23,10 @@ datos
> Usa tidyverse para limpair de ausentes tu variable objetivo (colesterol)
```{r}
#| eval: false
library(tidyverse)
datos <-
datos |>
...(colesterol)
drop_na(colesterol)
datos
```

Expand Down Expand Up @@ -72,8 +71,7 @@ modelo |> summary()

```{r}
#| eval: false
modelo <- ...
modelo <- lm(data = datos, formula = colesterol ~ edad + actividad_fisica)
modelo |> summary()
```

Expand Down Expand Up @@ -246,8 +244,8 @@ modelo |> summary()
El valor esperado de $Y$ es $\beta_0+\beta_1x_1 + ... = ... + ...*edad + ...$. Entonces si el paciente tuviera 51 años y actividad física de 2, su colesterol esperado sería de ...

```{r}
#| eval: false
predict(...)
predict(modelo, tibble("edad" = c(51, 15),
"actividad_fisica" = c(2, 4)))
```

> Haz otra predicción para un paciente de 15 años y actividad fisica de 4
Expand Down Expand Up @@ -275,7 +273,7 @@ modelo |> summary()
```{r}
#| eval: false
modelo_saturado <- ...
modelo_saturado <- lm(data = datos, formula = colesterol ~ .)
performance::compare_performance(modelo, modelo_saturado)
```

Expand All @@ -287,16 +285,29 @@ performance::compare_performance(modelo, modelo_saturado)
#| eval: false
datos_ruido_3 <-
datos |>
mutate("colesterol" = colesterol + rnorm(..., ..., sd = 3))
datos_ruido_7 <- ...
datos_ruido_15 <- ...
mutate("colesterol" = colesterol + rnorm(n = nrow(datos), mean = 0, sd = 3))
datos_ruido_7 <-
datos |>
mutate("colesterol" = colesterol + rnorm(n = nrow(datos), mean = 0, sd = 7))
datos_ruido_15 <-
datos |>
mutate("colesterol" = colesterol + rnorm(n = nrow(datos), mean = 0, sd = 15))
datos_ruido_25 <-
datos |>
mutate("colesterol" = colesterol + rnorm(n = nrow(datos), mean = 0, sd = 25))
modelo_ruido_3 <- ...
modelo_ruido_7 <- ...
modelo_ruido_15 <- ...
modelo_ruido_3 <- lm(data = datos_ruido_3,
formula = colesterol ~ edad + actividad_fisica)
modelo_ruido_7 <- lm(data = datos_ruido_7,
formula = colesterol ~ edad + actividad_fisica)
modelo_ruido_15 <- lm(data = datos_ruido_15,
formula = colesterol ~ edad + actividad_fisica)
modelo_ruido_25 <- lm(data = datos_ruido_25,
formula = colesterol ~ edad + actividad_fisica)
performance::compare_performance(modelo,
..., ..., ...)
modelo_ruido_3, modelo_ruido_7,
modelo_ruido_15, modelo_ruido_25)
```

Expand Down
66 changes: 33 additions & 33 deletions time-series/diapos/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1191,7 +1191,7 @@ <h2>Variables de fecha</h2>
<div class="cell">
<div class="sourceCode cell-code" id="cb42"><pre class="sourceCode numberSource r number-lines code-with-copy"><code class="sourceCode r"><span id="cb42-1"><a href="#cb42-1"></a><span class="fu">today</span>()</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-stdout">
<pre><code>[1] "2024-11-15"</code></pre>
<pre><code>[1] "2024-11-17"</code></pre>
</div>
</div>
<div class="fragment">
Expand All @@ -1201,7 +1201,7 @@ <h2>Variables de fecha</h2>
<div class="cell">
<div class="sourceCode cell-code" id="cb44"><pre class="sourceCode numberSource r number-lines code-with-copy"><code class="sourceCode r"><span id="cb44-1"><a href="#cb44-1"></a><span class="fu">now</span>()</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-stdout">
<pre><code>[1] "2024-11-15 15:16:14 CET"</code></pre>
<pre><code>[1] "2024-11-17 22:08:01 CET"</code></pre>
</div>
</div>
</div>
Expand Down Expand Up @@ -2673,12 +2673,12 @@ <h2>Evitando bucles</h2>
<span id="cb147-5"><a href="#cb147-5"></a> <span class="at">times =</span> <span class="dv">500</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-stdout">
<pre><code>Unit: microseconds
expr min lq mean
y &lt;- x^2 1.722 2.2755 3.079182
for (i in 1:100) { y[i] &lt;- x[i]^2 } 1368.908 1621.2425 2117.548976
median uq max neval
2.583 3.198 15.457 500
1757.198 1929.870 30093.672 500</code></pre>
expr min lq mean median
y &lt;- x^2 1.681 1.927 2.174722 2.050
for (i in 1:100) { y[i] &lt;- x[i]^2 } 1361.569 1382.622 1531.750488 1407.715
uq max neval
2.214 12.218 500
1480.818 4990.356 500</code></pre>
</div>
</div>
</section>
Expand Down Expand Up @@ -4749,18 +4749,18 @@ <h2>Sin tendencia</h2>
<span id="cb308-5"><a href="#cb308-5"></a>datos_tidy</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-stdout">
<pre><code># A tibble: 2,000 × 3
t X_t sd
&lt;int&gt; &lt;dbl&gt; &lt;chr&gt;
1 1 0.537 sd_0.5
2 2 -1.05 sd_0.5
3 3 -0.644 sd_0.5
4 4 0.117 sd_0.5
5 5 0.585 sd_0.5
6 6 -0.788 sd_0.5
7 7 -1.04 sd_0.5
8 8 -0.441 sd_0.5
9 9 0.109 sd_0.5
10 10 -0.0355 sd_0.5
t X_t sd
&lt;int&gt; &lt;dbl&gt; &lt;chr&gt;
1 1 -0.108 sd_0.5
2 2 -1.13 sd_0.5
3 3 -0.102 sd_0.5
4 4 -0.438 sd_0.5
5 5 -0.808 sd_0.5
6 6 -0.667 sd_0.5
7 7 -0.334 sd_0.5
8 8 0.658 sd_0.5
9 9 0.600 sd_0.5
10 10 0.218 sd_0.5
# ℹ 1,990 more rows</code></pre>
</div>
</div>
Expand Down Expand Up @@ -5142,18 +5142,18 @@ <h2>Recapitulando</h2>
<span id="cb323-12"><a href="#cb323-12"></a><span class="fu">ts_error</span>(<span class="at">n =</span> <span class="dv">100</span>, <span class="at">sd =</span> <span class="fu">c</span>(<span class="fl">0.5</span>, <span class="dv">2</span>))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-stdout">
<pre><code># A tibble: 200 × 3
t sd X_t
&lt;int&gt; &lt;glue&gt; &lt;dbl&gt;
1 1 sd_0.5 -0.105
2 2 sd_0.5 -0.161
3 3 sd_0.5 0.132
4 4 sd_0.5 -0.460
5 5 sd_0.5 0.0920
6 6 sd_0.5 -0.711
7 7 sd_0.5 1.27
8 8 sd_0.5 0.443
9 9 sd_0.5 0.155
10 10 sd_0.5 0.337
t sd X_t
&lt;int&gt; &lt;glue&gt; &lt;dbl&gt;
1 1 sd_0.5 0.136
2 2 sd_0.5 -0.705
3 3 sd_0.5 0.00306
4 4 sd_0.5 -0.519
5 5 sd_0.5 -0.758
6 6 sd_0.5 -0.301
7 7 sd_0.5 0.658
8 8 sd_0.5 -0.339
9 9 sd_0.5 0.240
10 10 sd_0.5 -0.0384
# ℹ 190 more rows</code></pre>
</div>
</div>
Expand Down Expand Up @@ -8685,7 +8685,7 @@ <h2>Procesos lineales</h2>
<h2>Procesos MA</h2>
<p><span class="math display">\[X_t = \sum_{j = -\infty}^{j=\infty} \Psi_j \varepsilon_{t-j}, \quad \sum_{j = -\infty}^{j=\infty} \left| \Psi_j \right| &lt; \infty, \quad \text{proceso lineal}\]</span></p>
<p>Uno de los tipos de procesos lineales más importantes son los conocidos como <span class="hl-yellow"><strong>procesos de medias moviles (MA)</strong></span> definidos como</p>
<p><span class="math display">\[X_t = \varepsilon - \theta_1 \varepsilon_{t-1} - \ldots - \theta_q \varepsilon_{t-q} \quad q \geq 1, \quad \left\lbrace \varepsilon_{t} \right\rbrace \text{ ruido blanco}\]</span></p>
<p><span class="math display">\[X_t = \varepsilon_t - \theta_1 \varepsilon_{t-1} - \ldots - \theta_q \varepsilon_{t-q} \quad q \geq 1, \quad \left\lbrace \varepsilon_{t} \right\rbrace \text{ ruido blanco}\]</span></p>
<p>donde <span class="math inline">\(q\)</span> será el <strong>orden</strong> (lo llamaremos <span class="hl-yellow"><strong>procesos de medias moviles de orden q o MA(q)</strong></span>). Si te fijas es un <strong>caso particular de proceso lineal</strong> donde todos los coeficientes son 0 salvo <span class="hl-green"><strong><span class="math inline">\(\left(\Psi_0 = 1, \Psi_1 = -\theta_1,\ldots, \Psi_q = -\theta_q \right)\)</span></strong></span>.</p>
</section>
<section id="procesos-ma-1" class="slide level2">
Expand Down
9 changes: 8 additions & 1 deletion time-series/diapos/index.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -8563,7 +8563,7 @@ $$X_t = \sum_{j = -\infty}^{j=\infty} \Psi_j \varepsilon_{t-j}, \quad \sum_{j =

Uno de los tipos de procesos lineales más importantes son los conocidos como [**procesos de medias moviles (MA)**]{.hl-yellow} definidos como

$$X_t = \varepsilon - \theta_1 \varepsilon_{t-1} - \ldots - \theta_q \varepsilon_{t-q} \quad q \geq 1, \quad \left\lbrace \varepsilon_{t} \right\rbrace \text{ ruido blanco}$$
$$X_t = \varepsilon_t - \theta_1 \varepsilon_{t-1} - \ldots - \theta_q \varepsilon_{t-q} \quad q \geq 1, \quad \left\lbrace \varepsilon_{t} \right\rbrace \text{ ruido blanco}$$

donde $q$ será el **orden** (lo llamaremos [**procesos de medias moviles de orden q o MA(q)**]{.hl-yellow}). Si te fijas es un **caso particular de proceso lineal** donde todos los coeficientes son 0 salvo [**$\left(\Psi_0 = 1, \Psi_1 = -\theta_1,\ldots, \Psi_q = -\theta_q \right)$**]{.hl-green}.

Expand Down Expand Up @@ -8962,3 +8962,10 @@ $$\begin{eqnarray}\rho_h = \frac{\gamma_h}{\gamma_0} = \begin{cases} 1 \quad & &
* simula varios y observa sus ACF

# Clases 18: [procesos MA]{.flow} {#clase-18}







0 comments on commit 24e6729

Please sign in to comment.