Published

September 4, 2026

Due 9/13/26 @ 11:59 PM

Submit the *.html file to Canvas.

Notebook Setup

Create a raw cell and insert this code

---
title: "TITLE"
author: "NAME HERE"
date: "DATE HERE"
format: 
  html:
    toc: true
    toc-depth: 2
    code-fold: true
    code-tools: true
    code-line-numbers: true
    embed-resources: true
execute:
  echo: true
  message: false
  warning: false
  error: true
jupyter: python3
---

Import Data

Code
# Libraries
import numpy as np
import pandas as pd
import plotnine as p9

# Problem 1 data
anime_url = (
    "https://raw.githubusercontent.com/rfordatascience/"
    "tidytuesday/master/data/2019/2019-04-23/tidy_anime.csv"
)

anime = (
    pd.read_csv(anime_url)
    .query("type != 'Unknown'")
    .copy()
)

# Problem 2 data
starbucks_url = (
    "https://raw.githubusercontent.com/rfordatascience/"
    "tidytuesday/master/data/2021/2021-12-21/starbucks.csv"
)

starbucks = (
    pd.read_csv(starbucks_url)
    .dropna()
    .query("size in ['tall', 'grande', 'venti']")
    .copy()
)

Problem 1

The anime dataset from MyAnimeList contains information on rankings and popularity scores of different anime episodes.

Fit a linear model showing the relationship between score (outcome; higher is better) and the predictors type, popularity, and rank. On average, what is the score for an anime that is a "Special", has a popularity score of 520, and has a rank of 3582?

Problem 2

Fit a linear model between the outcome caffeine_mg and predictors size, calories, and sugar_g from the starbucks dataset using the matrix formulation approach by defining the \(X\) matrix. Use tall as the reference value for the size variable.