Hi, I followed the code given in the link
http://www.forecastingfinancialrisk.com/3.html EWMA<-matrix(nrow=T,ncol=5) S<-cov(returns) dim(S) [1] 5 5 "EWMA[1,] = c(S)[c(1,4,2)] # extract the variances and covariance" *here we will get a vector but we are equating with a matrix. hence the following error.* > 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 *but how to rectify this error and use the code to calculate correlations etc....* Please help me. * * [[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.