程序代写代做代考 —


title: “STAT 341/641 Lab: Week Five”
author: “Your Name Here”
date: “Enter the Date Here”
output: html_document

**STAT 341/641:** Intro to EDA and Statistical Computing
**Lab #5:** Loops and the Jackknife
**Teaching Assistant:** “Fill in the name of your TA”

* * *

“`{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
“`

**Directions:** You will use the lab time to complete this assignment.

* * *

#**Task: Analyze the Gapminder Data**

Install and load the gapminder data.
“`{r}
#install.packages(“gapminder”)
library(gapminder)
“`

##1: Compute the average life expectancy and GDP per capita by country using the data from 1987 to 2007. Plot these values in a scatterplot. Color the points by the continent to which they belong.

**Solution:**
“`{r}

“`
##2: Use the Mahalanobis distance method to detect outliers in the output from question one. Which countries would you call outliers? Why?

**Solution:**
“`{r}

“`

##3: Using the full dataset, implement the jackknife to identify which countries have a large influence on the $\beta_{\text{gdpPercap}}$ parameter in the regression equation
$$ lifeExp_i = \alpha + \beta_{\text{gdpPercap}}gdpPercap_i + \beta_{\text{pop}}pop_i + \epsilon_i.$$
To do this, write a for-loop. In each iteration of the loop, drop one of the countries and compute the OLS coefficients. Plot the value of $\beta_{\text{gdpPercap}}$ with the name of countries on the $x$-axis and the values of $\beta_{\text{gdpPercap}}$ on the $y$-axis.

**Solution:**
“`{r}

“`

##5.4: Write a for-loop to sample $N=1,704$ points with replacement from the data. Do this $R=250$ times. For each iteration compute the mean of the population. Visualize the 250 means with a boxplot. Then compute the variance of the means. Compare this to the standard estimate for the variance of the sample mean
$$\frac{\hat{\sigma}^2}{N}.$$

**Solution:**
“`{r}

“`

* * *