# Example set of packages (most important for now)
install.packages("reticulate")
install.packages("rmarkdown")
install.packages("knitr")
install.packages("quarto")
install.packages("tidymodels")
install.packages("tidyverse")
# ... add any more you want. You can always add more anytime.DS 6030 | Spring 2026 | University of Virginia
Homework #0: Hello DS-6030
Getting Help
The purpose of this (ungraded) homework is to help get you prepared for the semester. Don’t panic if you don’t immediately know the answers to some of these. I expect everyone will need to look things up. Take note of the areas that are rusty and plan to spend a bit of extra time to get up to speed. If some of these items are not even remotely familiar to you, then you probably have not satisfied the pre-requisite material; review the course syllabus and speak to me about any questions.
The teaching staff (TA and myself) are here to help! Don’t wait too long before asking for help and do let us know right away if you are starting to fall behind. I will also publish the solutions after due date. It is highly encouraged that you study the posted solutions.
Course Tools
a. Working with Quarto
- Install or update quarto https://quarto.org/docs/get-started/ to version 1.8.26 (or greater).
- If you are using VSCode, install the Quarto extension.
- Course Homework Style
In order to help with grading, you need to use special formatting to generate the homework html file.
Download the following files and put them in the top level of where you will keep your homework.
An example directory structure is:
hw/
├─ _quarto.yml
├─ hw-style.css
├─ hw0.qmd
├─ hw0.html
├─ hw1.qmd
├─ hw1.html
...
b. Update IDE
Update your IDE and (optionally) try a new one! These will all work great for this course.
Positron (2026.01.0-147)
RStudio (2026.01.0+392)
VSCode (1.108)
- If using VSCode, install the Quarto extension
c. Update R
- Use the latest version (R 4.5.2, Quarto 1.8.26).
- Installation help R: https://cran.rstudio.com/
- Install/Update the following packages we will meet during this course:
- Using R and Python:
reticulate - Dynamic report generation:
rmarkdown,knitr,quarto - Utility:
remotes - Working with Data:
tidyverse - Data:
ISLR,moderndive,MASS - Resampling:
boot,rsample - Modeling:
tidymodels - Regression:
glmnet,FNN, - Classification:
e1071, - Trees:
rpart,rpart.plot,randomForest,ranger - Ensembles:
xgboost,lightgbm,bonsai - Forecasting:
fpp3
- Using R and Python:
To install/update an R package, open an R console and run
You can see which of your existing packages need updating by running:
old.packages() %>% as_tibble()Or use the update.packages() function to update them.
Note: Do not call install.packages() in this Quarto document; it only needs to be done once from the console. However you will need to use library() in Quarto since it needs to be called every time the document is compiled.
Below are some resources for help with modern R.
d. Python Package Manager
I recommend uv for python package management.
- To get you started, add the following
pyproject.tomlfile to your top-level class directory (e.g.,DS6030/):
pyproject.toml
[project]
name = "DS6030"
version = "0.1.0"
requires-python = ">=3.14"
dependencies = [
# numerical computing
"numpy",
"scipy",
# data manipulation
"pandas",
"polars",
"ibis-framework",
# machine learning
"scikit-learn",
"statsmodels",
# plotting and visualization
"matplotlib",
"seaborn",
"plotnine",
# notebooks and execution
"jupyterlab",
"ipykernel"
]- Then run the following to add the python and packages from the pyproject.toml:
uv sync
Problem 1: Math Notation
a. Least Squares
What are the equations for the least squares coefficients in linear regression (in matrix notation)? Use \(X\) for the model/design/predictor matrix, and \(Y\) the vector of outcomes.
b. MLE
Let \(x_1, x_2, \ldots, x_n\) be a sample of length of time that a customer is on the phone with a call center help line. We feel comfortable modeling the data as coming from an exponential distribution. What is the MLE (Maximum Likelihood Estimate) of the parameter? Show your steps.
Problem 2: Coding Practice
a. Simulation
Simulate 100 observations from the following model:
- \(X \sim N(\mu = 1, \sigma = 1)\)
- \(Y \sim N(\mu = 1 + 2X, \sigma = 2)\)
- \(Z = \begin{cases} 1 &\quad Y<0 \\ 2 &\quad Y \ge 0 \end{cases}\)
b. Scatterplot
Make a scatter plot of the data. Put \(X\) on the x-axis and \(Y\) on the y-axis. Color the points according to \(Z\).
c. Function
Write a function that adds two numbers together and squares the result.
Problem 3: Statistics
a. Quantiles
Find two quantiles that capture 95% of the following data:
set.seed(2026)
x = runif(n=100, min=2, max=22)import numpy as npModuleNotFoundError: No module named 'numpy'
rng = np.random.default_rng(2026)NameError: name 'np' is not defined
x = rng.uniform(low=2, high=22, size=100)NameError: name 'rng' is not defined
b. Confidence Interval
A new machine learning model, developed by UVA researchers, uses biopsy images to predict if a child has enteropathy or celiac disease. In a study of 102 patients, the model was able to correctly classify 95 of the images.
Find the 90% confidence interval for the probability a patient is correctly classified?
c. Linear Models
- Albemarle County, VA real estate assessment data can be found at this link. Data collected by UVAs StatLab as part of the PhD plus program (https://github.com/uvastatlab/phdplus).
Fit a linear regression model that predicts the
totalvalueusing the predictors:condition, size (finsqft), and location (city).What are the fitted model parameters (i.e., the estimated coefficients)?
What is the estimated
totalvaluefor home with the following characteristics?
| finsqft | city | condition |
|---|---|---|
| 2500 | EARLYSVILLE | Good |
| 1850 | CROZET | Fair |
d. Hypothesis Testing
Use the movies (IMDb) data from the ModernDive book to performance a hypothesis test that Action movies are ranked lower (on average) than Romance movies.