You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/materials.html
+6-12Lines changed: 6 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -149,8 +149,7 @@ <h2 id="toc-title">On This Page</h2>
149
149
<li><ahref="#simple-tpc-fitting-pipeline-using-nlls" id="toc-simple-tpc-fitting-pipeline-using-nlls" class="nav-link" data-scroll-target="#simple-tpc-fitting-pipeline-using-nlls">Simple TPC fitting pipeline using NLLS</a></li>
150
150
<li><ahref="#introduction-to-the-vecdyn-database" id="toc-introduction-to-the-vecdyn-database" class="nav-link" data-scroll-target="#introduction-to-the-vecdyn-database">Introduction to the VecDyn database</a></li>
151
151
<li><ahref="#environmental-covariates-for-time-and-space-dependent-data" id="toc-environmental-covariates-for-time-and-space-dependent-data" class="nav-link" data-scroll-target="#environmental-covariates-for-time-and-space-dependent-data">Environmental covariates for time and space dependent data</a></li>
152
-
<li><ahref="#introduction-to-time-dependent-data" id="toc-introduction-to-time-dependent-data" class="nav-link" data-scroll-target="#introduction-to-time-dependent-data">Introduction to Time Dependent Data</a></li>
153
-
<li><ahref="#simple-time-dependent-data-pipeline" id="toc-simple-time-dependent-data-pipeline" class="nav-link" data-scroll-target="#simple-time-dependent-data-pipeline">Simple Time-dependent data pipeline</a></li>
152
+
<li><ahref="#introduction-to-time-dependent-data-and-reproducible-data-pipelines" id="toc-introduction-to-time-dependent-data-and-reproducible-data-pipelines" class="nav-link" data-scroll-target="#introduction-to-time-dependent-data-and-reproducible-data-pipelines">Introduction to Time Dependent Data and reproducible data pipelines</a></li>
<h3class="anchored" data-anchor-id="introduction-to-time-dependent-data-and-reproducible-data-pipelines">Introduction to Time Dependent Data and reproducible data pipelines</h3>
The year `{r} summaryDat$year[which.max(summaryDat$mean)]` had the highest average mosquito abundance. The year `{r} summaryDat$year[which.max(summaryDat$outliers)]` had the most outlier abundance observations. There were `{r} length(boxplot.stats(mosqDFcomb$totalMos)$out)` total outliers in the data set.
145
+
The year `{r} summaryDat$year[which.max(summaryDat$mean)]` had the highest average mosquito abundance, with an average of `r max(summaryDat$mean)` mosquitoes observed. The year `{r} summaryDat$year[which.max(summaryDat$outliers)]` had the most outlier abundance observations. There were `{r} length(boxplot.stats(mosqDFcomb$totalMos)$out)` total outliers in the data set.
140
146
141
147
**Make one more plot that might be interesting and add some text to describe it using inline code**
142
148
@@ -268,4 +274,4 @@ It is always good to think about how our models do well and where they fall shor
268
274
269
275
## Challenge
270
276
271
-
Using the skills you learned in the time-dependent covariate module, gather mean monthly temperature data for Suffolk, VA for the appropriate time frame and include temperature as a covariate in your model.
277
+
Using the skills you learned in the time-dependent covariate module, gather mean monthly temperature data for Suffolk, VA for the appropriate time frame and include temperature as a covariate in your model. Consider transforming the response variable (e.g., taking a square-root) to address non-homoskedastic elements of the data.
Copy file name to clipboardExpand all lines: vectorByte2026_timedepRegression.qmd
+16-10Lines changed: 16 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,14 @@
1
1
---
2
2
title: "Time Series Linear Regression and Automated Reports"
3
-
author: "Alicia Surratt"
3
+
author:
4
+
- name:
5
+
given: Alicia
6
+
family: Surratt
7
+
affiliation: Virginia Tech and VectorByte
8
+
citation: true
9
+
date: 2026-05-29
10
+
date-format: long
4
11
format: html
5
-
editor: visual
6
12
error: true
7
13
execute:
8
14
message: false
@@ -19,11 +25,11 @@ library(tidyverse)
19
25
20
26
Remember that simple linear regression fits a straight line through data by minimizing the distance between the fitted line and the actual data points (Ordinary Least Squares approach we explored in the NLLS session).
While we often use a straight line for demonstration, also remember that linear models can be used to model data that doesn't *look* linear by incorporating higher order terms or using categorical predictors.
Linear regression comes with certain assumptions about our data, and we check that the fitted model meets those assumptions using graphical methods or tests. Those assumptions are:
29
35
@@ -131,13 +137,13 @@ The way we approach modeling time series data (and data in general) often depend
131
137
132
138
When we want to extract information about a system as it exists now or existed in the past, our goal is to use the model for *inference*. In this case, we may choose to focus more on the validity of the model within the data we already have. This helps us to characterize structures of interest within the data set (e.g. seasonal patterns, annual trends).
133
139
134
-
{fig-align="center" width="507"}
140
+
{fig-align="center" width="507"}
135
141
136
142
#### Prediction
137
143
138
144
When we want to anticipate how a system will exist in the future, our goal is to use the model for *prediction*. In this case, we may choose the focus more on how well the model predicts responses from data we did not use to fit the model. This helps provide an idea about how the model will predict the future, which can be especially useful for people in resource management positions.
139
145
140
-
.](images/clipboard-2136995412.png){fig-align="center" width="538"}
146
+
.](graphics/clipboard-2136995412.png){fig-align="center" width="538"}
141
147
142
148
Our practical will focus primarily on the inferential case.
143
149
:::
@@ -248,11 +254,11 @@ summary(tempregAuto)
248
254
249
255
When the coefficient associated with an autoregressive variable is greater than 1, we call the time series an "exploding series", because this means that the observations are going to become exponentially far away from one another over time. In this case, an autoregressive term is often not very useful in our model.
On the other hand, when the coefficient is less than 1, the series is likely "stationary". This means that the values tend to move back toward the mean value when they start to get far away from the mean. In these cases, autoregressive terms are very useful and informative.
In our model, the coefficient was about 0.64, so the NY temperatures tend to regress toward the mean value over time!
258
264
:::
@@ -299,7 +305,7 @@ The drawback to this approach is the number of dummy variables that will be intr
299
305
300
306
On the other hand, if you want to simply account for seasonality so you can focus on other information in the data, we can use trigonometric (sine and cosine) seasonality terms. We can represent any smooth periodic function as the sum of sines and cosines. Remember what the sine and cosine functions look like? They repeat every period ($\frac{2\pi}{k}$).
301
307
302
-

308
+

303
309
304
310
It can be harder to directly compare these continuous functions to say that one season is statistically warmer than another, for example, but they require only 2 degrees of freedom! Adding these into the linear regression model from earlier looks like
305
311
@@ -361,4 +367,4 @@ In cases where we expect to keep generating new data in a data set or where we e
361
367
362
368
In the next activity, we will use the VecDyn API to access mosquito population data collected over several years in Suffolk, VA to produce a report that explores and models the data. These data continue to be collected, so there's a good chance we would want to repeat any analyses we did with these data in the future.
363
369
364
-
Download and open the 'reproducibleReport.qmd' file to get started using the skills you learned in this practical to build a simple reproducible report!
370
+
Download and open the [reproducibleReport.qmd](reproducibleReport.qmd) file to get started using the skills you learned in this practical to build a simple reproducible report!
0 commit comments