**1. Run the following code to generate a sample of size 50 from the Student t distribution with degree of freedom 30, and then:**

**generate a histogram of sample x;****calculate its summary statistics (min, Q1, median, mean, Q3, max);****generate a Q-Q plot with 95% CI for sample x;****run Shapiro-Wilk normality test on sample x.**

```
set.seed(57)
x <- rt(n=50,df=30)
```

**2. Run the following simulation code first and then: **

**calculate and test the Pearson correlation between x and y****generate a scatter plot of x vs. y**

```
set.seed(1234)
x <- rnorm(1000, 3, 0.5)
y <- 3-5*x+3*rnorm(1000)
```

**3. Run the following simulation code first and then choose an appropriate test to compare the mean of sample x1 and x2. And then check the sample sizes. **

```
set.seed(57)
x1 <- rnorm(30, 2.2, 1)
x2 <- rnorm(30, 2.0, 1)
```

**4. Run the following simulation first and then: **

**test linear association between x and y****generate the scatter plot of x vs. y**

```
set.seed(1234)
r <- runif(1000, -pi,pi)
x <- 16*sin(r)^3
y <- 13*cos(r)-5*cos(2*r)-2*cos(3*r)-cos(4*r)+rnorm(1000)
```

**5. Run the following simulation code first and then: **

**regress y on x****generate the model diagnostic plots****plot the histgram of x****calculate mean of x****plot the histgram of y****calculate mean of y****what is the relation between mean of x and mean of y?****calculate and test the Pearson correlation between x and y**

```
set.seed(1234)
x <- rnorm(1000, 5, 2)
y <- 3+5*x+rnorm(1000)
```

**6. Run the following code to attach a dataset first. Then test the linear association between variable HEARTRTE and variable BMI while adjusting for variable age effect on HEARTRTE.**

```
data("DIGdata", package="asympTest")
attach(DIGdata)
```

**7. Run the following simulation code first and then**

**regress y on x****generate the model diagnostic plots****generate a histgram of y****generate a frequency table of x****generate a boxplot of y by different values of x****run two-sample t-test on y by different values of x**

```
set.seed(1234)
x <- rbinom(1000, 1, 0.5)
y <- 3+15*x+rnorm(1000)
```