I am using MSBVAR package in R, and have used the following codes: library("MSBVAR") data(IsraelPalestineConflict) granger.test.c <- function(x) c(granger.test(x, p = 6)) aa<-rollapplyr(IsraelPalestineConflict, 1275, granger.test.c, by.column = FALSE ) In rollapply, the width is 1275 (data contains total 1278 observations) and hence i have four rolls. In granger.test.c the lag order "p" is fixed at 6. I want to use a changing "p" for each roll using R object "p<-c(3,4,5,6)". Help is requested, please. Best Jawad