OnlineNursingOwl
← All nursing posts

Statistics · Studypool

By using R studio to resolve questions

Overview

All files needed are attached. There is a preview:

---

output: html_document

---

```{r setup, include=FALSE}

knitr::opts_chunk$set(echo = TRUE)

# turn on the tidyverse package

library(tidyverse)

```

---------------------

**All problems below use the UWEC data consisting of a sample of students randomly selected from the University of Wisconsin at Eau Claire. The file is `uwec.csv`, and contains 13 variables for each student. You may issue `names(uwec)`, `head(uwec)`, or `glimpse(uwec)` for more information.**

```{r, message=FALSE, warning=FALSE}

# Read-in data

uwec <- read.csv("uwec.csv", header=TRUE)

```

---------------------

### Problem 1

Find and interpret a 95% bootstrap CI for the true mean GPA of all seniors at this university. Set your seed value to 7777. **You must use the `boot` package here and provide a check and assessment of bias.**

```{r, warning=FALSE, message=FALSE}

# Data preparation

# Bootstrapping:

set.seed(7777)

```

**WRITE INTERPRETATION HERE**

---------------------------------------------------------------------------------------------------

### Problem 2

We are interested in estimating the probability of having a GPA above 3.500, given we know the student is of good academic standing (which means their GPA is at least 2.000). Find and interpret a 95% BCa bootstrap CI for this probability for the UWEC student body.

**NOTE:** You must use the `boot` package here. Set your seed value to 7878. Also note that you are estimating a conditional probability. Check online resources if you need to review how to calculate these.

```{r, warning=FALSE, message=FALSE}

# Data preparation

# Set up function for boot() that calculates the conditional probability

# Bootstrapping:

set.seed(7878)

```

**WRITE INTERPRETATION HERE**

---------------------

### Problem 3

Suppose we wish to run a multiple regression analysis to predict freshman GPA (first years only) from ACT Math and ACT English scores. The purpose is to see if [a] either of them is predictive of freshman GPA, and ultimately [b] to see if one of them is significantly *more* predictive of GPA than the other, when both are considered as joint predictors in the same model. Our model of interest is:

$$GPA = \beta_{0}+\beta_{1}ACT_{Math}+\beta_{2}ACT_{English}+\epsilon$$

Use R to fit this model **for freshmen only**, and provide a **complete and correct interpretation in context** of the values of $b_{1}$ and $b_{2}$, the model based estimates of the coefficients $\beta_{1}$ and $\beta_{2}$. *(Note that this is a STA 363 question, so review material from there for insight if necessary).*

```{r, message=FALSE, warning=FALSE}

# Data preparation

# Fit the regression model

```

* **Interpretation of $b_{1}$:**

* **Interpretation of $b_{2}$:**

---------------------

### Problem 4

**Refer to Problem 3.** You should have found that neither of these two ACT predictors are significantly related to freshman college GPA. However, that does **not** mean that those two predictors has the **same** effect, i.e. it doesn't mean that $\beta_{1}=\beta_{2}$.

Since both ACT variables are measured in the same units, we can compare their effects on mean freshman GPA by looking directly at the sizes of the regression coefficients $\beta_{1}$ and $\beta_{2}$. How can we test to see if ACT Math and ACT English scores have different effects on mean GPA? We could use bootstrapping to do it.

Use bootstrapping to find a 95% confidence interval for $\beta_{1}-\beta_{2}$, the true difference between the adjusted effect of ACT Math score on mean freshman GPA and the adjusted effect of ACT English score on mean freshman GPA. Provide the CI endpoints, and use the CI to determine if these two effects are significantly different from each other.

- Use looping to do the bootstrapping. Do NOT use the `boot` package on this problem.

- Set a starting seed of 9891110.

- Display the bootstrap distribution as a professional quality histogram.

```{r, message=FALSE, warning=FALSE}

# Calculate observed estimate of beta1-beta2 (= b1-b2)

# Set a seed value for reproducible results

set.seed(9891110)

# Set up bootstrapping

# Bias estimate

# Bootstrap distribution visualization

# CI calculation

```

**WRITE INTERPRETATIONS AND FINDINGS HERE**