@@ -605,3 +605,33 @@ rejection_sample_vec <- function(n, f, M, r_m, batch_size = 10000) {
605605}
606606```
607607
608+ ## Statistical Monte Carlo Simulation
609+
610+ ### Why do we need simulation?
611+ - Imitate the real world
612+ - Test a statistical theory
613+ - Compute hard problems
614+
615+ ### Typical Statistical Inference
616+ - Sample: ` x = (x1, x2, ..., xn) ` taken from an unknown distribution
617+ - Statistic ` T(x) ` estimates some unknown parameter ` theta `
618+ - Inferences: Find the distribution of ` T(x) ` to make inferences about ` theta `
619+
620+ ### Typical Simulation Procedure
621+ - DGP (Data Generating Process): need to produce data x, need to know the population distribution and noise distribution
622+ - Choose a distribution as close to the real distribution as possible
623+ - Monte Carlo generate data from the ** known** distribution
624+ - Use ` arima.sim ` to generate data
625+ - Model: a specific model under consideration
626+ - ARMA, Markov Chain, stochastic process, regression etc.
627+ - For a given ` x ` and a ` theta ` , ` model(x, theta) ` returns specific values
628+ - Estimation: use model data to estimate ` theta `
629+ - An estimation procedure has been given
630+ - Carefully plan out and carry out computation
631+ - Further breakdown computation task if needed
632+ - Keep track of computing issues, such as mis-convergence, boundary issues, computation error, rounding error, prefer ` warning() ` function
633+ - Start the loop and carry out real simulation
634+ - Use ` print ` function to indicate progress
635+ - Output partial results to a file
636+ - Prefer ` replicate ` and ` apply ` function
637+ - Analyze simulation results
0 commit comments