# Chapter 3 Sample Codes of Assignment 4

## 3.1 Exercise 1

For this part, you can either submit a html file compiled from .rmd, or a pdf source file generated by .r. All you need to change is

# Y00.name0<-"SP500"
# Y00.name0<-"BAC"
# Y00.name0<-"AAPL"
# Y00.name0<-"GE"

In other words, define your own Y00.name0 variable to the stock that you are interested in. To make sure that there is such stock, you might want to check all the stocks in casestudy1.data0.00, by simply type the following command in the console or code chunk:

names(casestudy1.data0.00)

## 3.2 Exercise 3

First you should note that there is no way to let R to find the maximum likelihood estimator (even though that there are some packages that can do this for you). Instead, you should tell R what $$\hat{\theta}_{mle}$$ is. In the example file fm_intro3_gof_rev1.r, at line 136 and 137, we define what is the mle for our $$\theta$$.

std0.mle=sqrt(mean(y^2) - (mean(y))^2) # MLE
std0.robust=IQR(y)/1.3490 # Robust fit

### 3.2.1 Chi-square goodness-of-fit test

The Chi-Square Goodness-of-Fit (GOF) Test applies to evaluating whether sample data is consistent with coming from a given probablity distribution. The evaluation compares the empirical histogram of the sample data to the theoretical histogram of the given probability distribution.