I have the following vector
s<-c(-0.1516865068,0.0777125437,  0.0596115942, -0.0066893552,  0.0111096953,   
0.0523087458, -0.0376922037,  0.0640068468,  0.0085058973, -0.0059950522,
0.0889039984,  0.0242030489, -0.0777979006, -0.0091988501,  0.0744002004, -0.0343007491,   
0.0156983014, -0.0601026480,  0.0848964025, -0.1040045470,0.0328945035, -0.0400064460, 
-0.0545073955, -0.0214083450, -0.0816092944,  0.1197897561,  0.0709888066,-0.0589121429, 
-0.0020130924, -0.0519140419,0.0015850086, -0.0215159408, -0.0315168903, -0.0645178398,  
0.0136812107, -0.0961197388,  0.0024793117,  0.0549783622,  0.1498774128,  0.0256764633,
-0.0124244862,  0.0529745643, -0.0709263852, -0.0438273347, -0.0442282842, 
-0.0109292336, -0.0118301831,  0.0290688674,  0.1202679179, -0.0881330316,-0.0685339811, 
-0.1182349306, -0.0772358800,  0.1094631705, -0.0542377790, -0.0561387285,  
0.0630603220,  0.0307593725,  0.0441584230,  0.0601574736, -0.0956434759, -0.0228444254,   
0.1257546251,  0.0437536756,  0.1038527261, -0.1235482234,  0.0090508272,  0.0865498777, 
-0.0672510718, -0.0219520213,-0.0088529708, -0.0123539203,  0.0323451303, -0.0395558192,  
0.0880432313, 0.0126422818,  0.1011413323, -0.0223596172, -0.1004605667, 
-0.0113615161,-0.0436624656, -0.0006634151,  0.0170356354,  0.0376346859, 0.0266337364,  
0.0501327869, -0.0153681625, -0.0671691120,  0.0525299385,  0.0332289890,-0.0551719605,  
0.0532270900,  0.0184261405, -0.0312748089,  0.0636242416, -0.0742767079, -0.0419776574,  
0.0608213931, -0.0559795564,  0.0298194941)
I have a function
spectrum(s, method = c("ar"))
I would like to run on a rolling window different values of width on the above function using rollapply or sapply from zoo package.
rollapply(s, width= ,FUN= , by =  )
I guess I have to write the function applying sapply similar as below but I can not find a way to put toguether the function and the parameters of sapply toguether
wide<-c(4,6,12)
for(i in 1:length(wide)){
b<-spectrum(s, method = c("ar"))
c<-sapply(s, width=wide[i],FUN=b, by = 1)
Sp[i] <- c    
}
Error en FUN(X[[1L]], ...) : unused arguments (width = 4, by = 1)
When doing the above I get the below as I not find a way to pass the arguments
Thank you
 
    