Advanced Data Visualization – 001 | Lesson 07 — Time-Series Visualization, Trend, Seasonality and Frequency-Domain Analysis

AI GENERATED CONTENT — POSTED AS IS. Questions and topic outlines were adapted from Open Education source posts (attributed to this site and, where identified there, Sayed Ahmed). Newly AI-generated explanations, original synthetic graphics and code are offered for reuse without copyright restrictions asserted by this blog. Third-party rights remain applicable; AI can make mistakes.

Advanced Data Visualization – 001: course index · Source articles: Post 16153 · Post 16059 · Post 16051

Learning goals: The blog’s time-series resources ask about trend, seasonal patterns, stationarity, decomposition, frequency-domain analysis and interactive plots. A time-series graphic must preserve chronological order and consistent sampling intervals.

Original schematic plot illustrating Time-Series Visualization, Trend, Seasonality and Frequency-Domain Analysis.
Original course-generated illustration; synthetic values, not measurements.

Theory and practical decisions

Trend describes slower variation, seasonality repeats at a known periodicity, and cycles may have variable durations. An additive model works when seasonal variation is roughly constant; a multiplicative model may better fit proportional swings after ensuring positivity.

Decomposition does not guarantee accurate prediction. Before reporting forecasts, inspect missing periods, structural breaks, autocorrelation and uncertainty. Frequency spectra help identify periodicity but suffer from aliasing and leakage.

Mathematical model

Additive model yₜ=Tₜ+Sₜ+εₜ. Discrete Fourier transform Xₖ=Σₜ₌₀ⁿ⁻¹ yₜ exp(−2πikt/n). For monthly data, a 12-month cycle corresponds to 1/12 cycles/month.

Python example and plot

import numpy as np, pandas as pd
import matplotlib.pyplot as plt
t=np.arange(48)
y=50+.35*t+8*np.sin(2*np.pi*t/12)+2*np.cos(2*np.pi*t/5)
dates=pd.date_range("2023-01-01",periods=len(t),freq="MS")
fig,ax=plt.subplots(figsize=(8,4))
ax.plot(dates,y,label="synthetic monthly metric")
ax.plot(dates,50+.35*t,"--",label="trend")
ax.legend();ax.set_ylabel("Metric");plt.tight_layout();plt.show()
spectrum=np.abs(np.fft.rfft(y-np.mean(y)))**2
freq=np.fft.rfftfreq(len(y),d=1)
dominant=freq[1:][np.argmax(spectrum[1:])]
print("Dominant cycles/month:",dominant)

R example and plot

t <- 0:47
y <- 50 + .35*t + 8*sin(2*pi*t/12) +
     2*cos(2*pi*t/5)
series <- ts(y,start=c(2023,1),frequency=12)
plot(series,main="Synthetic monthly series",ylab="Metric")
lines(ts(50+.35*t,start=c(2023,1),frequency=12),
      lty=2,col="blue")
parts <- decompose(series,type="additive")
plot(parts)
spec <- spectrum(series,plot=FALSE)
print(spec$freq[which.max(spec$spec)])

Expected output and interpretation

The plotted monthly series has an upward linear trend and a pronounced annual cycle. The highest nonzero frequency peak should be near 1/12 cycles per month (subject to trend and finite-sample effects).

Questions and answers

Q1. What is the difference between time and frequency domains?

Answer. Time domain shows values by date; frequency domain summarizes the strength of oscillations at different frequencies.

Q2. Is every annual-looking pattern seasonality?

Answer. Not necessarily: repeated evidence over multiple cycles and domain knowledge are needed.

Q3. Why do stationarity checks matter?

Answer. Many methods assume stable statistical properties; trend and changing variance can invalidate naïve comparisons.

Assessment

Generate four years of monthly values with annual seasonality; plot trends, decompose, and report the strongest nonzero spectral frequency.

Translated to Bengali / বাংলায় অনুবাদ

বাংলা অনুবাদ: উপরের ব্যাখ্যামূলক পাঠ ও প্রশ্নোত্তরের সহজ ও শুদ্ধ বাংলা রূপ এখানে দেওয়া হলো। কোডের Python ও R সিনট্যাক্স অপরিবর্তিত।

শেখার লক্ষ্য: সাইটের টাইম-সিরিজ উৎসে প্রবণতা, মৌসুমি পরিবর্তন, স্থিতিশীলতা, বিশ্লেষণভাগ এবং ফ্রিকোয়েন্সি ডোমেইনের প্রশ্ন আছে। সময়ক্রম ও নমুনার ব্যবধান ঠিক রাখা জরুরি।

প্রবণতা দীর্ঘমেয়াদি গতি, মৌসুমিতা নির্দিষ্ট বিরতিতে পুনরাবৃত্তি, আর চক্রের দৈর্ঘ্য পরিবর্তনশীল হতে পারে। মৌসুমি ওঠানামা স্থির হলে যোগমূলক মডেল, অনুপাতভিত্তিক হলে গুণমূলক মডেল বিবেচ্য।

সিরিজকে উপাদানে ভাগ করলেই পূর্বাভাস নির্ভুল হয় না। অনুপস্থিত সময়, গঠনগত পরিবর্তন ও সম্পর্ক পরীক্ষা করুন। ফ্রিকোয়েন্সি স্পেকট্রাম পুনরাবৃত্তি দেখায়; তবে অ্যালিয়াসিং ও লিকেজ সমস্যা থাকতে পারে।

গাণিতিক ধারণা: যোগমূলক মডেল yₜ=Tₜ+Sₜ+εₜ। বিচ্ছিন্ন ফুরিয়ার রূপান্তর Xₖ=Σ yₜ exp(−2πikt/n)। মাসিক উপাত্তে ১২ মাসের চক্রের ফ্রিকোয়েন্সি প্রতি মাসে ১/১২ চক্র।

প্রত্যাশিত ফল: মাসিক রেখাচিত্রে ঊর্ধ্বমুখী প্রবণতা ও বার্ষিক চক্র দেখা যায়। সবচেয়ে শক্তিশালী শূন্য-বহির্ভূত ফ্রিকোয়েন্সি প্রায় প্রতি মাসে ১/১২ চক্রের কাছাকাছি হওয়ার কথা।

প্রশ্ন 1. টাইম ও ফ্রিকোয়েন্সি ডোমেইনের পার্থক্য কী?

উত্তর: টাইম ডোমেইনে সময় অনুযায়ী মান, ফ্রিকোয়েন্সি ডোমেইনে পুনরাবৃত্তির বিভিন্ন কম্পাঙ্কের শক্তি দেখা যায়।

প্রশ্ন 2. বার্ষিকের মতো যে কোনো ওঠানামাই কি মৌসুমিতা?

উত্তর: অবশ্যই নয়। একাধিক বছরের পুনরাবৃত্তি ও বিষয়গত প্রমাণ দরকার।

প্রশ্ন 3. স্থিতিশীলতা পরীক্ষা কেন গুরুত্বপূর্ণ?

উত্তর: অনেক পদ্ধতি পরিসংখ্যানগত বৈশিষ্ট্য স্থিতিশীল ধরে; প্রবণতা বা ভ্যারিয়েন্স বদলালে ফল বিভ্রান্তিকর হতে পারে।

বাংলা অনুশীলন

চার বছরের মাসিক কৃত্রিম উপাত্ত তৈরি করে প্রবণতা, মৌসুমি অংশ ও প্রধান ফ্রিকোয়েন্সি নির্ণয় করুন।

মূল উৎসগুলোর লিংক উপরে আছে। এআই-তৈরি নিজস্ব ব্যাখ্যা ও চিত্র পুনর্ব্যবহারে এই ব্লগ থেকে কপিরাইটের বিধিনিষেধ দেওয়া হচ্ছে না। তৃতীয় পক্ষের অধিকার আলাদা। এআই ভুল করতে পারে, তাই যাচাই করুন।


Discover more from Open Education

Subscribe to get the latest posts sent to your email.

Leave a Reply

Discover more from Open Education

Subscribe now to keep reading and get access to the full archive.

Continue reading