## 机器学习代写|机器学习代写machine learning代考|Fitting a Linear Multiple Regression Model via the Ordinary Least Square (OLS) Method

In a general context, we have a covariate vector $X=\left(X_1, \ldots, X_p\right)^{\mathrm{T}}$ and we want to use this information to predict or explain how this variable affects a real-value response $Y$. The linear multiple regression model assumes a relationship given by
$$Y=\beta_0+\sum_{j=1}^p X_j \beta_j+\epsilon,$$
where $\epsilon$ is a random error with mean $0, E(\epsilon)=0$ and is independent of $X$. This error is included in the model to capture measurement errors and the effects of other unregistered explanatory variables that can help to explain the mean response.

Then, the conditional mean of this model is $E(Y \mid X)=\beta_0+\sum_{j=1}^p X_j \beta_j$ and the conditional distribution of $Y$ given $X$ is only affected by the information of $X$.
For estimating the parameters $\beta=\left(\beta_0, \beta_1, \ldots, \beta_p\right)^{\mathrm{T}}$, usually we have a set of data $\left(\boldsymbol{x}i^{\mathrm{T}}, y_i\right), i=1, \ldots, n$, often known as training data, where $\boldsymbol{x}_i=\left(x{i 1}, \ldots, x_{i p}\right)^{\mathrm{T}}$ is a vector of features measurement and $y_i$ is the response measurement corresponding to the $i$ th individual drawn. The most common method for estimating $\boldsymbol{\beta}$ is the least squares method (OLS) that consists of taking the $\boldsymbol{\beta}$ value that minimizes the residual sum of squares defined as
$$\operatorname{RSS}(\boldsymbol{\beta})=\sum_{i=1}^n\left(y_i-\beta_0-\boldsymbol{x}i^{\mathrm{T}} \boldsymbol{\beta}_0\right)^2=(\boldsymbol{y}-\boldsymbol{X} \boldsymbol{\beta})^{\mathrm{T}}(\boldsymbol{y}-\boldsymbol{X} \boldsymbol{\beta}),$$ where $\boldsymbol{\beta}_0=\left(\beta_1, \ldots, \beta_p\right)^{\mathrm{T}}, \boldsymbol{y}=\left(y_1, \ldots, y_n\right)^{\mathrm{T}}$ is the vector with the response values of all individuals, and $\boldsymbol{X}$ is an $n \times(p+1)$ matrix that contains the information of the measured features of all individuals, including the intercept in the first entry: $$\boldsymbol{X}=\left[\begin{array}{cccc} 1 & x{11} & \cdots & x_{1 p} \ \vdots & \vdots & \vdots & \vdots \ 1 & x_{n 1} & \cdots & x_{n p} \end{array}\right]$$
If the $\boldsymbol{X}$ matrix has full column rank, then by differentiating the residual sum of squares with respect to the $\boldsymbol{\beta}$ coefficients, we can find the set of $\boldsymbol{\beta}$ parameters that minimize the $\operatorname{RSS}(\boldsymbol{\beta})$,
$$\frac{\operatorname{RSS}(\boldsymbol{\beta})}{\partial \boldsymbol{\beta}}=\frac{(\boldsymbol{y}-\boldsymbol{X} \boldsymbol{\beta})^{\mathrm{T}}(\boldsymbol{y}-\boldsymbol{X} \boldsymbol{\beta})}{\partial \boldsymbol{\beta}}=\frac{\boldsymbol{y}^{\mathrm{T}} \boldsymbol{y}-\boldsymbol{2} \boldsymbol{y}^{\mathrm{T}} \boldsymbol{X} \boldsymbol{\beta}+\boldsymbol{\beta}^{\mathrm{T}}\left(\boldsymbol{X}^{\mathrm{T}} \boldsymbol{X}\right) \boldsymbol{\beta}}{\partial \boldsymbol{\beta}}=\boldsymbol{2}\left[\left(\boldsymbol{X}^{\mathrm{T}} \boldsymbol{X}\right) \boldsymbol{\beta}-\boldsymbol{X}^{\mathrm{T}} \boldsymbol{Y}\right]$$
This derivative is also known as the gradient of the residual sum of squares. Then by setting the gradient of the residual sum of squares to zero, we obtain the normal equations
$$\left(\boldsymbol{X}^{\mathrm{T}} \boldsymbol{X}\right) \boldsymbol{\beta}=\boldsymbol{X}^{\mathrm{T}} \boldsymbol{Y}$$

## 机器学习代写|机器学习代写machine learning代考|Fitting the Linear Multiple Regression Model via the Maximum Likelihood (ML) Method

The maximum likelihood (ML) estimation is a more general and popular method for estimating the parameters of a model (Casella and Berger 2002). It consists of finding the parameter value that maximizes the “probability” of observed values in the sample under the adopted model. Specifically, if $\left(x_i^{\mathrm{T}}, y_i\right), i=1, \ldots, n$, is a set of observations from a multiple linear regression model (3.1) with homoscedastic and uncorrelated errors, the MLE of $\boldsymbol{\beta}$ and $\sigma^2, \widehat{\boldsymbol{\beta}}$ and $\widehat{\sigma}^2$, of this model is defined as
$$\left(\hat{\boldsymbol{\beta}}^{\mathrm{T}}, \hat{\sigma}^2\right)=\underset{\boldsymbol{\beta}, \sigma^2}{\arg \max } L\left(\boldsymbol{\beta}, \sigma^2 ; \boldsymbol{y}, \boldsymbol{X}\right),$$
where $L\left(\boldsymbol{\beta}, \sigma^2 ; \boldsymbol{y}, \boldsymbol{X}\right)$ is the likelihood function of the parameters, which is the probability of the observed response values but viewed as a function of the parameters
$$L\left(\boldsymbol{\beta}, \sigma^2 ; \boldsymbol{y}, \boldsymbol{X}\right)=\left(\frac{1}{\sqrt{2 \pi \sigma^2}}\right)^n \exp \left[-\frac{1}{2 \sigma^2}(\boldsymbol{y}-\boldsymbol{X} \boldsymbol{\beta})^{\mathrm{T}}(\boldsymbol{y}-\boldsymbol{X} \boldsymbol{\beta})\right]$$
Then, the $\log \left(L\left(\boldsymbol{\beta}, \sigma^2 ; \boldsymbol{y}, \boldsymbol{X}\right)\right)$ is equal to
$$\log \left(L\left(\boldsymbol{\beta}, \sigma^2 ; \boldsymbol{y}, \boldsymbol{X}\right)\right)=-\frac{n}{2} \log (2 \pi)-n \log (\sigma)-\frac{1}{2 \sigma^2}(\boldsymbol{y}-\boldsymbol{X} \boldsymbol{\beta})^{\mathrm{T}}(\boldsymbol{y}-\boldsymbol{X} \boldsymbol{\beta})$$
To find the maximum of $\sigma^2$ and $\boldsymbol{\beta}$, we get the derivative of $\log \left(L\left(\widehat{\boldsymbol{\beta}}, \sigma^2 ; \boldsymbol{y}, \boldsymbol{X}\right)\right)$ with regard to these parameters
$$\begin{gathered} \frac{\log \left(L\left(\boldsymbol{\beta}, \sigma^2 ; \boldsymbol{y}, \boldsymbol{X}\right)\right)}{\partial \boldsymbol{\beta}}=\frac{\left[\left(\boldsymbol{X}^{\mathrm{T}} \boldsymbol{X}\right) \boldsymbol{\beta}-\boldsymbol{X}^{\mathrm{T}} \boldsymbol{Y}\right]}{\sigma^2} \ \frac{\log \left(L\left(\boldsymbol{\beta}, \sigma^2 ; \boldsymbol{y}, \boldsymbol{X}\right)\right)}{\partial \sigma^2}=-\frac{n}{2 \sigma^2}+\frac{1}{2 \sigma^4}(\boldsymbol{y}-\boldsymbol{X} \boldsymbol{\beta})^{\mathrm{T}}(\boldsymbol{y}-\boldsymbol{X} \boldsymbol{\beta}) \end{gathered}$$

# 机器学习代考

## 机器学习代写|机器学习代写machine learning代考|通过普通最小二乘(OLS)方法拟合线性多元回归模型

$$Y=\beta_0+\sum_{j=1}^p X_j \beta_j+\epsilon,$$

$$\frac{\operatorname{RSS}(\boldsymbol{\beta})}{\partial \boldsymbol{\beta}}=\frac{(\boldsymbol{y}-\boldsymbol{X} \boldsymbol{\beta})^{\mathrm{T}}(\boldsymbol{y}-\boldsymbol{X} \boldsymbol{\beta})}{\partial \boldsymbol{\beta}}=\frac{\boldsymbol{y}^{\mathrm{T}} \boldsymbol{y}-\boldsymbol{2} \boldsymbol{y}^{\mathrm{T}} \boldsymbol{X} \boldsymbol{\beta}+\boldsymbol{\beta}^{\mathrm{T}}\left(\boldsymbol{X}^{\mathrm{T}} \boldsymbol{X}\right) \boldsymbol{\beta}}{\partial \boldsymbol{\beta}}=\boldsymbol{2}\left[\left(\boldsymbol{X}^{\mathrm{T}} \boldsymbol{X}\right) \boldsymbol{\beta}-\boldsymbol{X}^{\mathrm{T}} \boldsymbol{Y}\right]$$这个导数也被称为残差平方和的梯度。然后将残差平方和的梯度设为零，得到法方程
$$\left(\boldsymbol{X}^{\mathrm{T}} \boldsymbol{X}\right) \boldsymbol{\beta}=\boldsymbol{X}^{\mathrm{T}} \boldsymbol{Y}$$

## 机器学习代写|机器学习代写machine learning代考|通过最大似然(ML)方法拟合线性多元回归模型

.

$$\left(\hat{\boldsymbol{\beta}}^{\mathrm{T}}, \hat{\sigma}^2\right)=\underset{\boldsymbol{\beta}, \sigma^2}{\arg \max } L\left(\boldsymbol{\beta}, \sigma^2 ; \boldsymbol{y}, \boldsymbol{X}\right),$$
，其中$L\left(\boldsymbol{\beta}, \sigma^2 ; \boldsymbol{y}, \boldsymbol{X}\right)$是参数的似然函数，这是观测响应值的概率，但被视为参数的函数
$$L\left(\boldsymbol{\beta}, \sigma^2 ; \boldsymbol{y}, \boldsymbol{X}\right)=\left(\frac{1}{\sqrt{2 \pi \sigma^2}}\right)^n \exp \left[-\frac{1}{2 \sigma^2}(\boldsymbol{y}-\boldsymbol{X} \boldsymbol{\beta})^{\mathrm{T}}(\boldsymbol{y}-\boldsymbol{X} \boldsymbol{\beta})\right]$$

$$\log \left(L\left(\boldsymbol{\beta}, \sigma^2 ; \boldsymbol{y}, \boldsymbol{X}\right)\right)=-\frac{n}{2} \log (2 \pi)-n \log (\sigma)-\frac{1}{2 \sigma^2}(\boldsymbol{y}-\boldsymbol{X} \boldsymbol{\beta})^{\mathrm{T}}(\boldsymbol{y}-\boldsymbol{X} \boldsymbol{\beta})$$

$$\begin{gathered} \frac{\log \left(L\left(\boldsymbol{\beta}, \sigma^2 ; \boldsymbol{y}, \boldsymbol{X}\right)\right)}{\partial \boldsymbol{\beta}}=\frac{\left[\left(\boldsymbol{X}^{\mathrm{T}} \boldsymbol{X}\right) \boldsymbol{\beta}-\boldsymbol{X}^{\mathrm{T}} \boldsymbol{Y}\right]}{\sigma^2} \ \frac{\log \left(L\left(\boldsymbol{\beta}, \sigma^2 ; \boldsymbol{y}, \boldsymbol{X}\right)\right)}{\partial \sigma^2}=-\frac{n}{2 \sigma^2}+\frac{1}{2 \sigma^4}(\boldsymbol{y}-\boldsymbol{X} \boldsymbol{\beta})^{\mathrm{T}}(\boldsymbol{y}-\boldsymbol{X} \boldsymbol{\beta}) \end{gathered}$$

myassignments-help数学代考价格说明

1、客户需提供物理代考的网址，相关账户，以及课程名称，Textbook等相关资料~客服会根据作业数量和持续时间给您定价~使收费透明，让您清楚的知道您的钱花在什么地方。

2、数学代写一般每篇报价约为600—1000rmb，费用根据持续时间、周作业量、成绩要求有所浮动(持续时间越长约便宜、周作业量越多约贵、成绩要求越高越贵)，报价后价格觉得合适，可以先付一周的款，我们帮你试做，满意后再继续，遇到Fail全额退款。

3、myassignments-help公司所有MATH作业代写服务支持付半款，全款，周付款，周付款一方面方便大家查阅自己的分数，一方面也方便大家资金周转，注意:每周固定周一时先预付下周的定金，不付定金不予继续做。物理代写一次性付清打9.5折。

Math作业代写、数学代写常见问题

myassignments-help擅长领域包含但不是全部: