Model and Likelihood
\[y = m * x + b\]
\[\mu = m * x + b\]
Likelihood
\[y = \mu + \epsilon\]
\[\epsilon \sim N(0, \sigma)\]
The slope, \(m\)
The intercept, \(b\)
The variability, \(\sigma\)
Collectively, \(\theta\)
\[P(Y | \theta)\]
\[P(Y | \theta, X)\]
\[P(\theta)\]
\[P(\theta | Y) = \frac{P(Y|\theta)P(\theta)}{P(Y)}\]
\[P(\theta | Y)\]
\[P(\theta | Y)\]
\[P(\theta | Y) = \frac{P(Y|\theta)P(\theta)}{P(Y)}\]
Metropolis-Hastings
Gibbs
curve(dnorm(x), xlim = c(-3, 3)
plot(density(rnorm(1000)), xlim = c(-3, 3))
Sample from the joint distribution, \(P(\theta, Y) = P(\theta)P(Y|\theta)\)
Reject when the sampled \(Y\) does not equal the observed
Cases where we can simulate data, we know the data generating process, but might have difficulty writing down a likelihood.
Write code in C++, call from R
Because C++ is faster than R
Not a new concept but Rcpp makes this much easier
uspop data in R
\[\frac{dp}{dt} = rp\]
\[p = p_0 e ^ {rt}\]
\[\frac{dp}{dt} = \frac{rp(K - p)}{K}\]
\[p = \frac{K}{1 + (K / p_0 - 1) e^ {- r t}}\]