0

I am using the rollapply function to create a rolling logit estimation. The function is doing its job properly so far, but I would now like to extract for each iteration of the data the last values of that specific window to use these for the prediction of the next following period. I tried to use a simple apply function but it seems not to work. Here is my code:

    rollapply(zoo(DATASET),
      width=300,
      FUN = function(Z) 
      { 
        t = glm(formula= y ~ ( Sentiment-SentimentLag) + (Sentiment-SentimentLag10) + Volume  , data = as.data.frame(Z),family=binomial(link='logit')); 
        new <- coeftest(t,vcov.=vcovHAC(t,sandwich = T))
        pval <- new[,4]

        #### this line does only return single values and not the vector I want
        lastOb <- as.matrix(apply(Z,1,max))

      },
       by.column=FALSE, align="right" )

What am I doing wrong?

4

0 回答 0