hi,

Could anyone help me in solving the following error:
I have 5 stocks returns data (returns)

EWMA = matrix(nrow=T,ncol=5)                  # create a matrix to hold the
covariance matrix for each t

lambda = 0.94
S<-cov(returns)                                         # initial (t=1) 
covariance matrix
EWMA[1,] = c(S)[c(1,4,2)]                  ---ERROR        # extract the
variances and covariancefor (i in 2:T)

   {            # loop though the sample
        S<- lambda*S+(1-lambda)*t(returns[i])%*%returns[i]      
        EWMA[i,] = c(S)[c(1,4,2)]       # convert matrix to vector          }

*ERROR as follows:*

*> EWMA[1,]<-c(S)[c(1,4,2)]*
*Error in EWMA[1, ] <- c(S)[c(1, 4, 2)] : *
*  number of items to replace is not a multiple of replacement length*

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to