Homework 3

Distribution Theory

Setup

Each of your assignments will begin with the following steps.

  • Going to our RStudio Server at http://turing.cornellcollege.edu:8787/

  • Creating a new R project, inside your homework folder on the server, and giving it a sensible name such as homework_3 and having that project in the course folder you created.

  • Create a new quarto document and give it a sensible name such as hw3.

  • In the YAML add the following (add what you don’t have). The embed-resources component will make your final rendered html self-contained.

    ---
    title: "Document title"
    author: "my name"
    format:
      html:
    embed-resources: true
    ---

Instructions

Be sure to include the relevant R code as well as full sentences answering each of the questions (i.e. if I ask for the average, you can output the answer in R but also write a full sentence with the answer). Be sure to frequently save your files!

Data for the homework will be in the STA363_inst_files -> data folder.

Exercises

All problems are from The main textbook is: Beyond Multiple Linear Regression by Paul Roback and Julie Legler – it is freely available online. Chapters 1-9.. Abbreviated BMLR.

Use the numbering on the left. The codes are for instructor use (Ex: C1).

Exercise 1

  1. (C1) At what value of \(p\) is the standard deviation of a binary random variable smallest? When is standard deviation largest?

Exercise 2

  1. (C3) How are exponential and Poisson random variables related?

Exercise 3

  1. (C7) Chapter 1 also asked you to consider a scenario where “Researchers are attempting to see if socioeconomic status and parental stability are predictive of low birthweight. They classify a low birthweight as below 2500 g, hence our response is binary: 1 for low birthweight, and 0 when the birthweight is not low.” What distribution might be useful to model if a newborn has low birthweight?

Exercise 4

  1. (C9) Describe a scenario which could be modeled using a gamma distribution.

Exercise 5

  1. (G2) Gamma-Poisson mixture I. Use the R function rpois() to generate 10,000 \(x_i\) from a plain old vanilla Poisson random variable, \(X \sim \textrm{Poisson}(\lambda=1.5)\). Plot a histogram of this distribution and note its mean and standard deviation. Next, let \(Y \sim \textrm{Gamma}(r = 3, \lambda = 2)\) and use rgamma() to generate 10,000 random \(y_i\) from this distribution. Now, consider 10,000 different Poisson distributions where \(\lambda_i = y_i\). Randomly generate one \(z_i\) from each Poisson distribution. Plot a histogram of these \(z_i\) and compare it to your original histogram of \(X\) (where \(X \sim \textrm{Poisson}(1.5)\)). How do the means and standard deviations compare?

Submission

When you are finished with your homework, be sure to Render the final document. Once rendered, you can download your file by:

  • Finding the .html file in your File pane (on the bottom right of the screen)
  • Click the check box next to the file
  • Click the blue gear above and then click “Export” to download
  • Submit your final html document to the respective assignment on Moodle