# Librariesimport numpy as npimport pandas as pdimport plotnine as p9# Problem 1 dataanime_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 datastarbucks_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.
Source Code
---title: "ICA 2"date: 9/4/26editor: sourcejupyter: python3format: html: code-fold: true code-tools: true code-line-numbers: true embed-resources: truedraft: false---**Due 9/13/26 \@ 11:59 PM**Submit the \*.html file to Canvas.## Notebook SetupCreate a raw cell and insert this code```text---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: trueexecute: echo: true message: false warning: false error: truejupyter: python3---```## Import Data```{python}#| label: setup#| include: true# Librariesimport numpy as npimport pandas as pdimport plotnine as p9# Problem 1 dataanime_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 datastarbucks_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 1The `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 2Fit 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.