Homework

Prepare a single file homework5.Rmd, which should include all answers, R codes, and result figures. Note: DO NOT generate and save figures, and then insert into Rmd. Make your Rmd dynamic, meaning that it will automatically generate and insert figures when you knit the Rmd.

  1. This question explores the relationship among multiple continuous variables.

  2. This question explores the relationship among multiple categorical variables.

  3. This question explores the relationship among continuous and categorical variables.

  4. Write an R function named myRowSums to compute and return the sums of all the rows in a matrix. Use the following codes to generate data and verify the results. NOTE: you cannot call rowSums function in your function. Write a loop.

    x = matrix(1:12, nrow=4)
    rowSums(x)
    myRowSums(x) ## should get the same results
  5. Write an R function to compute the root of a quadratic function ax^2+bx+c=0.

  6. Perform a simple linear regression to explore the relationship between wt and mpg in the mtcars. Provide a figure (scatterplot with regression line) to show the results. Explain in plain lanuage what the results mean (e.g., the meanings of regression coefficients).


Day 1: Basic statistics - relationships among continuous data

This week, we will learn some concept and techniques to assess the relationships among multiple variables (continuous or categorical). Today we will focus on the relationsip among continuous data.


Day 2: Basic statistics - relationships among continuous and categorical data

To assess the relationship among multiple categorical data:

To assess the relationship among continous and categorical data:


Day 3: R functions


Day 4: Simple linear regression


Day 5: Review