11---
2- title : " Time series analysis in the frequency domain"
2+ title : " Time series analysis<br> in the frequency domain"
33subtitle : " FISH 550 – Applied Time Series Analysis"
44author : " Mark Scheuerell"
5- date : " 23 May 2023 "
5+ date : " 22 May 2025 "
66output :
77 ioslides_presentation :
88 css : lecture_slides.css
9+ widescreen : true
10+ mathjax : " https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml-full.js"
911---
1012
1113
1214``` {r setup, include=FALSE}
13- knitr::opts_chunk$set(echo = FALSE)
15+ knitr::opts_chunk$set(echo = FALSE, fig.align = "center" )
1416library(MARSS)
1517set.seed(123)
1618```
@@ -45,9 +47,23 @@ We can think of this as comparing changes in amplitude (displacement) with time
4547
4648## Frequency domain
4749
48- Today we'll consider how amplitude changes with frequency
50+ Analyzing time series in the frequency domain involves examining the signal's frequency components, rather than its time-based behavior
4951
5052
53+ ## Some advantages | Simplified mathematics
54+
55+ For systems governed by _ linear differential equations_ (many real-world examples)
56+
57+ converting from the time domain to the frequency domain converts the system to _ algebraic equations_
58+
59+
60+ ## Some advantages | More intuitive
61+
62+ Terms like bandwidth, gain, phase shift are common
63+
64+ For example, musical notes are just component frequencies
65+
66+
5167## Jean-Baptiste Fourier (1768 - 1830)
5268
5369French mathematician & physicist best known for his studies of heat transfer
@@ -127,8 +143,21 @@ par(mai = c(0.9,0.9,0.3,0.1), omi = c(0,0,0,0))
127143plot.ts(xt, type = "n", las = 1,
128144 ylab = expression(italic(x[t])))
129145matlines(t(fs), lty = "solid",
130- col = viridis::plasma(nn, 0.7, 0.1, 0.5))
131- lines(xt, lwd = 2)
146+ col = viridis::plasma(nn, 0.7, 0.1, 0.7), lwd = 2)
147+ # lines(xt, lwd = 2)
148+ ```
149+
150+
151+ ## Fourier series
152+
153+ ``` {r fourier_ex_2}
154+ par(mai = c(0.9,0.9,0.3,0.1), omi = c(0,0,0,0))
155+
156+ plot.ts(xt, type = "n", las = 1,
157+ ylab = expression(italic(x[t])))
158+ matlines(t(fs), lty = "solid",
159+ col = viridis::plasma(nn, 0.7, 0.1, 0.7), lwd = 2)
160+ lines(xt, lwd = 3)
132161```
133162
134163
@@ -137,7 +166,7 @@ lines(xt, lwd = 2)
137166``` {r}
138167par(mai = c(0.9,0.9,0.3,0.1), omi = c(0,0,0,0))
139168
140- plot(seq(nn), apply(fs, 1, max), type = "h", las = 1,
169+ plot(seq(nn), apply(fs, 1, max), type = "h", las = 1, lwd = 3,
141170 ylab = "Amplitude", xlab = "Frequency")
142171```
143172
@@ -514,9 +543,11 @@ where the $c_k$ are filter coefficients*
514543Simple, but commonly used, where $\small K = 1; ~ c_0 = 1; ~ c_1 = 1$
515544
516545$$
546+ \begin{gather}
517547\psi(t) = \sum_{k=0}^K c_k \psi(2t - k) \\
518548\big \Downarrow \\
519549\psi(t) = \psi(2t) + \psi(2t - 1)
550+ \end{gather}
520551$$
521552
522553The only function that satisfies this is:
632663\psi_{j,k}(t) = 2^{j/2} \psi(2^j t - k)
633664$$
634665
635- The basic Haar wavelet has $j = 0$
666+ The mother Haar wavelet has $j = 0$
636667
637668Setting $j = 1$ yields a daughter
638669
@@ -670,13 +701,13 @@ plot(ti, haar4(ti), type = "l", lwd = 2,
670701
671702## Other wavelets
672703
673- There are many forms of wavelets, many of which were developed in the past 50 years
704+ There are many forms of wavelets, many of which were developed< br > in the past 50 years
674705
675706
676- ## Morlet {data-background=morlet.png data-background-size=cover }
707+ ## Morlet {data-background=morlet.png data-background-size=75% data-background-position='50% 65%' }
677708
678709
679- ## Mexican Hat {data-background=hat.png data-background-size=cover }
710+ ## Mexican Hat {data-background=hat.png data-background-size=75% data-background-position='50% 65%' }
680711
681712
682713## Who does this?
@@ -689,7 +720,7 @@ Wavelet analysis is used widely in audio & video compression
689720
690721## Estimating wavelet transforms in R
691722
692- We'll use the __ WaveletComp __ package, which uses the Morlet wavelet
723+ We'll use the __ {WaveletComp __ } package, which uses the Morlet wavelet
693724
694725We'll also use the L Washington temperature data from the __ MARSS__ package
695726
@@ -706,11 +737,11 @@ dat <- data.frame(tmp = tmp)
706737
707738Use ` analyze.wavelet() ` to estimate the wavelet transform
708739
709- ``` {r, echo = TRUE, progress = FALSE}
710- w_est <- analyze.wavelet(dat, "tmp", ## need both df & colname
711- loess.span = 0, ## no de-trending
712- dt = 1/12, ## monthly sampling
713- lowerPeriod = 1/6, ## default = 2*dt
740+ ``` {r, echo = TRUE, progress = FALSE, message = FALSE }
741+ w_est <- analyze.wavelet(dat, "tmp", ## need both df & colname
742+ loess.span = 0, ## no de-trending
743+ dt = 1/12, ## monthly sampling
744+ lowerPeriod = 1/6, ## default = 2*dt
714745 n.sim = 100,
715746 verbose = FALSE)
716747```
0 commit comments