### 统计代写|广义线性模型代写generalized linear model代考|STAT 7430

statistics-lab™ 为您的留学生涯保驾护航 在代写广义线性模型generalized linear model方面已经树立了自己的口碑, 保证靠谱, 高质且原创的统计Statistics代写服务。我们的专家在代写广义线性模型generalized linear model代写方面经验极为丰富，各种代写广义线性模型generalized linear model相关的作业也就用不着说。

• Statistical Inference 统计推断
• Statistical Computing 统计计算
• (Generalized) Linear Models 广义线性模型
• Statistical Machine Learning 统计机器学习
• Longitudinal Data Analysis 纵向数据分析
• Foundations of Data Science 数据科学基础

## 统计代写|广义线性模型代写generalized linear model代考|Heart Disease Example

What might affect the chance of getting heart disease? One of the earliest studies addressing this issue started in 1960 and used 3154 healthy men, aged from 39 to 59 , from the San Francisco area. At the start of the study, all were free of heart disease. Eight and a half years later, the study recorded whether these men now suffered from heart disease along with many other variables that might be related to the chance of developing this disease. We load a subset of this data from the Western Collaborative Group Study described in Rosenman et al. (1975):
data (wcgs, package=”faraway”)
We start by focusing on just three of the variables in the dataset:
We see that only 257 men developed heart disease as given by the factor variable chd. The men vary in height (in inches) and the number of cigarettes (cigs) smoked per day. We can plot these data using $R$ base graphics:
plot (height chd, wcgs)
wcgs\$y <- ifelse (wogs\$chd = “no”, 0, 1)
plot (jitter $(y, 0.1) \sim$ jitter (height), wegs, $x l a b=$ “Height”, $y$ lab=”Heart
$\hookrightarrow$ Disease”, peh=”.”)
The first panel in Figure $2.1$ shows a boxplot. This shows the similarity in the distribution of heights of the two groups of men with and without heart disease. But the heart disease is the response variable so we might prefer a plot which treats it as such. We convert the absence/presence of disease into a numerical $0 / 1$ variable and plot this in the second panel of Figure 2.1. Because heights are reported as round numbers of inches and the response can only take two values, it is sensible to add a small amount of noise to each point, called jittering, so that we can distinguish them. Again we can see the similarity in the distributions. We might think about fitting a line to this plot.

More informative plots may be obtained using the ggplot2 package of Wickham (2009). In the first panel of Figure 2.2, we see two histograms showing the distribution of heights for both those with and without heart disease. The dodge option ensures that the two histograms are interleaved. We see that the two distributions are similar. We also had to set the bin width of the histogram. It was natural to use one inch as all the height measurements are rounded to the nearest inch. In the second panel of Figure $2.2$, we see the corresponding histograms for smoking. In this case, we have shown the frequency rather than the count version of the histogram. We see that smokers are more likely to get heart disease.

## 统计代写|广义线性模型代写generalized linear model代考|Logistic Regression

Suppose we have a response variable $Y_{i}$ for $i=1, \ldots, n$ which takes the values zero or one with $P\left(Y_{i}=1\right)=p_{i}$. This response may be related to a set of $q$ predictors $\left(x_{i 1}, \ldots, x_{i q}\right)$. We need a model that describes the relationship of $x_{1}, \ldots, x_{q}$ to the probability $p$. Following the linear model approach, we construct a linear predictor:
$$\eta_{i}=\beta_{0}+\beta_{1} x_{i 1}+\cdots+\beta_{q} x_{i q}$$
Since the linear predictor can accommodate quantitative and qualitative predictors with the use of dummy variables and also allows for transformations and combinations of the original predictors, it is very flexible and yet retains interpretability. The idea that we can express the effect of the predictors on the response solely through the linear predictor is important. The idea can be extended to models for other types of response and is one of the defining features of the wider class of generalized linear models (GLMs) discussed later in Chapter 8 .

We have seen previously that the linear relation $\eta_{i}=p_{i}$ is not workable because we require $0 \leq p_{i} \leq 1$. Instead we shall use a link function $g$ such that $\eta_{i}=g\left(p_{i}\right)$. We need $g$ to be monotone and be such that $0 \leq g^{-1}(\eta) \leq 1$ for any $\eta$. The most popular choice of link function in this situation is the logit. It is defined so that:
$$\eta=\log (p /(1-p))$$
or equivalently:
$$p=\frac{e^{\eta}}{1+e^{\eta}}$$
Combining the use of the logit link with a linear predictor gives us the term logistic regression. Other choices of link function are possible but we will defer discussion of these until later. The logit and its inverse are defined as logit and ilogit in the faraway package. The relationship between $p$ and the linear predictor $\eta$ is shown in Figure 2.4.

## 统计代写|广义线性模型代写generalized linear model代考|Consider two models

Consider two models, a larger model with $l$ parameters and likelihood $L_{L}$ and a smaller model with $s$ parameters and likelihood $L_{S}$ where the smaller model represents a subset (or more generally a linear subspace) of the larger model. Likelihood

methods suggest the likelihood ratio statistic:
$$2 \log \frac{L_{L}}{L_{S}}$$
as an appropriate test statistic for comparing the two models. Now suppose we choose a saturated larger model – such a model typically has as many parameters as cases and has fitted values $\hat{p}{i}=y{i}$. The test statistic becomes:
$$D=-2 \sum_{i=1}^{n} \hat{p}{i} \operatorname{logit}\left(\hat{p}{i}\right)+\log \left(1-\hat{p}{i}\right)$$ where $\hat{p}{i}$ are the fitted values from the smaller model. $D$ is called the deviance and is useful in making hypothesis tests to compare models.

In other examples of GLMs, the deviance is a measure of how well the model fit the data but in this case, $D$ is just a function of the fitted values $\hat{p}$ so it cannot be used for that purpose. Other methods must be used to judge goodness of fit for binary data – for example, the Hosmer-Lemeshow test described in Section 2.6.
In the summary output previously, we had:
Deviance – 1749.049 Nu11 Deviance $=1781.244$ (Difference – 32.195)
The Deviance is the deviance for the current model while the Nu1l Deviance is the deviance for a model with no predictors and just an intercept term.

We can use the deviance to compare two nested models. The test statistic in (2.1) becomes $D_{S}-D_{L}$. This test statistic is asymptotically distributed $\chi_{l-s}^{2}$, assuming that the smaller model is correct and the distributional assumptions hold. For example, we can compare the fitted model to the null model (which has no predictors) by considering the difference between the residual and null deviances. For the heart disease example, this difference is $32.2$ on two degrees of freedom (one for each predictor). Hence, the $p$-value for the test of the hypothesis that at least one of the predictors is related to the response is:
1-pchisq $(32,2,2)$
(1) $1.0183 \mathrm{e}-07$
Since this value is so small, we are confident that there is some relationship between the predictors and the response. Note that the expected value of a $\chi^{2}$-variate with $d$ degrees of freedom is simply $d$ so we knew the $p$-value would be small before even calculating it.

## 统计代写|广义线性模型代写generalized linear model代考|Heart Disease Example

data (wcgs, package=”faraway”)

plot (height chd, wcgs)
wcgs $y <- ifelse (wogs$ chd = “no”, 0, 1)
plot (jitter(是,0.1)∼抖动（高度），wegs，Xl一个b=“高度”，是实验室=”心脏

p=和这1+和这

## 统计代写|广义线性模型代写generalized linear model代考|Consider two models

2日志⁡大号大号大号小号

Deviance – 1749.049 Nu11 Deviance=1781.244（差值 – 32.195）

1-pchisq(32,2,2)
(1) 1.0183和−07

## 有限元方法代写

tatistics-lab作为专业的留学生服务机构，多年来已为美国、英国、加拿大、澳洲等留学热门地的学生提供专业的学术服务，包括但不限于Essay代写，Assignment代写，Dissertation代写，Report代写，小组作业代写，Proposal代写，Paper代写，Presentation代写，计算机作业代写，论文修改和润色，网课代做，exam代考等等。写作范围涵盖高中，本科，研究生等海外留学全阶段，辐射金融，经济学，会计学，审计学，管理学等全球99%专业科目。写作团队既有专业英语母语作者，也有海外名校硕博留学生，每位写作老师都拥有过硬的语言能力，专业的学科背景和学术写作经验。我们承诺100%原创，100%专业，100%准时，100%满意。

## MATLAB代写

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