Este taller está basado en los ejemplos del libro Data Analysis Using Regression and Multilevel/Hierarchical Models. Los autores del libro dispusieron los datos y los scripts de R en el siguiente enlace http://www.stat.columbia.edu/~gelman/arm/. Visite el enlace para descargar el material necesario.
Discrete probability simulation: suppose that a basketball player has a 60% chance of making a shot, and he keeps taking shots until he misses two in a row. Also assume his shots are independent (so that each shot has 60% probability of success, no matter what happened before). Simulate the process 1000 times. Use the simulation to estimate the mean, standard deviation, and distribution of the total number of shots that the player will take.
Simular \(n=500\) observaciones del siguiente modelo normal:
\[\begin{align*} y_i &\sim N(\mu_i, \sigma^2) \\ \mu_i &= 4 - 6 x_i \\ x_i &\sim U(-5, 6) \\ \sigma^2 &= 16 \end{align*}\]
\[\begin{align*} y_i &\sim N(\mu_i, \sigma^2_i) \\ \mu_i &= 4 - 6 x_{1i} \\ x_{1i} &\sim U(-3, 3) \\ \log(\sigma^2_i) &= 3 + 2 x_{1i} \end{align*}\]
\[\begin{align*} y_i &\sim Poisson(\lambda_i), \\ \log(\lambda_i) &= 2 + 0.5 x_{i}, \\ x_i &\sim U(0, 1). \end{align*}\]
\[\begin{align*} y_i &\sim Bernoulli(p_i) \\ \text{logit}(p_i) &= -1.4 + 0.33 \, x_{i} \\ x_{i} &\sim \text{Unif Disc} \{1, 2, 3, 4, 5\} \end{align*}\]