توضیح 1
The live starter code is self-contained and uses only runner-compatible functions.
Loading
درس 17 از 22
Advanced Topic – Optional. Compare rolling, annualized, realized, and range-based measures with explicit units and sampling choices.
Advanced Topic – Optional
This chapter extends the core pathway. Complete Chapters 1–14 first, then use this material when your question and data justify the added model complexity.
Motivation
Volatility is latent, so every estimate embeds a window, grid, annualization factor, or model.
Why this matters
Compare rolling, annualized, realized, and range-based measures with explicit units and sampling choices.
Packages and data
Base R; zoo, xts, highfrequency, and TTR are optional.
توضیح 1
The live starter code is self-contained and uses only runner-compatible functions.
توضیح 2
Book-only outputs are labelled when the separate source dataset or advanced package was not supplied.
توضیح 3
R code, paths, function names, and formulas remain left-to-right in every locale.
اصطلاحات
Windowed standard deviation using recent returns.
Responsive but backward-looking
Sum of squared intraday log returns.
Variance units, not volatility
Bid-ask bounce, discreteness, and asynchronous trading distort fine grids.
Finer is not always better
نمادگذاری و فرمولها
annualized volatility = sqrt(k) × sd(returns); realized variance = sum(r_j^2)
Variance scales by k under the conventional independent-increment approximation, so standard deviation scales by sqrt(k).
مثال حلشده
سناریو
How does sampling aggregation alter realized volatility in a clean simulation?
بررسی با R
set.seed(1717)
r <- rnorm(390,sd=.012/sqrt(390))
intervals <- c(1,5,15,30,65)
rv <- sapply(intervals,function(k){g<-ceiling(seq_along(r)/k); a<-as.numeric(rowsum(r,g)); sqrt(sum(a^2))})
print(data.frame(minutes=intervals,realized_vol_percent=100*rv))Without microstructure noise, the exercise isolates sampling variation rather than real tick-data bias. Limitation: Real high-frequency data add market microstructure, gaps, and timestamp issues; this simulation does not.
Visual
Realized-volatility estimates vary across aggregation intervals.
ارتباط با R
Run the self-contained starter code in the protected STATLAB R runner. The code prints an auditable result and avoids network or unrestricted file access.
Live R Lab
Run a self-contained example, verify its output, and explain one limitation for measuring volatility and realized variation.
Ready to run
Common mistake
Do not annualize a standard deviation by multiplying by periods; use the square root.
STATLAB Tip
Put the unit in object names such as annualized_vol_percent.
تمرین هدایتشده
سناریو
Compare 6-, 12-, and 24-period rolling windows for responsiveness and missing early estimates.
Compare your result with the definition, units, and model assumptions—not only with a target number.
Exercises
Complete these without looking at the selected solutions. More than one defensible program may exist.
توضیح 1
Show realized variance units.
توضیح 2
Add alternating bid-ask noise.
توضیح 3
Compute Parkinson variance.
Selected solutions
These are compact solution routes. Confirm dimensions, units, and any changed modelling choices.
توضیح 1
Squared log returns sum to squared-return units.
توضیح 2
Perturb alternating observed prices and compare sampling grids.
توضیح 3
mean(log(high/low)^2)/(4*log(2))
Chapter summary
Compare rolling, annualized, realized, and range-based measures with explicit units and sampling choices.
توضیح 1
Window length affects rolling estimates.
توضیح 2
Realized variance sums squares.
توضیح 3
Fine grids face noise bias.
توضیح 4
Range measures add information under assumptions.
اصطلاحات
rolling window
Use in Measuring Volatility and Realized Variation.
annualize
Use in Measuring Volatility and Realized Variation.
realized variance
Use in Measuring Volatility and Realized Variation.
aggregate intraday returns
Use in Measuring Volatility and Realized Variation.
References and provenance
Safavi (2026), Chapter 17. Student notes: Mohammad Safavi, Ph.D., STATLAB Academy, Version 1.0.
منبع
The authoritative 125-page English PDF accompanies this native lesson.
دریافتبازاندیشی
Name the assumption, evidence you would seek, and how the recommendation might change.
ارزیابی پایانی