Serving the Quantitative Finance Community

 
User avatar
JediQuant
Topic Author
Posts: 0
Joined: October 14th, 2005, 3:28 pm

Specral Decomposition of a large matrix

May 26th, 2008, 11:32 am

I have a variance covariance matrix which is of a high dimension...4000x4000. I am using R and trying to do a spectral decomposition..however, due to the size of the matrix R reports memory issues and is unable to do it. I was wondering whether there is a way for me to do this.. perhaps by breaking up the matrix into smaller matrices or something..?Any advice would be appreciated.Regards,JQ
 
User avatar
Polter
Posts: 1
Joined: April 29th, 2008, 4:55 pm

Specral Decomposition of a large matrix

May 26th, 2008, 12:42 pm

I assume you're using eigen(X), where X is your matrix. Does it help when you set symmetric (also works for Hermitian if the matrix is complex) to true, i.e. eigen(X, symmetric = TRUE)? What is your ultimate goal, by the way? If you need this for the PCA, for example, then perhaps there's a faster way to do it -- while in principle one could use the eigenvalue decomposition of a covariance matrix, it might be better to use fast.prcomp() instead (needs data matrix, though):http://finzi.psych.upenn.edu/R/library/ ... rcomp.html
Last edited by Polter on May 25th, 2008, 10:00 pm, edited 1 time in total.
 
User avatar
JediQuant
Topic Author
Posts: 0
Joined: October 14th, 2005, 3:28 pm

Specral Decomposition of a large matrix

May 26th, 2008, 12:50 pm

Thanks for the suggestion. I am indeed using eigen(X)..I haven't tried symmetric=TRUE. The R help thingie says:symmetric: if 'TRUE', the matrix is assumed to be symmetric (or Hermitian if complex) and only its lower triangle is used. If 'symmetric' is not specified, the matrix is inspected for symmetry.I suspect that since it automatically inspects for symmetry...explicitly specifying symmetric=TRUE would not make a difference. I shall give it a go though and report back!JQ
 
User avatar
JediQuant
Topic Author
Posts: 0
Joined: October 14th, 2005, 3:28 pm

Specral Decomposition of a large matrix

May 26th, 2008, 4:33 pm

My goal is to use the decomposition to generate a multivariate Gaussian random vector with my X matrix as its covariance. Unless I am mistaken, this is the standard way to do this.BTW, I tried the symmetric=TRUE part...however, my computer crashed..so I guess its not gonna work!
 
User avatar
Polter
Posts: 1
Joined: April 29th, 2008, 4:55 pm

Specral Decomposition of a large matrix

May 26th, 2008, 7:47 pm

I think it's simple to just use Cholesky decomposition for this. Check here for example in R:http://astrostatistics.psu.edu/su07/R/mv.htmlStill, R has plenty of packages which have this functionality (generating multivariate Gaussians) built-in:http://finzi.psych.upenn.edu/R/library/ ... orm.htmlIs there a reason you're not using any of the above?
Last edited by Polter on May 25th, 2008, 10:00 pm, edited 1 time in total.
 
User avatar
JediQuant
Topic Author
Posts: 0
Joined: October 14th, 2005, 3:28 pm

Specral Decomposition of a large matrix

May 26th, 2008, 8:19 pm

QuoteOriginally posted by: PolterI think it's simple to just use Cholesky decomposition for this. Check here for example in R:http://astrostatistics.psu.edu/su07/R/mv.htmlStill, R has plenty of packages which have this functionality (generating multivariate Gaussians) built-in:http://finzi.psych.upenn.edu/R/library/ ... orm.htmlIs there a reason you're not using any of the above?I actually tried using mvrnorm, however, it uses the eigen function as well and therefore fails. I didn't think there would be any more R packages dealing with this. I shall check these out. Perhaps one of these does it more efficiently. Many thanks for the links!
 
User avatar
Alan
Posts: 3050
Joined: December 19th, 2001, 4:01 am
Location: California
Contact:

Specral Decomposition of a large matrix

May 28th, 2008, 3:31 pm

Maybe some kind of sector/industry model would be better; certainly more feasible.What are you planning to do with these 4000 time series if you could generate them?
 
User avatar
JediQuant
Topic Author
Posts: 0
Joined: October 14th, 2005, 3:28 pm

Specral Decomposition of a large matrix

June 2nd, 2008, 12:30 pm

QuoteOriginally posted by: AlanMaybe some kind of sector/industry model would be better; certainly more feasible.What are you planning to do with these 4000 time series if you could generate them?Alan,My application is purely time series. I have fitted a model (with a certain correlation structure) to a time series of length 4,000+. Now to check whether the simulations produced from the fitted model match the statistical characteristics of the actual data I am in need of simulating a sequence of the same length as my actual time series. Hence the need for a spectral decomposition of the variance covariance matrix.JQ.
 
User avatar
Traden4Alpha
Posts: 3300
Joined: September 20th, 2002, 8:30 pm

Specral Decomposition of a large matrix

June 2nd, 2008, 2:01 pm

If you can't find a way to do the full 4000 instrument model, you might consider clustering the 4000 instruments and culling some of the nearest-neighbor instruments. Although you may lose a little statistical sensitivity, the smaller data set should capture the dominant variations and covariations across time and industry sectors.The other alternative is to buy more RAM. Have you done any scaling studies to see how much RAM you need or how large a set of equations you can handle? Can you handle 500x500, 1000x1000, or 2000x2000? And, if so, how much RAM is consumed?
 
User avatar
Alan
Posts: 3050
Joined: December 19th, 2001, 4:01 am
Location: California
Contact:

Specral Decomposition of a large matrix

June 2nd, 2008, 3:11 pm

QuoteOriginally posted by: JediQuantQuoteOriginally posted by: AlanMaybe some kind of sector/industry model would be better; certainly more feasible.What are you planning to do with these 4000 time series if you could generate them?Alan,My application is purely time series. I have fitted a model (with a certain correlation structure) to a time series of length 4,000+. Now to check whether the simulations produced from the fitted model match the statistical characteristics of the actual data I am in need of simulating a sequence of the same length as my actual time series. Hence the need for a spectral decomposition of the variance covariance matrix.JQ.I'm confused. Is there a single time series of length 4000, and the correlations are auto-correlations? Or 4000 separate time series, each of length T? If so, what is T?
 
User avatar
Polter
Posts: 1
Joined: April 29th, 2008, 4:55 pm

Specral Decomposition of a large matrix

June 2nd, 2008, 4:53 pm

The first one (rmvnorm from the mvtnorm package) works rather fine for me (could be faster).Here's the output for my case (I also use genPositiveDefMat from clusterGeneration) -- let me know if that helps: