Is there a loss function when estimating a model using MCMC? I am trying to understand how fitting a model using MCMC works. Is there a loss function that is optimized? 
Or is it simply a case of more draws from the distribution amount to a more complete description of the posterior and therefore more accurate parameters? 
In particular I am referring to how a BSTS time series model is fitted using MCMC draws as described in Scott and Varian "Predicting the Present with Bayesian Structural Time Series", 2013. 
In that paper a state space model of a time series is described: 
$y_t = Z_t^T \alpha_t + \epsilon_t $. 
$\alpha_{t+1} = T_t \alpha_t + R_t\eta_t$ 
Let 
$\theta = (Z, T, R, \epsilon, \eta)$
and 
$\textbf{y} = y_1,....y_n$ their time series data. 
They then use MCMC to simulate the posterior distribution of the parameters of the model given their data $p(\theta|\textbf{y})$ - and presumably (they don't actually states this, I am assuming) they select $\theta$ that maximizes $p(\theta|\textbf{y})$. 
In R the BSTS model takes a number of MCMC draws as an input parameter - and I am trying to figure how to choose that number. 
If it is the second case (more draws = better simulation of the distribution), how do we decided the number of iterations and how do we avoid overfitting?
 A: For Bayesian estimation, the point of MCMC is only to simulate data from--and thereby obtain an estimate of--the posterior. In general, MCMC (Markov Chain Monte Carlo) only refers to generating realizations or simulating data from a probability model. This is necessary for Bayesian analyses where the posterior if often not solvable in a closed form. Gibbs Sampling is perhaps the most popular technique for obtaining a posterior and it happens to be MCMC, but there are other approaches. 
These simulation methods are imprecise, but we do not call this loss (in the same way that a blurry image could be called "lossy"). We call this precision. Increasing the number of iterations of Gibbs sampling will generally increase the precision with which the density of the posterior can be estimated. The lack of precision is called MCMC error.
Rather, loss is a general concept of Bayesian estimation. In practice, we make no distinction between posteriors which are estimated from MCMC or posteriors which are known in exact form when we discuss the loss of estimators. The risk (expected loss) is calculated the same way. Optimal Bayes estimators minimize risk. 
