Posted on Categories:Bayesian Analysis, 统计代写, 统计代考, 贝叶斯分析

## avatest™帮您通过考试

avatest™的各个学科专家已帮了学生顺利通过达上千场考试。我们保证您快速准时完成各时长和类型的考试，包括in class、take home、online、proctor。写手整理各样的资源来或按照您学校的资料教您，创造模拟试题，提供所有的问题例子，以保证您在真实考试中取得的通过率是85%以上。如果您有即将到来的每周、季考、期中或期末考试，我们都能帮助您！

•最快12小时交付

•200+ 英语母语导师

•70分以下全额退款

## 统计代写|贝叶斯分析代考Bayesian Analysis代写|Estimating a probability from binomial data

In the simple binomial model, the aim is to estimate an unknown population proportion from the results of a sequence of ‘Bernoulli trials’; that is, data $y_1, \ldots, y_n$, each of which is either 0 or 1 . This problem provides a relatively simple but important starting point for the discussion of Bayesian inference. By starting with the binomial model, our discussion also parallels the very first published Bayesian analysis by Thomas Bayes in 1763, and his seminal contribution is still of interest.

The binomial distribution provides a natural model for data that arise from a sequence of $n$ exchangeable trials or draws from a large population where each trial gives rise to one of two possible outcomes, conventionally labeled ‘success’ and ‘failure.’ Because of the exchangeability, the data can be summarized by the total number of successes in the $n$ trials, which we denote here by $y$. Converting from a formulation in terms of exchangeable trials to one using independent and identically distributed random variables is achieved naturally by letting the parameter $\theta$ represent the proportion of successes in the population or, equivalently, the probability of success in each trial. The binomial sampling model is,
$$p(y \mid \theta)=\operatorname{Bin}(y \mid n, \theta)=\left(\begin{array}{l} n \ y \end{array}\right) \theta^y(1-\theta)^{n-y},$$
where on the left side we suppress the dependence on $n$ because it is regarded as part of the experimental design that is considered fixed; all the probabilities discussed for this problem are assumed to be conditional on $n$.

## 统计代写|贝叶斯分析代考Bayesian Analysis代写|Example. Estimating the probability of a female birth

As a specific application of the binomial model, we consider the estimation of the sex ratio within a population of human births. The proportion of births that are female has long been a topic of interest both scientifically and to the lay public. Two hundred years ago it was established that the proportion of female births in European populations was less than 0.5 (see Historical Note below), while in this century interest has focused on factors that may influence the sex ratio. The currently accepted value of the proportion of female births in large European-race populations is 0.485 . For this example we define the parameter $\theta$ to be the proportion of female births, but an alternative way of reporting this parameter is as a ratio of male to female birth rates, $\phi=(1-\theta) / \theta$.
Let $y$ be the number of girls in $n$ recorded births. By applying the binomial model (2.1), we are assuming that the $n$ births are conditionally independent given $\theta$, with the probability of a female birth equal to $\theta$ for all cases. This modeling assumption is motivated by the exchangeability that may be judged to arise when we have no explanatory information (for example, distinguishing multiple births or births within the same family) that might affect the sex of the baby.
To perform Bayesian inference in the binomial model, we must specify a prior distribution for $\theta$. We will discuss issues associated with specifying prior distributions many times throughout this book, but for simplicity at this point, we assume that the prior distribution for $\theta$ is uniform on the interval $[0,1]$.

Elementary application of Bayes’ rule as displayed in (1.2), applied to (2.1), then gives the posterior density for $\theta$ as
$$p(\theta \mid y) \propto \theta^y(1-\theta)^{n-y}$$
With fixed $n$ and $y$, the factor $\left(\begin{array}{l}n \ y\end{array}\right)$ does not depend on the unknown parameter $\theta$, and so it can be treated as a constant when calculating the posterior distribution of $\theta$. As is typical of many examples, the posterior density can be written immediately in closed form, up to a constant of proportionality. In single-parameter problems, this allows immediate graphical presentation of the posterior distribution. For example, in Figure 2.1, the unnormalized density (2.2) is displayed for several different experiments, that is, different values of $n$ and $y$. Each of the four experiments has the same proportion of successes, but the sample sizes vary. In the present case, we can recognize $(2.2)$ as the unnormalized form of the beta distribution (see Appendix A),
$$\theta \mid y \sim \operatorname{Beta}(y+1, n-y+1) .$$

# 贝叶斯分析代写

## 统计代写|贝叶斯分析代考Bayesian Analysis代写|Estimating a probability from binomial data

$$p(y \mid \theta)=\operatorname{Bin}(y \mid n, \theta)=\left(\begin{array}{l} n \ y \end{array}\right) \theta^y(1-\theta)^{n-y},$$

## 统计代写|贝叶斯分析代考Bayesian Analysis代写|Example. Estimating the probability of a female birth

$$p(\theta \mid y) \propto \theta^y(1-\theta)^{n-y}$$

$$\theta \mid y \sim \operatorname{Beta}(y+1, n-y+1) .$$

avatest.org 为您提供可靠及专业的论文代写服务以便帮助您完成您学术上的需求，让您重新掌握您的人生。我们将尽力给您提供完美的论文，并且保证质量以及准时交稿。除了承诺的奉献精神，我们的专业写手、研究人员和校对员都经过非常严格的招聘流程。所有写手都必须证明自己的分析和沟通能力以及英文水平，并通过由我们的资深研究人员和校对员组织的面试。

## MATLAB代写

MATLAB 是一种用于技术计算的高性能语言。它将计算、可视化和编程集成在一个易于使用的环境中，其中问题和解决方案以熟悉的数学符号表示。典型用途包括：数学和计算算法开发建模、仿真和原型制作数据分析、探索和可视化科学和工程图形应用程序开发，包括图形用户界面构建MATLAB 是一个交互式系统，其基本数据元素是一个不需要维度的数组。这使您可以解决许多技术计算问题，尤其是那些具有矩阵和向量公式的问题，而只需用 C 或 Fortran 等标量非交互式语言编写程序所需的时间的一小部分。MATLAB 名称代表矩阵实验室。MATLAB 最初的编写目的是提供对由 LINPACK 和 EISPACK 项目开发的矩阵软件的轻松访问，这两个项目共同代表了矩阵计算软件的最新技术。MATLAB 经过多年的发展，得到了许多用户的投入。在大学环境中，它是数学、工程和科学入门和高级课程的标准教学工具。在工业领域，MATLAB 是高效研究、开发和分析的首选工具。MATLAB 具有一系列称为工具箱的特定于应用程序的解决方案。对于大多数 MATLAB 用户来说非常重要，工具箱允许您学习应用专业技术。工具箱是 MATLAB 函数（M 文件）的综合集合，可扩展 MATLAB 环境以解决特定类别的问题。可用工具箱的领域包括信号处理、控制系统、神经网络、模糊逻辑、小波、仿真等。

Posted on Categories:Bayesian Analysis, 统计代写, 统计代考, 贝叶斯分析

## avatest™帮您通过考试

avatest™的各个学科专家已帮了学生顺利通过达上千场考试。我们保证您快速准时完成各时长和类型的考试，包括in class、take home、online、proctor。写手整理各样的资源来或按照您学校的资料教您，创造模拟试题，提供所有的问题例子，以保证您在真实考试中取得的通过率是85%以上。如果您有即将到来的每周、季考、期中或期末考试，我们都能帮助您！

•最快12小时交付

•200+ 英语母语导师

•70分以下全额退款

## 统计代写|贝叶斯分析代考Bayesian Analysis代写|Example of probability assignment: football point spreads

As an example of how probabilities might be assigned using empirical data and plausible substantive assumptions, we consider methods of estimating the probabilities of certain outcomes in professional (American) football games. This is an example only of probability assignment, not of Bayesian inference. A number of approaches to assigning probabilities for football game outcomes are illustrated: making subjective assessments, using empirical probabilities based on observed data, and constructing a parametric probability model.

Football point spreads and game outcomes
Football experts provide a point spread for every football game as a measure of the difference in ability between the two teams. For example, team A might be a 3.5-point favorite to defeat team B. The implication of this point spread is that the proposition that team A, the favorite, defeats team $B$, the underdog, by 4 or more points is considered a fair bet; in other words, the probability that A wins by more than 3.5 points is $\frac{1}{2}$. If the point spread is an integer, then the implication is that team $\mathrm{A}$ is as likely to win by more points than the point spread as it is to win by fewer points than the point spread (or to lose); there is positive probability that A will win by exactly the point spread, in which case neither side is paid off. The assignment of point spreads is itself an interesting exercise in probabilistic reasoning; one interpretation is that the point spread is the median of the distribution of the gambling population’s beliefs about the possible outcomes of the game. For the rest of this example, we treat point spreads as given and do not worry about how they were derived.

The point spread and actual game outcome for 672 professional football games played during the 1981, 1983, and 1984 seasons are graphed in Figure 1.1. (Much of the 1982 season was canceled due to a labor dispute.) Each point in the scatterplot displays the point spread, $x$, and the actual outcome (favorite’s score minus underdog’s score), $y$. (In games with a point spread of zero, the labels ‘favorite’ and ‘underdog’ were assigned at random.) A small random jitter is added to the $x$ and $y$ coordinate of each point on the graph so that multiple points do not fall exactly on top of each other.

## 统计代写|贝叶斯分析代考Bayesian Analysis代写|Assigning probabilities based on observed frequencies

It is of interest to assign probabilities to particular events: $\operatorname{Pr}$ (favorite wins), $\operatorname{Pr}$ (favorite wins $\mid$ point spread is 3.5 points), $\operatorname{Pr}$ (favorite wins by more than the point spread), $\operatorname{Pr}$ (favorite wins by more than the point spread | point spread is 3.5 points), and so forth. We might report a subjective probability based on informal experience gathered by reading the newspaper and watching football games. The probability that the favored team wins a game should certainly be greater than 0.5 , perhaps between 0.6 and 0.75 ? More complex events require more intuition or knowledge on our part. A more systematic approach is to assign probabilities based on the data in Figure 1.1. Counting a tied game as one-half win and one-half loss, and ignoring games for which the point spread is zero (and thus there is no favorite), we obtain empirical estimates such as:

• $\operatorname{Pr}($ favorite wins $)=\frac{410.5}{655}=0.63$
• $\operatorname{Pr}($ favorite wins $\mid x=3.5)=\frac{36}{59}=0.61$
• $\operatorname{Pr}($ favorite wins by more than the point spread $)=\frac{308}{655}=0.47$
• $\operatorname{Pr}($ favorite wins by more than the point spread $\mid x=3.5)=\frac{32}{59}=0.54$.
These empirical probability assignments all seem sensible in that they match the intuition of knowledgeable football fans. However, such probability assignments are problematic for events with few directly relevant data points. For example, 8.5-point favorites won five out of five times during this three-year period, whereas 9-point favorites won thirteen out of twenty times. However, we realistically expect the probability of winning to be greater for a 9-point favorite than for an 8.5-point favorite. The small sample size with point spread 8.5 leads to imprecise probability assignments. We consider an alternative method using a parametric model.

# 贝叶斯分析代写

## 统计代写|贝叶斯分析代考Bayesian Analysis代写|Example of probability assignment: football point spreads

1981、1983和1984赛季的672场职业足球比赛的分差和实际比赛结果如图1.1所示。(由于劳资纠纷，1982年的大部分节目都被取消了。)散点图中的每个点都显示了点差($x$)和实际结果(最受欢迎的比分减去不受欢迎的比分)$y$。(在分差为0的游戏中，“最受欢迎”和“不受欢迎”的标签是随机分配的。)在图上每个点的$x$和$y$坐标上添加一个小的随机抖动，这样多个点就不会完全落在彼此的顶部。

## 统计代写|贝叶斯分析代考Bayesian Analysis代写|Assigning probabilities based on observed frequencies

$\operatorname{Pr}($ 热门胜利 $)=\frac{410.5}{655}=0.63$

$\operatorname{Pr}($ 热门胜利 $\mid x=3.5)=\frac{36}{59}=0.61$

$\operatorname{Pr}($ 热门队以超过分差的优势获胜 $)=\frac{308}{655}=0.47$

$\operatorname{Pr}($ 夺冠热门以超过分差$\mid x=3.5)=\frac{32}{59}=0.54$获胜。

avatest.org 为您提供可靠及专业的论文代写服务以便帮助您完成您学术上的需求，让您重新掌握您的人生。我们将尽力给您提供完美的论文，并且保证质量以及准时交稿。除了承诺的奉献精神，我们的专业写手、研究人员和校对员都经过非常严格的招聘流程。所有写手都必须证明自己的分析和沟通能力以及英文水平，并通过由我们的资深研究人员和校对员组织的面试。

## MATLAB代写

MATLAB 是一种用于技术计算的高性能语言。它将计算、可视化和编程集成在一个易于使用的环境中，其中问题和解决方案以熟悉的数学符号表示。典型用途包括：数学和计算算法开发建模、仿真和原型制作数据分析、探索和可视化科学和工程图形应用程序开发，包括图形用户界面构建MATLAB 是一个交互式系统，其基本数据元素是一个不需要维度的数组。这使您可以解决许多技术计算问题，尤其是那些具有矩阵和向量公式的问题，而只需用 C 或 Fortran 等标量非交互式语言编写程序所需的时间的一小部分。MATLAB 名称代表矩阵实验室。MATLAB 最初的编写目的是提供对由 LINPACK 和 EISPACK 项目开发的矩阵软件的轻松访问，这两个项目共同代表了矩阵计算软件的最新技术。MATLAB 经过多年的发展，得到了许多用户的投入。在大学环境中，它是数学、工程和科学入门和高级课程的标准教学工具。在工业领域，MATLAB 是高效研究、开发和分析的首选工具。MATLAB 具有一系列称为工具箱的特定于应用程序的解决方案。对于大多数 MATLAB 用户来说非常重要，工具箱允许您学习应用专业技术。工具箱是 MATLAB 函数（M 文件）的综合集合，可扩展 MATLAB 环境以解决特定类别的问题。可用工具箱的领域包括信号处理、控制系统、神经网络、模糊逻辑、小波、仿真等。

Posted on Categories:Bayesian Analysis, 统计代写, 统计代考, 贝叶斯分析

## avatest™帮您通过考试

avatest™的各个学科专家已帮了学生顺利通过达上千场考试。我们保证您快速准时完成各时长和类型的考试，包括in class、take home、online、proctor。写手整理各样的资源来或按照您学校的资料教您，创造模拟试题，提供所有的问题例子，以保证您在真实考试中取得的通过率是85%以上。如果您有即将到来的每周、季考、期中或期末考试，我们都能帮助您！

•最快12小时交付

•200+ 英语母语导师

•70分以下全额退款

## 统计代写|贝叶斯分析代考Bayesian Analysis代写|Parameters, data, and predictions

As general notation, we let $\theta$ denote unobservable vector quantities or population parameters of interest (such as the probabilities of survival under each treatment for randomly chosen members of the population in the example of the clinical trial), $y$ denote the observed data (such as the numbers of survivors and deaths in each treatment group), and $\tilde{y}$ denote unknown, but potentially observable, quantities (such as the outcomes of the patients under the other treatment, or the outcome under each of the treatments for a new patient similar to those already in the trial). In general these symbols represent multivariate quantities. We generally use Greek letters for parameters, lower case Roman letters for observed or observable scalars and vectors (and sometimes matrices), and upper case Roman letters for observed or observable matrices. When using matrix notation, we consider vectors as column vectors throughout; for example, if $u$ is a vector with $n$ components, then $u^T u$ is a scalar and $u u^T$ an $n \times n$ matrix.

Observational units and variables
In many statistical studies, data are gathered on each of a set of $n$ objects or units, and we can write the data as a vector, $y=\left(y_1, \ldots, y_n\right)$. In the clinical trial example, we might label $y_i$ as 1 if patient $i$ is alive after five years or 0 if the patient dies. If several variables are measured on each unit, then each $y_i$ is actually a vector, and the entire dataset $y$ is a matrix (usually taken to have $n$ rows). The $y$ variables are called the ‘outcomes’ and are considered ‘random’ in the sense that, when making inferences, we wish to allow for the possibility that the observed values of the variables could have turned out otherwise, due to the sampling process and the natural variation of the population.

## 统计代写|贝叶斯分析代考Bayesian Analysis代写|Exchangeability

The usual starting point of a statistical analysis is the (often tacit) assumption that the $n$ values $y_i$ may be regarded as exchangeable, meaning that we express uncertainty as a joint probability density $p\left(y_1, \ldots, y_n\right)$ that is invariant to permutations of the indexes. A nonexchangeable model would be appropriate if information relevant to the outcome were conveyed in the unit indexes rather than by explanatory variables (see below). The idea of exchangeability is fundamental to statistics, and we return to it repeatedly throughout the book.

We commonly model data from an exchangeable distribution as independently and identically distributed (iid) given some unknown parameter vector $\theta$ with distribution $p(\theta)$. In the clinical trial example, we might model the outcomes $y_i$ as iid, given $\theta$, the unknown probability of survival.

Explanatory variables
It is common to have observations on each unit that we do not bother to model as random. In the clinical trial example, such variables might include the age and previous health status of each patient in the study. We call this second class of variables explanatory variables, or covariates, and label them $x$. We use $X$ to denote the entire set of explanatory variables for all $n$ units; if there are $k$ explanatory variables, then $X$ is a matrix with $n$ rows and $k$ columns. Treating $X$ as random, the notion of exchangeability can be extended to require the distribution of the $n$ values of $(x, y)_i$ to be unchanged by arbitrary permutations of the indexes. It is always appropriate to assume an exchangeable model after incorporating sufficient relevant information in $X$ that the indexes can be thought of as randomly assigned. It follows from the assumption of exchangeability that the distribution of $y$, given $x$, is the same for all units in the study in the sense that if two units have the same value of $x$, then their distributions of $y$ are the same. Any of the explanatory variables $x$ can be moved into the $y$ category if we wish to model them. We discuss the role of explanatory variables (also called predictors) in detail in Chapter 8 in the context of analyzing surveys, experiments, and observational studies, and in the later parts of this book in the context of regression models.

# 贝叶斯分析代写

## 统计代写|贝叶斯分析代考Bayesian Analysis代写|Exchangeability

avatest.org 为您提供可靠及专业的论文代写服务以便帮助您完成您学术上的需求，让您重新掌握您的人生。我们将尽力给您提供完美的论文，并且保证质量以及准时交稿。除了承诺的奉献精神，我们的专业写手、研究人员和校对员都经过非常严格的招聘流程。所有写手都必须证明自己的分析和沟通能力以及英文水平，并通过由我们的资深研究人员和校对员组织的面试。

## MATLAB代写

MATLAB 是一种用于技术计算的高性能语言。它将计算、可视化和编程集成在一个易于使用的环境中，其中问题和解决方案以熟悉的数学符号表示。典型用途包括：数学和计算算法开发建模、仿真和原型制作数据分析、探索和可视化科学和工程图形应用程序开发，包括图形用户界面构建MATLAB 是一个交互式系统，其基本数据元素是一个不需要维度的数组。这使您可以解决许多技术计算问题，尤其是那些具有矩阵和向量公式的问题，而只需用 C 或 Fortran 等标量非交互式语言编写程序所需的时间的一小部分。MATLAB 名称代表矩阵实验室。MATLAB 最初的编写目的是提供对由 LINPACK 和 EISPACK 项目开发的矩阵软件的轻松访问，这两个项目共同代表了矩阵计算软件的最新技术。MATLAB 经过多年的发展，得到了许多用户的投入。在大学环境中，它是数学、工程和科学入门和高级课程的标准教学工具。在工业领域，MATLAB 是高效研究、开发和分析的首选工具。MATLAB 具有一系列称为工具箱的特定于应用程序的解决方案。对于大多数 MATLAB 用户来说非常重要，工具箱允许您学习应用专业技术。工具箱是 MATLAB 函数（M 文件）的综合集合，可扩展 MATLAB 环境以解决特定类别的问题。可用工具箱的领域包括信号处理、控制系统、神经网络、模糊逻辑、小波、仿真等。

Posted on Categories:Bayesian Analysis, 统计代写, 统计代考, 贝叶斯分析

## avatest™帮您通过考试

avatest™的各个学科专家已帮了学生顺利通过达上千场考试。我们保证您快速准时完成各时长和类型的考试，包括in class、take home、online、proctor。写手整理各样的资源来或按照您学校的资料教您，创造模拟试题，提供所有的问题例子，以保证您在真实考试中取得的通过率是85%以上。如果您有即将到来的每周、季考、期中或期末考试，我们都能帮助您！

•最快12小时交付

•200+ 英语母语导师

•70分以下全额退款

## 统计代写|贝叶斯分析代考Bayesian Analysis代写|Alternative solution

The above results can also be obtained by working through in the style of the solutions to previous exercises, as follows. Before the data is observed, the Bayesian model may be written:
\begin{aligned} & f(s \mid y, \theta)=\left(\begin{array}{l} N \ n \end{array}\right)^{-1}=\left(\begin{array}{l} 4 \ 2 \end{array}\right)^{-1}=\frac{1}{6}, \ & s=(1,2),(1,3),(1,4),(2,3),(2,4),(3,4) \ & f(y \mid \theta)=\frac{1}{4}, \quad y=(\theta, \theta, \theta, \theta),(\theta, \theta, \theta, 1-\theta), \ & (\theta, \theta, 1-\theta, 1-\theta),(\theta, 1-\theta, 1-\theta, 1-\theta) \ & f(\theta)=1 / 2, \theta=0,1 \quad \text { (the prior density of the parameter). } \end{aligned}
(the prior density of the parameter).
The observed data is $D=\left(s, y_s\right)=((2,3),(1,1))$. At this particular value of the data:
$f(s \mid y, \theta)=\frac{1}{6}, s=(2,3) \quad$ (the value of $s$ actually observed)
$f(y \mid \theta)=\frac{1}{4}, \quad y=(0,1,1,1)$ and $\theta=0$,
$y \in{(1,1,1,1),(1,1,1,0)}$ and $\theta=1$ (where we need only consider values of $y$ consistent with the data)
$f(\theta)=1 / 2, \theta=0,1 \quad$ (since both values of $\theta$ are still possible, i.e. consistent with the observed data).
With the quantities $s=(2,3), y_s=\left(y_2, y_3\right)=(1,1)$ and $y_r=\left(y_1, y_4\right)$ all fixed at these values, the joint density of all quantities in the model may be written
\begin{aligned} & f(\theta, s, y)=f\left(\theta, s, y_s, y_r\right)=f(\theta) f\left(y_s, y_r \mid \theta\right) f\left(s \mid y_s, y_r, \theta\right) \ & =\frac{I(\theta \in{0,1})}{2} \times \frac{I(y=(0,1,1,1), \theta=0)+I(y \in{(1,1,1,1),(1,1,1,0)}, \theta=1)}{4} \times \frac{1}{6} \ & \theta, y_r \ & \propto I\left(y_r=(0,1), \theta=0\right)+I\left(y_r \in{(1,1),(1,0)}, \theta=1\right) \text {. } \ & \end{aligned}

## 统计代写|贝叶斯分析代考Bayesian Analysis代写|The case of SRSWR

In the case of SRSWR, the sampling density
$$f(I \mid y, \lambda)=\frac{n !}{\prod_{i=1}^N I_i} \prod_{i=1}^N\left(\frac{y_i}{y_T}\right)^{I_i}$$
changes to
$$f(I \mid y, \lambda)=\frac{n !}{\prod_{i=1}^N I_i} \prod_{i=1}^N\left(\frac{1}{N}\right)^{I_i}=\frac{n !}{N^n \prod_{i=1}^N I_i},$$
which we note does not depend on $\lambda$ or $y_{r T}$ and so can be ‘ignored’.
The result is then almost the same as before, the only difference being that the term
$$\prod_{i=1}^N y_T^{L_i}=y_T^n=\left(y_{s T}+y_{r T}\right)^n$$
in
$$k\left(y_{r T}\right)=\left(\frac{N-d}{N+\tau}\right)^{y_{r T}} \frac{\Gamma\left(\eta+y_{s T}+y_{r T}\right)}{y_{r T} !\left(y_{s T}+y_{r T}\right)^n}$$
is replaced by 1 .
Thus under SRSWR we find that
$$f\left(y_{r T} \mid D\right)=\frac{K\left(y_{r T}\right)}{C}, y_{r T}=0,1,2, \ldots,$$
where
$$K\left(y_{r T}\right)=\left(\frac{N-d}{N+\tau}\right)^{y_{r T}} \frac{\Gamma\left(\eta+y_{s T}+y_{r T}\right)}{y_{r T} ! \times 1}$$
and
$$C=\sum_{y_{r r}=0}^{\infty} K\left(y_{r T}\right) .$$
As regards the posterior distribution of $\lambda$ under SRSWR, this need no longer be expressed as an infinite mixture of gamma distributions but simply as
$$(\lambda \mid D) \sim G\left(\eta+y_{s T}, \tau+d\right)$$

# 贝叶斯分析代写

## 统计代写|贝叶斯分析代考Bayesian Analysis代写|Alternative solution

\begin{aligned} & f(s \mid y, \theta)=\left(\begin{array}{l} N \ n \end{array}\right)^{-1}=\left(\begin{array}{l} 4 \ 2 \end{array}\right)^{-1}=\frac{1}{6}, \ & s=(1,2),(1,3),(1,4),(2,3),(2,4),(3,4) \ & f(y \mid \theta)=\frac{1}{4}, \quad y=(\theta, \theta, \theta, \theta),(\theta, \theta, \theta, 1-\theta), \ & (\theta, \theta, 1-\theta, 1-\theta),(\theta, 1-\theta, 1-\theta, 1-\theta) \ & f(\theta)=1 / 2, \theta=0,1 \quad \text { (the prior density of the parameter). } \end{aligned}
(参数的先验密度)。

$f(s \mid y, \theta)=\frac{1}{6}, s=(2,3) \quad$(实际观察到的$s$的值)
$f(y \mid \theta)=\frac{1}{4}, \quad y=(0,1,1,1)$和$\theta=0$，
$y \in{(1,1,1,1),(1,1,1,0)}$和$\theta=1$(我们只需要考虑$y$与数据一致的值)
$f(\theta)=1 / 2, \theta=0,1 \quad$(因为$\theta$的两个值仍然是可能的，即与观测数据一致)。

\begin{aligned} & f(\theta, s, y)=f\left(\theta, s, y_s, y_r\right)=f(\theta) f\left(y_s, y_r \mid \theta\right) f\left(s \mid y_s, y_r, \theta\right) \ & =\frac{I(\theta \in{0,1})}{2} \times \frac{I(y=(0,1,1,1), \theta=0)+I(y \in{(1,1,1,1),(1,1,1,0)}, \theta=1)}{4} \times \frac{1}{6} \ & \theta, y_r \ & \propto I\left(y_r=(0,1), \theta=0\right)+I\left(y_r \in{(1,1),(1,0)}, \theta=1\right) \text {. } \ & \end{aligned}

## 统计代写|贝叶斯分析代考Bayesian Analysis代写|The case of SRSWR

$$f(I \mid y, \lambda)=\frac{n !}{\prod_{i=1}^N I_i} \prod_{i=1}^N\left(\frac{y_i}{y_T}\right)^{I_i}$$

$$f(I \mid y, \lambda)=\frac{n !}{\prod_{i=1}^N I_i} \prod_{i=1}^N\left(\frac{1}{N}\right)^{I_i}=\frac{n !}{N^n \prod_{i=1}^N I_i},$$

$$\prod_{i=1}^N y_T^{L_i}=y_T^n=\left(y_{s T}+y_{r T}\right)^n$$

$$k\left(y_{r T}\right)=\left(\frac{N-d}{N+\tau}\right)^{y_{r T}} \frac{\Gamma\left(\eta+y_{s T}+y_{r T}\right)}{y_{r T} !\left(y_{s T}+y_{r T}\right)^n}$$

$$f\left(y_{r T} \mid D\right)=\frac{K\left(y_{r T}\right)}{C}, y_{r T}=0,1,2, \ldots,$$

$$K\left(y_{r T}\right)=\left(\frac{N-d}{N+\tau}\right)^{y_{r T}} \frac{\Gamma\left(\eta+y_{s T}+y_{r T}\right)}{y_{r T} ! \times 1}$$

$$C=\sum_{y_{r r}=0}^{\infty} K\left(y_{r T}\right) .$$

$$(\lambda \mid D) \sim G\left(\eta+y_{s T}, \tau+d\right)$$

avatest.org 为您提供可靠及专业的论文代写服务以便帮助您完成您学术上的需求，让您重新掌握您的人生。我们将尽力给您提供完美的论文，并且保证质量以及准时交稿。除了承诺的奉献精神，我们的专业写手、研究人员和校对员都经过非常严格的招聘流程。所有写手都必须证明自己的分析和沟通能力以及英文水平，并通过由我们的资深研究人员和校对员组织的面试。

## MATLAB代写

MATLAB 是一种用于技术计算的高性能语言。它将计算、可视化和编程集成在一个易于使用的环境中，其中问题和解决方案以熟悉的数学符号表示。典型用途包括：数学和计算算法开发建模、仿真和原型制作数据分析、探索和可视化科学和工程图形应用程序开发，包括图形用户界面构建MATLAB 是一个交互式系统，其基本数据元素是一个不需要维度的数组。这使您可以解决许多技术计算问题，尤其是那些具有矩阵和向量公式的问题，而只需用 C 或 Fortran 等标量非交互式语言编写程序所需的时间的一小部分。MATLAB 名称代表矩阵实验室。MATLAB 最初的编写目的是提供对由 LINPACK 和 EISPACK 项目开发的矩阵软件的轻松访问，这两个项目共同代表了矩阵计算软件的最新技术。MATLAB 经过多年的发展，得到了许多用户的投入。在大学环境中，它是数学、工程和科学入门和高级课程的标准教学工具。在工业领域，MATLAB 是高效研究、开发和分析的首选工具。MATLAB 具有一系列称为工具箱的特定于应用程序的解决方案。对于大多数 MATLAB 用户来说非常重要，工具箱允许您学习应用专业技术。工具箱是 MATLAB 函数（M 文件）的综合集合，可扩展 MATLAB 环境以解决特定类别的问题。可用工具箱的领域包括信号处理、控制系统、神经网络、模糊逻辑、小波、仿真等。

Posted on Categories:Bayesian Analysis, 统计代写, 统计代考, 贝叶斯分析

## avatest™帮您通过考试

avatest™的各个学科专家已帮了学生顺利通过达上千场考试。我们保证您快速准时完成各时长和类型的考试，包括in class、take home、online、proctor。写手整理各样的资源来或按照您学校的资料教您，创造模拟试题，提供所有的问题例子，以保证您在真实考试中取得的通过率是85%以上。如果您有即将到来的每周、季考、期中或期末考试，我们都能帮助您！

•最快12小时交付

•200+ 英语母语导师

•70分以下全额退款

## 统计代写|贝叶斯分析代考Bayesian Analysis代写|A first tutorial in BUGS

Consider the following Bayesian model:
\begin{aligned} & y_1, \ldots, y_n \mid \mu, \tau \sim \text { iid } \operatorname{Normal}\left(\mu, \sigma^2\right) \quad\left(\tau=1 / \sigma^2\right) \ & \mu \mid \tau \sim \operatorname{Normal}\left(\mu_0, \sigma_0^2\right) \ & \tau \sim \operatorname{Gamma}(\alpha, \beta) \quad(E \tau=\alpha / \beta) \end{aligned}
where $\mu_0=0, \sigma_0^2=10,000$ and $\alpha=\beta=0.001$.
Suppose the data is $y=\left(y_1, \ldots, y_n\right)=(2.4,1.2,5.3,1.1,3.9,2.0)$, and we wish to find the posterior mean and $95 \%$ posterior interval for each of $\mu$ and $\gamma=\mu \sqrt{\tau}$ (the signal to noise ratio).

To perform this in WinBUGS 1.4.3, open a new window (select ‘File’ and then ‘New’ in the BUGS toolbar), and type the following BUGS code:
model
{
for $($ i in $1: n){$
$y[i] \sim \operatorname{dnorm}(\mathrm{mu}$, tau $)$
}
mu $\sim$ dnorm( $(0,0.0001)$
tau $\sim$ dgamma(0.001, 0.001)
gam <- musqrt(tau) } list $(n=6, y=c(2.4,1.2,5.3,1.1,3.9,2.0))$ list(tau=1) model { for(i in 1:n){ $y[i] \sim \operatorname{dnorm}(\mathrm{mu}, \mathrm{tau})$ } $\mathrm{mu} \sim \operatorname{dnorm}(0,0.0001)$ tau dgamma(0.001, 0.001) gam <- musqrt(tau)
}
list $(n=6, y=c(2.4,1.2,5 \cdot 3,1.1,3.9,2.0))$
list(tau=1)
Alternatively, copy this text from a Word document into a Notepad file, and then copy the text from the Notepad file into the WinBUGS window.

## 统计代写|贝叶斯分析代考Bayesian Analysis代写|Tutorial on calling BUGS in R

The following is a short tutorial on how WinBUGS can be called within an R session. Some of the details may need to be changed depending on the configuration of files and directories in the computer being used.
First, assume that $\mathrm{R}$ (v3.01) is installed in C:/R-3.0.1
Also assume that WinBUGS (v4.1.3) is installed in C:/WinBUGS14
Open R and type
install.packages(“R2WinBUGS”)
Note: You must have a connection to the internet for this to work. This command is required only once for each installed version of $R$.

Next, select a CRAN mirror when prompted. ‘Melbourne’ should work.
You should then see something like the following:
package ‘coda’ successfully unpacked and MD5 sums checked
package ‘R2WinBUGS’ successfully unpacked and MD5 sums checked, etc.
Then type
library(“R2WinBUGS”)
Note: This loads the necessary functions and must be done at the beginning of each R session in which WinBUGS is to be called.

You should now see something like:

# 贝叶斯分析代写

## 统计代写|贝叶斯分析代考Bayesian Analysis代写|A first tutorial in BUGS

\begin{aligned} & y_1, \ldots, y_n \mid \mu, \tau \sim \text { iid } \operatorname{Normal}\left(\mu, \sigma^2\right) \quad\left(\tau=1 / \sigma^2\right) \ & \mu \mid \tau \sim \operatorname{Normal}\left(\mu_0, \sigma_0^2\right) \ & \tau \sim \operatorname{Gamma}(\alpha, \beta) \quad(E \tau=\alpha / \beta) \end{aligned}

{对于}{$1: n){$}{中的}{$($}{ I
}{$y[i] \sim \operatorname{dnorm}(\mathrm{mu}$}{, tau }{$)$}{

}Mu$\sim$ dnorm($(0,0.0001)$
Tau $\sim$ dgamma(0.001, 0.001)
Gam <- musqrt(tau)｝ list $(n=6, y=c(2.4,1.2,5.3,1.1,3.9,2.0))$ list(tau=1) model for{(i in 1:n){$y[i] \sim \operatorname{dnorm}(\mathrm{mu}, \mathrm{tau})$}$\mathrm{mu} \sim \operatorname{dnorm}(0,0.0001)$ tau dgamma(0.001, 0.001) Gam <- musqrt(tau))

}清单$(n=6, y=c(2.4,1.2,5 \cdot 3,1.1,3.9,2.0))$
list(tau=1) 或者，将

## 统计代写|贝叶斯分析代考Bayesian Analysis代写|Tutorial on calling BUGS in R

install.packages(“R2WinBUGS”)

avatest.org 为您提供可靠及专业的论文代写服务以便帮助您完成您学术上的需求，让您重新掌握您的人生。我们将尽力给您提供完美的论文，并且保证质量以及准时交稿。除了承诺的奉献精神，我们的专业写手、研究人员和校对员都经过非常严格的招聘流程。所有写手都必须证明自己的分析和沟通能力以及英文水平，并通过由我们的资深研究人员和校对员组织的面试。

## MATLAB代写

MATLAB 是一种用于技术计算的高性能语言。它将计算、可视化和编程集成在一个易于使用的环境中，其中问题和解决方案以熟悉的数学符号表示。典型用途包括：数学和计算算法开发建模、仿真和原型制作数据分析、探索和可视化科学和工程图形应用程序开发，包括图形用户界面构建MATLAB 是一个交互式系统，其基本数据元素是一个不需要维度的数组。这使您可以解决许多技术计算问题，尤其是那些具有矩阵和向量公式的问题，而只需用 C 或 Fortran 等标量非交互式语言编写程序所需的时间的一小部分。MATLAB 名称代表矩阵实验室。MATLAB 最初的编写目的是提供对由 LINPACK 和 EISPACK 项目开发的矩阵软件的轻松访问，这两个项目共同代表了矩阵计算软件的最新技术。MATLAB 经过多年的发展，得到了许多用户的投入。在大学环境中，它是数学、工程和科学入门和高级课程的标准教学工具。在工业领域，MATLAB 是高效研究、开发和分析的首选工具。MATLAB 具有一系列称为工具箱的特定于应用程序的解决方案。对于大多数 MATLAB 用户来说非常重要，工具箱允许您学习应用专业技术。工具箱是 MATLAB 函数（M 文件）的综合集合，可扩展 MATLAB 环境以解决特定类别的问题。可用工具箱的领域包括信号处理、控制系统、神经网络、模糊逻辑、小波、仿真等。

Posted on Categories:Bayesian Analysis, 统计代写, 统计代考, 贝叶斯分析

## avatest™帮您通过考试

avatest™的各个学科专家已帮了学生顺利通过达上千场考试。我们保证您快速准时完成各时长和类型的考试，包括in class、take home、online、proctor。写手整理各样的资源来或按照您学校的资料教您，创造模拟试题，提供所有的问题例子，以保证您在真实考试中取得的通过率是85%以上。如果您有即将到来的每周、季考、期中或期末考试，我们都能帮助您！

•最快12小时交付

•200+ 英语母语导师

•70分以下全额退款

## 统计代写|贝叶斯分析代考Bayesian Analysis代写|Non-symmetric drivers and the general Metropolis algorithm

In some cases, applying the Metropolis algorithm as described above may lead to poor mixing, even after experimentation to decide on the most suitable value of the tuning constant.

For example, if the random variable of interest is strictly positive with a pdf $f(x)$ which is positively skewed and highly concentrated just above 0 (for example, if $f(x) \rightarrow \infty$ as $x \downarrow 0$ ), proposing a value symmetrically distributed around the last value may lead to many candidate values which are negative and therefore automatically rejected.

In such cases, the support of $X$ may not be properly represented, and it may be preferable to choose a different type of driver distribution, one which adapts ‘cleverly’ to the current state of the Markov chain.

This can be achieved using the general Metropolis algorithm which allows for non-symmetric driver distributions. As before, let $g(t \mid x)$ denote a driver density, where $t$ denotes the proposed value and $x$ is the last value in the chain. Then at iteration $j$, after generating a proposed value from the driver distribution,
$$x_j^{\prime} \sim g\left(t \mid x=x_{j-1}\right),$$
the acceptance probability is
$$p=\frac{f\left(x_j^{\prime}\right)}{f\left(x_{j-1}\right)} \times \frac{g\left(x_{j-1} \mid x_j^{\prime}\right)}{g\left(x_j^{\prime} \mid x_{j-1}\right)} .$$

Note 1: Previously, when $g(t \mid x)$ was assumed to be symmetric,
$$\frac{g\left(x_{j-1} \mid x_j^{\prime}\right)}{g\left(x_j^{\prime} \mid x_{j-1}\right)}=1 \text {. }$$
Note 2: To calculate $p$, the best strategy is to let
$$p=\exp (q)$$
after first computing
\begin{aligned} q & =\log f\left(x_j^{\prime}\right)-\log f\left(x_{j-1}\right) \ & +\log g\left(x_{j-1} \mid x_j^{\prime}\right)-\log g\left(x_j^{\prime} \mid x_{j-1}\right) . \end{aligned}

## 统计代写|贝叶斯分析代考Bayesian Analysis代写|The Metropolis-Hastings algorithm

We have introduced Markov chain Monte Carlo methods with a detailed discussion of the Metropolis algorithm. As already noted, this algorithm is limited and rarely used on its own because it can only be used to sample from univariate distributions. Typically, other methods will be better suited to the task of sampling from a univariate distribution.

We now turn to the Metropolis-Hastings (MH) algorithm, a generalisation of the Metropolis algorithm that can be used to sample from a very wide range of multivariate distributions. This algorithm is very useful and has been applied in many difficult statistical modelling settings.

First let us again review the Metropolis algorithm for sampling from a univariate density, $f(x)$. This involves choosing an arbitrary starting value of $x$, a suitable driver density $g(t \mid x)$ and then repeatedly proposing a value $x^{\prime} \sim g(t \mid x)$, each time accepting this value with probability
$$p=\frac{f\left(x^{\prime}\right)}{f(x)} \times \frac{g\left(x \mid x^{\prime}\right)}{g\left(x^{\prime} \mid x\right)}$$
(or $p=\frac{f\left(x^{\prime}\right)}{f(x)}$ in the case of a symmetric driver).
Each proposal and then either acceptance or rejection constitutes one iteration of the algorithm and may be referred to as a Metropolis step.
Performing $K$ iterations, each consisting of a single Metropolis step, results in a Markov chain of values which may be denoted $x^{(0)}, x^{(1)}, \ldots, x^{(K)}$.
Assuming that stochastic equilibrium has been attained within $B$ iterations ( $B$ standing for burn-in) the last $J=K-B$ values may be renumbered so as to yield the required sample, $x^{(1)}, \ldots, x^{(J)} \dot{\sim}$ iid $f(x)$.

The Metropolis-Hastings (MH) algorithm is a generalisation of this procedure to the case where $x$ is a vector of length $M$ (say).

# 贝叶斯分析代写

## 统计代写|贝叶斯分析代考Bayesian Analysis代写|Non-symmetric drivers and the general Metropolis algorithm

$$x_j^{\prime} \sim g\left(t \mid x=x_{j-1}\right),$$

$$p=\frac{f\left(x_j^{\prime}\right)}{f\left(x_{j-1}\right)} \times \frac{g\left(x_{j-1} \mid x_j^{\prime}\right)}{g\left(x_j^{\prime} \mid x_{j-1}\right)} .$$

$$\frac{g\left(x_{j-1} \mid x_j^{\prime}\right)}{g\left(x_j^{\prime} \mid x_{j-1}\right)}=1 \text {. }$$

$$p=\exp (q)$$

\begin{aligned} q & =\log f\left(x_j^{\prime}\right)-\log f\left(x_{j-1}\right) \ & +\log g\left(x_{j-1} \mid x_j^{\prime}\right)-\log g\left(x_j^{\prime} \mid x_{j-1}\right) . \end{aligned}

## 统计代写|贝叶斯分析代考Bayesian Analysis代写|The Metropolis-Hastings algorithm

$$p=\frac{f\left(x^{\prime}\right)}{f(x)} \times \frac{g\left(x \mid x^{\prime}\right)}{g\left(x^{\prime} \mid x\right)}$$
(或$p=\frac{f\left(x^{\prime}\right)}{f(x)}$在对称驱动程序的情况下)。

Metropolis-Hastings (MH)算法是该过程的一般化，其中$x$是长度为$M$(例如)的向量。

avatest.org 为您提供可靠及专业的论文代写服务以便帮助您完成您学术上的需求，让您重新掌握您的人生。我们将尽力给您提供完美的论文，并且保证质量以及准时交稿。除了承诺的奉献精神，我们的专业写手、研究人员和校对员都经过非常严格的招聘流程。所有写手都必须证明自己的分析和沟通能力以及英文水平，并通过由我们的资深研究人员和校对员组织的面试。

## MATLAB代写

MATLAB 是一种用于技术计算的高性能语言。它将计算、可视化和编程集成在一个易于使用的环境中，其中问题和解决方案以熟悉的数学符号表示。典型用途包括：数学和计算算法开发建模、仿真和原型制作数据分析、探索和可视化科学和工程图形应用程序开发，包括图形用户界面构建MATLAB 是一个交互式系统，其基本数据元素是一个不需要维度的数组。这使您可以解决许多技术计算问题，尤其是那些具有矩阵和向量公式的问题，而只需用 C 或 Fortran 等标量非交互式语言编写程序所需的时间的一小部分。MATLAB 名称代表矩阵实验室。MATLAB 最初的编写目的是提供对由 LINPACK 和 EISPACK 项目开发的矩阵软件的轻松访问，这两个项目共同代表了矩阵计算软件的最新技术。MATLAB 经过多年的发展，得到了许多用户的投入。在大学环境中，它是数学、工程和科学入门和高级课程的标准教学工具。在工业领域，MATLAB 是高效研究、开发和分析的首选工具。MATLAB 具有一系列称为工具箱的特定于应用程序的解决方案。对于大多数 MATLAB 用户来说非常重要，工具箱允许您学习应用专业技术。工具箱是 MATLAB 函数（M 文件）的综合集合，可扩展 MATLAB 环境以解决特定类别的问题。可用工具箱的领域包括信号处理、控制系统、神经网络、模糊逻辑、小波、仿真等。

Posted on Categories:Bayesian Analysis, 统计代写, 统计代考, 贝叶斯分析

## avatest™帮您通过考试

avatest™的各个学科专家已帮了学生顺利通过达上千场考试。我们保证您快速准时完成各时长和类型的考试，包括in class、take home、online、proctor。写手整理各样的资源来或按照您学校的资料教您，创造模拟试题，提供所有的问题例子，以保证您在真实考试中取得的通过率是85%以上。如果您有即将到来的每周、季考、期中或期末考试，我们都能帮助您！

•最快12小时交付

•200+ 英语母语导师

•70分以下全额退款

## 统计代写|贝叶斯分析代考Bayesian Analysis代写|The Metropolis algorithm

Suppose that we wish to sample from a univariate distribution with pdf $f(x)$ for which rejection sampling and the other techniques described previously are problematic (say). Then another way to proceed is via the Metropolis algorithm. This is an example of Markov chain Monte Carlo (MCMC) methods. The Metropolis algorithm may be described as follows.

As with the Newton-Raphson algorithm, we begin by specifying an initial value of $x$, call it $x_0$. We then also need to specify a suitable driver distribution which is easy to sample from, defined by a pdf,
$$g(t \mid x)$$
For now, we will assume the driver to be symmetric, in the sense that
$$g(t \mid x)=g(x \mid t)$$
or more precisely,
$$g(t=a \mid \theta=b)=g(t=b \mid \theta=a) \quad \forall a, b \in \mathfrak{R} .$$
Note: The driver distribution may also be non-symmetric, but this case will be discussed later.

We then do the following iteratively for each $j=1,2,3, \ldots, K$ (where $K$ is ‘large’):
(a) Generate a candidate value of $x$ by sampling $x_j^{\prime} \sim g\left(t \mid x_{j-1}\right)$. We call $x_j^{\prime}$ the proposed value and $g\left(t \mid x_{j-1}\right)$ the proposal density.
(b) Calculate the acceptance probability as $p=\frac{f\left(x_j^{\prime}\right)}{f\left(x_{j-1}\right)}$.
Note: If $p>1$ then we take $p=1$. Also, if $x_j^{\prime}$ is outside the range of possible values for the random variable $x$, then $f\left(x_j^{\prime}\right)=0$ and so $p=0$.
(c) Accept the proposed value $x_j^{\prime}$ with probability $p$.
To determine if $x_j^{\prime}$ is accepted, generate $u \sim U(0,1)$ (independently). If $u<p$ then accept $x_j^{\prime}$, and otherwise reject $x_j^{\prime}$.
(d) If $x_j^{\prime}$ has been accepted then let $x_j=x_j^{\prime}$, and otherwise let $x_j=x_{j-1}$ (i.e. repeat the last value $x_{j-1}$ in the case of a rejection).
This procedure results in the realisation of a Markov chain, $x_0, x_1, x_2, \ldots, x_K$. The last value of this chain, $x_K$, may be taken as an observation from $f(x)$, at least approximately. The approximation will be extremely good if $K$ is sufficiently large.

## 统计代写|贝叶斯分析代考Bayesian Analysis代写|Changing the tuning parameter

What happens if we make the tuning parameter $c=0.15$ larger? Figures 6.3 and 6.4 are a repeat of Figures 6.1 and 6.2, respectively, but using simulated values from a run of the Metropolis algorithm with $c=0.65$.
In this case the acceptance rate is only $20.8 \%$ and the histogram is a poorer estimate of the true density (to which it would however converge as $J \rightarrow \infty)$. We say that the algorithm is now displaying poor mixing compared to results in the first run of 500 where $c=0.15$.

What happens if we make $c=0.15$ smaller? Figures 6.5 and 6.6 are a repeat of Figures 6.1 and 6.2, respectively, but using simulated values from a run of the Metropolis algorithm with $c=0.05$.

In this case the acceptance rate is higher at $83 \%$, there is greater autocorrelation, and the histogram is again a poorer estimate of the true density (to which it would however still converge as $J \rightarrow \infty$ ). We again say that the algorithm is mixing poorly.

It is important to stress that even if the algorithm is mixing poorly (whether this be due to the tuning constant being too large or too small), it will eventually (with a sufficiently large value of $J$ ) yield a sample that is useful for inference to the desired degree of precision. Tweaking the tuning constant is merely a device for optimising computational efficiency.

# 贝叶斯分析代写

## 统计代写|贝叶斯分析代考Bayesian Analysis代写|The Metropolis algorithm

$$g(t \mid x)$$

$$g(t \mid x)=g(x \mid t)$$

$$g(t=a \mid \theta=b)=g(t=b \mid \theta=a) \quad \forall a, b \in \mathfrak{R} .$$

(a)对$x_j^{\prime} \sim g\left(t \mid x_{j-1}\right)$进行抽样，产生一个候选值$x$。我们称$x_j^{\prime}$为建议值，称$g\left(t \mid x_{j-1}\right)$为建议密度。
(b)计算接受概率为$p=\frac{f\left(x_j^{\prime}\right)}{f\left(x_{j-1}\right)}$。

(c)以$p$的概率接受建议值$x_j^{\prime}$。

(d)如果$x_j^{\prime}$已被接受，则设$x_j=x_j^{\prime}$，否则设$x_j=x_{j-1}$(即在被拒绝的情况下重复最后一个值$x_{j-1}$)。

## 统计代写|贝叶斯分析代考Bayesian Analysis代写|Changing the tuning parameter

avatest.org 为您提供可靠及专业的论文代写服务以便帮助您完成您学术上的需求，让您重新掌握您的人生。我们将尽力给您提供完美的论文，并且保证质量以及准时交稿。除了承诺的奉献精神，我们的专业写手、研究人员和校对员都经过非常严格的招聘流程。所有写手都必须证明自己的分析和沟通能力以及英文水平，并通过由我们的资深研究人员和校对员组织的面试。

## MATLAB代写

MATLAB 是一种用于技术计算的高性能语言。它将计算、可视化和编程集成在一个易于使用的环境中，其中问题和解决方案以熟悉的数学符号表示。典型用途包括：数学和计算算法开发建模、仿真和原型制作数据分析、探索和可视化科学和工程图形应用程序开发，包括图形用户界面构建MATLAB 是一个交互式系统，其基本数据元素是一个不需要维度的数组。这使您可以解决许多技术计算问题，尤其是那些具有矩阵和向量公式的问题，而只需用 C 或 Fortran 等标量非交互式语言编写程序所需的时间的一小部分。MATLAB 名称代表矩阵实验室。MATLAB 最初的编写目的是提供对由 LINPACK 和 EISPACK 项目开发的矩阵软件的轻松访问，这两个项目共同代表了矩阵计算软件的最新技术。MATLAB 经过多年的发展，得到了许多用户的投入。在大学环境中，它是数学、工程和科学入门和高级课程的标准教学工具。在工业领域，MATLAB 是高效研究、开发和分析的首选工具。MATLAB 具有一系列称为工具箱的特定于应用程序的解决方案。对于大多数 MATLAB 用户来说非常重要，工具箱允许您学习应用专业技术。工具箱是 MATLAB 函数（M 文件）的综合集合，可扩展 MATLAB 环境以解决特定类别的问题。可用工具箱的领域包括信号处理、控制系统、神经网络、模糊逻辑、小波、仿真等。

Posted on Categories:Bayesian Analysis, 统计代写, 统计代考, 贝叶斯分析

## avatest™帮您通过考试

avatest™的各个学科专家已帮了学生顺利通过达上千场考试。我们保证您快速准时完成各时长和类型的考试，包括in class、take home、online、proctor。写手整理各样的资源来或按照您学校的资料教您，创造模拟试题，提供所有的问题例子，以保证您在真实考试中取得的通过率是85%以上。如果您有即将到来的每周、季考、期中或期末考试，我们都能帮助您！

•最快12小时交付

•200+ 英语母语导师

•70分以下全额退款

## 统计代写|贝叶斯分析代考Bayesian Analysis代写|Random number generation

So far we have assumed the availability of the sample required for Monte Carlo estimation, such as $x_1, \ldots, x_J \sim$ iid $f(x)$. The issue was skipped over by making use of ready made functions in $\mathrm{R}$ such as runif(), $\operatorname{rbeta()}$ and rgamma(). However, many applications involve dealing with complicated distributions from which sampling is not straightforward.

So we will next discuss some basic techniques that can be used to generate the required Monte Carlo sample from a given distribution. More advanced techniques will be treated later. We will first treat the discrete case, which is the simplest, and then the continuous case. It will be assumed throughout that we can at least sample easily from the standard uniform distribution, i.e. that we can readily generate $u \sim U(0,1)$.

Note: This sampling is easily achieved using the runif() function in R. Alternatively, it can be done physically by using a hat with 10 cards in it, where these have the numbers $0,1,2, \ldots ., 9$ written on them. Three cards (say) are drawn out of the hat, randomly and with replacement. The three numbers thereby selected are written down in a row, and a decimal point is placed in front of them. The resulting number (e.g. $0.472,0.000$ or 0.970 ) is an approximate draw from the standard uniform distribution. Repeating the entire procedure several times results in a random sample from that distribution. Increasing ‘three’ above (to ‘five’, say) improves the approximation (e.g. yielding $0.47207,0.00029$ or 0.97010 ).

## 统计代写|贝叶斯分析代考Bayesian Analysis代写|Sampling from an arbitrary discrete distribution

Suppose we wish to sample a value $x \sim f(x)$ where $f(x)$ is a discrete pdf defined over the possible values $x=x_1, \ldots, x_K$. First define
$$f_k=f\left(x_k\right)$$
and
$$F_k=f_1+\ldots+f_k(k=1, \ldots, K),$$
noting that $F_K=1$.
Then sample $u \sim U(0,1)$, and finally return:
\begin{aligned} & x=x_1 \quad \text { if } 0 \leq u \leq F_1 \ & x=x_2 \quad \text { if } F_1<u \leq F_2 \ & x=x_K \quad \text { if } F_{K-1}<u \leq F_K(=1) . \ & \end{aligned}
One way to implement the above is to set $k=1$, to repeatedly increment $k$ by 1 until $F_{k-1}<u \leq F_k$, and then, using the final value of $k$ thereby obtained, to return $x=x_k$.

Note 1: We see that this procedure will work also in the case where $K$ is infinite. In that case a practical alternative is to redefine $K$ as a value $k$ for which $F_k$ is very close to 1 (e.g. 0.9999) and then approximate $f(x)$ by zero for all $x>x_K$.

Note 2: In R, an alternative to using $u \sim U(0,1)$ is to apply the function sample() with appropriate specifications of $x_1, \ldots, x_K$ and $f_1, \ldots, f_K$ (as illustrated in an exercise below).

# 贝叶斯分析代写

## 统计代写|贝叶斯分析代考Bayesian Analysis代写|Sampling from an arbitrary discrete distribution

$$f_k=f\left(x_k\right)$$

$$F_k=f_1+\ldots+f_k(k=1, \ldots, K),$$

\begin{aligned} & x=x_1 \quad \text { if } 0 \leq u \leq F_1 \ & x=x_2 \quad \text { if } F_1<u \leq F_2 \ & x=x_K \quad \text { if } F_{K-1}<u \leq F_K(=1) . \ & \end{aligned}

avatest.org 为您提供可靠及专业的论文代写服务以便帮助您完成您学术上的需求，让您重新掌握您的人生。我们将尽力给您提供完美的论文，并且保证质量以及准时交稿。除了承诺的奉献精神，我们的专业写手、研究人员和校对员都经过非常严格的招聘流程。所有写手都必须证明自己的分析和沟通能力以及英文水平，并通过由我们的资深研究人员和校对员组织的面试。

## MATLAB代写

MATLAB 是一种用于技术计算的高性能语言。它将计算、可视化和编程集成在一个易于使用的环境中，其中问题和解决方案以熟悉的数学符号表示。典型用途包括：数学和计算算法开发建模、仿真和原型制作数据分析、探索和可视化科学和工程图形应用程序开发，包括图形用户界面构建MATLAB 是一个交互式系统，其基本数据元素是一个不需要维度的数组。这使您可以解决许多技术计算问题，尤其是那些具有矩阵和向量公式的问题，而只需用 C 或 Fortran 等标量非交互式语言编写程序所需的时间的一小部分。MATLAB 名称代表矩阵实验室。MATLAB 最初的编写目的是提供对由 LINPACK 和 EISPACK 项目开发的矩阵软件的轻松访问，这两个项目共同代表了矩阵计算软件的最新技术。MATLAB 经过多年的发展，得到了许多用户的投入。在大学环境中，它是数学、工程和科学入门和高级课程的标准教学工具。在工业领域，MATLAB 是高效研究、开发和分析的首选工具。MATLAB 具有一系列称为工具箱的特定于应用程序的解决方案。对于大多数 MATLAB 用户来说非常重要，工具箱允许您学习应用专业技术。工具箱是 MATLAB 函数（M 文件）的综合集合，可扩展 MATLAB 环境以解决特定类别的问题。可用工具箱的领域包括信号处理、控制系统、神经网络、模糊逻辑、小波、仿真等。

Posted on Categories:Bayesian Analysis, 统计代写, 统计代考, 贝叶斯分析

## avatest™帮您通过考试

avatest™的各个学科专家已帮了学生顺利通过达上千场考试。我们保证您快速准时完成各时长和类型的考试，包括in class、take home、online、proctor。写手整理各样的资源来或按照您学校的资料教您，创造模拟试题，提供所有的问题例子，以保证您在真实考试中取得的通过率是85%以上。如果您有即将到来的每周、季考、期中或期末考试，我们都能帮助您！

•最快12小时交付

•200+ 英语母语导师

•70分以下全额退款

## 统计代写|贝叶斯分析代考Bayesian Analysis代写|The method of Monte Carlo integration for estimating means

One of the most important applications of Monte Carlo methods is the estimation of means. Suppose we are interested in $\mu$, the mean of some distribution defined by a density $f(x)$ (or by a cumulative distribution function $F(x)$ ), but we are unable to calculate $\mu$ exactly (or easily), for example by applying the formula
$$\mu=E x=\int x f(x) d x$$
(or $\quad \mu=E x=\sum_x x f(x)$ or $\quad \mu=E x=\int x d F(x)$ ).
Also suppose, however, that we are able to generate (or obtain) a random sample from the distribution in question. Denote this sample as
\begin{aligned} x_1, \ldots, x_J & \sim \text { iid } f(x) \ \text { (or } \quad x_1, \ldots, x_J & \sim \text { iid } F(x) \text { ). } \end{aligned}
Then we may use this sample to estimate $\mu$ by
$$\bar{x}=\frac{1}{J} \sum_{j=1}^J x_j .$$

## 统计代写|贝叶斯分析代考Bayesian Analysis代写|Other uses of the MC sample

Once a Monte Carlo sample $x_1, \ldots, x_J \sim$ iid $f(x)$ has been obtained, it can be used for much more than just estimating the mean of the distribution, $\mu=E x$. For example, suppose we are interested in the (lower) $p$-quantile of the distribution, namely
$$q_p=F_X^{-1}(p)={\text { value of } x \text { such that } F(x)=p} .$$
The MC estimate of $q_p$ is simply $\hat{q}p$, the empirical $p$-quantile of $x_1, \ldots, x_J$. For instance, the median $q{1 / 2}$ can be estimated by the middle number amongst $x_1, \ldots, x_J$ after sorting in increasing order. This assumes that $J$ is odd. If $J$ is even, we estimate $q_{1 / 2}$ by the average of the two middle numbers. Thus we may write the $\mathrm{MC}$ estimate of $q_{1 / 2}$ as
$$\hat{q}{1 / 2}=\left{\begin{array}{c} x{((J+1) / 22}, J \text { odd } \ \frac{x_{(J / 2)}+x_{((J+1) / 2)}}{2}, J \text { even, } \end{array}\right.$$
where $x_{(k)}$ is the $k$ th smallest value amongst $x_1, \ldots, x_J \quad(k=1, \ldots, J)$.
Also, we estimate the $1-\alpha$ central density region (CDR) for $x$, namely $\left(q_{\alpha / 2}, q_{1-\alpha / 2}\right)$, by $\left(\hat{q}{\alpha / 2}, \hat{q}{1-\alpha / 2}\right)$.

Further, suppose we are interested in the expected value of some function of $x$, say $y=g(x)$. That is, we wish to estimate the quantity/integral
$$\psi=E y=\int y f(y) d y=E g(x)=\int g(x) f(x) d x .$$

# 贝叶斯分析代写

## 统计代写|贝叶斯分析代考Bayesian Analysis代写|The method of Monte Carlo integration for estimating means

$$\mu=E x=\int x f(x) d x$$
(或$\quad \mu=E x=\sum_x x f(x)$或$\quad \mu=E x=\int x d F(x)$)。

\begin{aligned} x_1, \ldots, x_J & \sim \text { iid } f(x) \ \text { (or } \quad x_1, \ldots, x_J & \sim \text { iid } F(x) \text { ). } \end{aligned}

$$\bar{x}=\frac{1}{J} \sum_{j=1}^J x_j .$$

## 统计代写|贝叶斯分析代考Bayesian Analysis代写|Other uses of the MC sample

$$q_p=F_X^{-1}(p)={\text { value of } x \text { such that } F(x)=p} .$$
$q_p$的MC估计简单地为$\hat{q}p$，即$x_1, \ldots, x_J$的经验$p$ -分位数。例如，中位数$q{1 / 2}$可以通过按递增顺序排序后的$x_1, \ldots, x_J$中的中间数来估计。这里假设$J$是奇数。如果$J$是偶数，我们用中间两个数的平均值来估计$q_{1 / 2}$。因此，我们可以将$q_{1 / 2}$的$\mathrm{MC}$估计值写成
$$\hat{q}{1 / 2}=\left{\begin{array}{c} x{((J+1) / 22}, J \text { odd } \ \frac{x_{(J / 2)}+x_{((J+1) / 2)}}{2}, J \text { even, } \end{array}\right.$$

$$\psi=E y=\int y f(y) d y=E g(x)=\int g(x) f(x) d x .$$

avatest.org 为您提供可靠及专业的论文代写服务以便帮助您完成您学术上的需求，让您重新掌握您的人生。我们将尽力给您提供完美的论文，并且保证质量以及准时交稿。除了承诺的奉献精神，我们的专业写手、研究人员和校对员都经过非常严格的招聘流程。所有写手都必须证明自己的分析和沟通能力以及英文水平，并通过由我们的资深研究人员和校对员组织的面试。

## MATLAB代写

MATLAB 是一种用于技术计算的高性能语言。它将计算、可视化和编程集成在一个易于使用的环境中，其中问题和解决方案以熟悉的数学符号表示。典型用途包括：数学和计算算法开发建模、仿真和原型制作数据分析、探索和可视化科学和工程图形应用程序开发，包括图形用户界面构建MATLAB 是一个交互式系统，其基本数据元素是一个不需要维度的数组。这使您可以解决许多技术计算问题，尤其是那些具有矩阵和向量公式的问题，而只需用 C 或 Fortran 等标量非交互式语言编写程序所需的时间的一小部分。MATLAB 名称代表矩阵实验室。MATLAB 最初的编写目的是提供对由 LINPACK 和 EISPACK 项目开发的矩阵软件的轻松访问，这两个项目共同代表了矩阵计算软件的最新技术。MATLAB 经过多年的发展，得到了许多用户的投入。在大学环境中，它是数学、工程和科学入门和高级课程的标准教学工具。在工业领域，MATLAB 是高效研究、开发和分析的首选工具。MATLAB 具有一系列称为工具箱的特定于应用程序的解决方案。对于大多数 MATLAB 用户来说非常重要，工具箱允许您学习应用专业技术。工具箱是 MATLAB 函数（M 文件）的综合集合，可扩展 MATLAB 环境以解决特定类别的问题。可用工具箱的领域包括信号处理、控制系统、神经网络、模糊逻辑、小波、仿真等。

Posted on Categories:Bayesian Analysis, 统计代写, 统计代考, 贝叶斯分析

## avatest™帮您通过考试

avatest™的各个学科专家已帮了学生顺利通过达上千场考试。我们保证您快速准时完成各时长和类型的考试，包括in class、take home、online、proctor。写手整理各样的资源来或按照您学校的资料教您，创造模拟试题，提供所有的问题例子，以保证您在真实考试中取得的通过率是85%以上。如果您有即将到来的每周、季考、期中或期末考试，我们都能帮助您！

•最快12小时交付

•200+ 英语母语导师

•70分以下全额退款

## 统计代写|贝叶斯分析代考Bayesian Analysis代写|The Bayes estimate

The Bayes estimate (or estimator) is defined to be the choice of the function $\hat{\theta}=\hat{\theta}(y)$ for which the Bayes risk $r=E L(\hat{\theta}, \theta)$ is minimised. This estimator has the smallest overall expected loss over all estimators under the specified loss function $L(\hat{\theta}, \theta)$.

In many cases, the procedure for finding a Bayes estimate can be considerably simplified by considering which estimate minimises the posterior expected loss function, $\operatorname{PEL}(y)=E{L(\hat{\theta}, \theta) \mid y}$.

If we can find an estimate $\hat{\theta}=\hat{\theta}(y)$ which minimises $P E L(y)$ for all possible values of the data $y$, then that estimate must also minimise the Bayes risk.

This is because the Bayes risk may be written as a weighted average of the PEL, namely
$$r=E L(\hat{\theta}, \theta)=E E{L(\hat{\theta}, \theta) \mid y}=E{\operatorname{PEL}(y)}=\int \operatorname{PEL}(y) f(y) d y .$$

## 统计代写|贝叶斯分析代考Bayesian Analysis代写|Bayesian predictive inference

In addition to estimating model parameters (and functions of those parameters) there is often interest in predicting some future data (or some other quantity which is not just a function of the model parameters).

Consider a Bayesian model specified by $f(y \mid \theta)$ and $f(\theta)$, with posterior as derived in ways already discussed and given by $f(\theta \mid y)$.
Now consider any other quantity $x$ whose distribution is defined by a density of the form $f(x \mid y, \theta)$.

The posterior predictive distribution of $x$ is given by the posterior predictive density $f(x \mid y)$. This can typically be derived using the following equation:
\begin{aligned} f(x \mid y) & =\int f(x, \theta \mid y) d \theta \ & =\int f(x \mid y, \theta) f(\theta \mid y) d \theta . \end{aligned}
Note: For the case where $\theta$ is discrete, a summation needs to be performed rather than an integral.

# 贝叶斯分析代写

## 统计代写|贝叶斯分析代考Bayesian Analysis代写|The Bayes estimate

$$r=E L(\hat{\theta}, \theta)=E E{L(\hat{\theta}, \theta) \mid y}=E{\operatorname{PEL}(y)}=\int \operatorname{PEL}(y) f(y) d y .$$

## 统计代写|贝叶斯分析代考Bayesian Analysis代写|Bayesian predictive inference

$x$的后验预测分布由后验预测密度$f(x \mid y)$给出。这通常可以用下面的公式推导出来:
\begin{aligned} f(x \mid y) & =\int f(x, \theta \mid y) d \theta \ & =\int f(x \mid y, \theta) f(\theta \mid y) d \theta . \end{aligned}

avatest.org 为您提供可靠及专业的论文代写服务以便帮助您完成您学术上的需求，让您重新掌握您的人生。我们将尽力给您提供完美的论文，并且保证质量以及准时交稿。除了承诺的奉献精神，我们的专业写手、研究人员和校对员都经过非常严格的招聘流程。所有写手都必须证明自己的分析和沟通能力以及英文水平，并通过由我们的资深研究人员和校对员组织的面试。

## MATLAB代写

MATLAB 是一种用于技术计算的高性能语言。它将计算、可视化和编程集成在一个易于使用的环境中，其中问题和解决方案以熟悉的数学符号表示。典型用途包括：数学和计算算法开发建模、仿真和原型制作数据分析、探索和可视化科学和工程图形应用程序开发，包括图形用户界面构建MATLAB 是一个交互式系统，其基本数据元素是一个不需要维度的数组。这使您可以解决许多技术计算问题，尤其是那些具有矩阵和向量公式的问题，而只需用 C 或 Fortran 等标量非交互式语言编写程序所需的时间的一小部分。MATLAB 名称代表矩阵实验室。MATLAB 最初的编写目的是提供对由 LINPACK 和 EISPACK 项目开发的矩阵软件的轻松访问，这两个项目共同代表了矩阵计算软件的最新技术。MATLAB 经过多年的发展，得到了许多用户的投入。在大学环境中，它是数学、工程和科学入门和高级课程的标准教学工具。在工业领域，MATLAB 是高效研究、开发和分析的首选工具。MATLAB 具有一系列称为工具箱的特定于应用程序的解决方案。对于大多数 MATLAB 用户来说非常重要，工具箱允许您学习应用专业技术。工具箱是 MATLAB 函数（M 文件）的综合集合，可扩展 MATLAB 环境以解决特定类别的问题。可用工具箱的领域包括信号处理、控制系统、神经网络、模糊逻辑、小波、仿真等。