Skip to content

Rolling Beta

1 message · Brian G. Peterson

#
As with most things in R, you can see the code by typing the function 
name without the parentheses.

In the case of rolling beta, the important line is this:

rollapply(na.omit(merged.assets[,, drop = FALSE]),
                  width = width, FUN = function(x) lm(x[,1, drop = FALSE]
                  ~ x[, 2, drop = FALSE])$coefficients[2],
                  by = 1, by.column = FALSE, na.pad = na.pad,
                  align = "right")

Regards,

   - Brian
Eduard Pieterse (Macquarie Securities) wrote: