search for: movingwindowregress

Displaying 2 results from an estimated 2 matches for "movingwindowregress".

2004 Apr 24
4
Moving window regressions - how can I improve this code?
...ive, but that's rocket science to me!! For a regression with K explanatory variables, I make a matrix with 2*K+2 columns, where I capture: K coefficients and K standard errors the residual sigma R^2 My code is: # ------------------------------------------------------------ movingWindowRegression <- function(data, T, width, model, K) { results = matrix(nrow=T, ncol=2*K+2) for (i in width:T) { details <- summary.lm(lm(as.formula(model), data[(i-width+1):i,])) n=1; for (j in 1:K) { results[i, n] = details$coefficients[j, 1] results[i...
2006 Aug 31
0
Moving Window regressions with corrections for Heteroscedasticity and Autocorrelations(HAC)
...standard error, t-stat and pvalue. # To implement the corrections for Heteroscedasticity and Autocorrelations for a moving/rolling # window OLS regression, here is the actual function: #--------------------------------------------------------------------------------------------------------- >movingWindowRegression <- function(data, T, width, model, K) { results = matrix(nrow=T, ncol=4*K) for (i in width:T) { details <-coeftest(lm(model,data[(i-width+1):i,]),NeweyWest) n=1; for (j in 1:K) { results[i,n:(n+3)] = details[j, 1:4] n=n+4 } } return(resu...