Use the source Luke:
> library(TTR)
> volatiliy
function (OHLC, n = 10, calc = "close", N = 260, mean0 = FALSE, ...)
{
OHLC <- try.xts(OHLC, error = as.matrix)
calc <- match.arg(calc, c("close", "garman.klass", "parkinson",
"rogers.satchell", "gk.yz", "yang.zhang"))
<snip>
if (calc == "garman.klass") {
s <- sqrt(N/n * runSum(0.5 * log(OHLC[, 2]/OHLC[, 3])^2 -
(2 * log(2) - 1) * log(OHLC[, 4]/OHLC[, 1])^2, n))
}
<snip>
reclass(s, OHLC)
}
clearly the TTR
package is using runSum
which seems to be rather complicated on it own. However, we can simply do
> runSum(1:11, n = 10)
NA NA NA NA NA NA NA NA NA 55 65
to see that indeed the first 9 values of runSum
called with n = 10
generate 9 NA
values. In R those NA
's will propagate.
This intuitively makes sense for the reason you suggest in your question.