Hello!
I have to generate a Variance Covariance Matrix of assets returns using as parameter a decay factor of 0.97.
Does anyone knows how can i include the decay factor? (the cov function does not allow me to do that)
Thank you very much in advance for your attention.
Giorgio
|
|
0
|
|
|
|
Reply
|
Giorgio
|
12/27/2010 3:26:05 PM |
|
On 12/27/2010 10:26 AM, Giorgio Solfaroli wrote:
> I have to generate a Variance Covariance Matrix of assets returns using
> as parameter a decay factor of 0.97.
> Does anyone knows how can i include the decay factor? (the cov function
> does not allow me to do that)
The COV function is for computing a sample covariance matrix, given
data. There are no model parameters involved at all. It sounds like
you want to compute a theoretical covariance. You should be able to do
that based on whatever model you are using.
|
|
0
|
|
|
|
Reply
|
Peter
|
12/27/2010 5:52:25 PM
|
|
Peter Perkins <Peter.Perkins@MathRemoveThisWorks.com> wrote in message <ifajop$egt$1@fred.mathworks.com>...
> On 12/27/2010 10:26 AM, Giorgio Solfaroli wrote:
> > I have to generate a Variance Covariance Matrix of assets returns using
> > as parameter a decay factor of 0.97.
> > Does anyone knows how can i include the decay factor? (the cov function
> > does not allow me to do that)
>
> The COV function is for computing a sample covariance matrix, given
> data. There are no model parameters involved at all. It sounds like
> you want to compute a theoretical covariance. You should be able to do
> that based on whatever model you are using.
Hi! thanks for your reply!
I want to compute a GBM with a theoretical mean using a Variance Covariance Matrix computed with a decay factor of 0.97..Do you have any suggestion to give me?
|
|
0
|
|
|
|
Reply
|
Giorgio
|
12/28/2010 8:07:05 AM
|
|
On Dec 27, 10:26 am, "Giorgio Solfaroli"
<giorgio.solfar...@uniqagroup.it> wrote:
> Hello!
>
> I have to generate a Variance Covariance Matrix of
> assets returns using as parameter a decay factor of 0.97.
> Does anyone knows how can i include the decay factor?
>(the cov function does not allow me to do that)
>
> Thank you very much in advance for your attention.
>
> Giorgio
M No. of assets
N No. of time instants (N is index of latest asset)
X0 Original assets return matrix
size(X0) = [N M]
W diagonal exponential decay weight matrix
W0i = a^(N-i) % i = 1:N, a = 0.97
Wi = W01/sum(W0i)
X Exponentially weighted assets return matrix
X = W*X0
covX = cov(X);
Hope this helps.
Greg
|
|
0
|
|
|
|
Reply
|
Greg
|
12/28/2010 3:02:51 PM
|
|
Greg Heath <heath@alumni.brown.edu> wrote in message <1efad805-f60f-460b-8764-5c3e2f434956@30g2000yql.googlegroups.com>...
> On Dec 27, 10:26 am, "Giorgio Solfaroli"
> <giorgio.solfar...@uniqagroup.it> wrote:
> > Hello!
> >
> > I have to generate a Variance Covariance Matrix of
> > assets returns using as parameter a decay factor of 0.97.
> > Does anyone knows how can i include the decay factor?
> >(the cov function does not allow me to do that)
> >
> > Thank you very much in advance for your attention.
> >
> > Giorgio
>
> M No. of assets
> N No. of time instants (N is index of latest asset)
> X0 Original assets return matrix
>
> size(X0) = [N M]
>
> W diagonal exponential decay weight matrix
>
> W0i = a^(N-i) % i = 1:N, a = 0.97
> Wi = W01/sum(W0i)
>
> X Exponentially weighted assets return matrix
>
> X = W*X0
>
> covX = cov(X);
>
> Hope this helps.
>
> Greg
Hello Greg!
Thank you very much for your reply!
I wrote down this code:
for i=1:N
W0(i) = 0.97^(N-i);
W(i) = W0(1)/sum(W0(i));
end
X = W*X0;
covX = cov(X);
Where M=43 and N=74
Anyway what i get is a single covariance number (cov(X) is a 1x1 matrix, instead of 43)
Where is my mistake?
Thanks again for your help!
|
|
0
|
|
|
|
Reply
|
Giorgio
|
12/29/2010 9:38:04 AM
|
|
On Dec 29, 4:38 am, "Giorgio Solfaroli"
<giorgio.solfar...@uniqagroup.it> wrote:
> Greg Heath <he...@alumni.brown.edu> wrote in message <1efad805-f60f-460b-8764-5c3e2f434...@30g2000yql.googlegroups.com>...
> > On Dec 27, 10:26 am, "Giorgio Solfaroli"
> > <giorgio.solfar...@uniqagroup.it> wrote:
> > > Hello!
>
> > > I have to generate a Variance Covariance Matrix of
> > > assets returns using as parameter a decay factor of 0.97.
> > > Does anyone knows how can i include the decay factor?
> > >(the cov function does not allow me to do that)
>
> > > Thank you very much in advance for your attention.
>
> > > Giorgio
>
> > M No. of assets
> > N No. of time instants (N is index of latest asset)
CORRECTION: ... (N is index of the latest TIME)...
> > X0 Original assets return matrix
>
> > size(X0) = [N M]
>
> > W diagonal exponential decay weight matrix
>
> > W0i = a^(N-i) % i = 1:N, a = 0.97
> > Wi = W01/sum(W0i)
>
> > X Exponentially weighted assets return matrix
>
> > X = W*X0
>
> > covX = cov(X);
>
> > Hope this helps.
>
> > Greg
>
> Hello Greg!
>
> Thank you very much for your reply!
>
> I wrote down this code:
>
> for i=1:N
> W0(i) = 0.97^(N-i);
> W(i) = W0(1)/sum(W0(i));
> end
>
> X = W*X0;
>
> covX = cov(X);
>
> Where M=43 and N=74
>
> Anyway what i get is a single covariance number (cov(X) is a 1x1 matrix, instead of 43)
> Where is my mistake?
1. Using my comments without trying to understand them,
e.g., why did you use W0(1) and why did you
normalize with the sum before having all the terms?
2. Assuming my comments were error free code
3. Not using small N,M with semicolons removed so
that you can see the result of each command
4. Not checking the dimensions of each matrix
via whos or size, e.g, what is the size of your X?
5. Using an unnecessary for loop instead of vectorization
(not really a mistake, but if you are going to
use MATLAB, learn how to vectorize!)
close all, clear all, clc
% Debugging: Small N,M and no semicolons
N = 7, M = 4, a = 0.97
rand('state',0) % Old version
X0 = rand(N,M) % [7 4] meaningless placeholder
i = (1:N)' % [7 1]
Wu = a.^(N-i) % [7 1] Unnormalized
Wn = Wu/sum(Wu) % [7 1] Normalized
whos % Shows all dimensions
% UNDERSTANDING: You have to multiply
% each column of X0 with Wn (i.e.,
% Wn.*X0(:,j), j=1:M) and end up
% with size(X) = size(X0) = [N M]
% and size(cov(X)) = [M M]
W = diag(Wn)
X = W*X0
covX = cov(X)
% Simple check:
Xc = X - repmat(mean(X),N,1)
dcovX = abs( covX - Xc'*Xc/(N-1) )
Hope this helps.
Greg
|
|
0
|
|
|
|
Reply
|
Greg
|
12/29/2010 12:33:23 PM
|
|
Greg Heath <heath@alumni.brown.edu> wrote in message <540aa0b1-dd16-498b-bfc6-9333b7808c0f@s4g2000yql.googlegroups.com>...
> On Dec 29, 4:38 am, "Giorgio Solfaroli"
> <giorgio.solfar...@uniqagroup.it> wrote:
> > Greg Heath <he...@alumni.brown.edu> wrote in message <1efad805-f60f-460b-8764-5c3e2f434...@30g2000yql.googlegroups.com>...
> > > On Dec 27, 10:26 am, "Giorgio Solfaroli"
> > > <giorgio.solfar...@uniqagroup.it> wrote:
> > > > Hello!
> >
> > > > I have to generate a Variance Covariance Matrix of
> > > > assets returns using as parameter a decay factor of 0.97.
> > > > Does anyone knows how can i include the decay factor?
> > > >(the cov function does not allow me to do that)
> >
> > > > Thank you very much in advance for your attention.
> >
> > > > Giorgio
> >
> > > M No. of assets
> > > N No. of time instants (N is index of latest asset)
>
> CORRECTION: ... (N is index of the latest TIME)...
>
> > > X0 Original assets return matrix
> >
> > > size(X0) = [N M]
> >
> > > W diagonal exponential decay weight matrix
> >
> > > W0i = a^(N-i) % i = 1:N, a = 0.97
> > > Wi = W01/sum(W0i)
> >
> > > X Exponentially weighted assets return matrix
> >
> > > X = W*X0
> >
> > > covX = cov(X);
> >
> > > Hope this helps.
> >
> > > Greg
> >
> > Hello Greg!
> >
> > Thank you very much for your reply!
> >
> > I wrote down this code:
> >
> > for i=1:N
> > W0(i) = 0.97^(N-i);
> > W(i) = W0(1)/sum(W0(i));
> > end
> >
> > X = W*X0;
> >
> > covX = cov(X);
> >
> > Where M=43 and N=74
> >
> > Anyway what i get is a single covariance number (cov(X) is a 1x1 matrix, instead of 43)
> > Where is my mistake?
>
> 1. Using my comments without trying to understand them,
> e.g., why did you use W0(1) and why did you
> normalize with the sum before having all the terms?
> 2. Assuming my comments were error free code
> 3. Not using small N,M with semicolons removed so
> that you can see the result of each command
> 4. Not checking the dimensions of each matrix
> via whos or size, e.g, what is the size of your X?
> 5. Using an unnecessary for loop instead of vectorization
> (not really a mistake, but if you are going to
> use MATLAB, learn how to vectorize!)
>
>
> close all, clear all, clc
>
> % Debugging: Small N,M and no semicolons
>
> N = 7, M = 4, a = 0.97
>
> rand('state',0) % Old version
> X0 = rand(N,M) % [7 4] meaningless placeholder
>
> i = (1:N)' % [7 1]
> Wu = a.^(N-i) % [7 1] Unnormalized
> Wn = Wu/sum(Wu) % [7 1] Normalized
> whos % Shows all dimensions
>
> % UNDERSTANDING: You have to multiply
> % each column of X0 with Wn (i.e.,
> % Wn.*X0(:,j), j=1:M) and end up
> % with size(X) = size(X0) = [N M]
> % and size(cov(X)) = [M M]
>
> W = diag(Wn)
> X = W*X0
> covX = cov(X)
>
> % Simple check:
>
> Xc = X - repmat(mean(X),N,1)
> dcovX = abs( covX - Xc'*Xc/(N-1) )
>
> Hope this helps.
>
> Greg
Thanks! Your help has been really usefull for me!
Giorgio
|
|
0
|
|
|
|
Reply
|
Giorgio
|
12/29/2010 1:46:04 PM
|
|
|
6 Replies
390 Views
(page loaded in 0.093 seconds)
Similiar Articles: 'out of memory' covariance matrix - comp.soft-sys.matlab ...Hola, necesito calcular la matriz de varianzas y covarianzas de una matriz de 300 por 137455 y el comando cov no me sirve en este caso, ya que matlab ... normal likelihood function &covariance matrix ¶meter ...Hi, I have a question which has made me confused for a long time. Here is the question: I want to estimate the parameters in the normal likeliho... How to output the variance covariance matrix for Glimmix procedure ...Hi Friends: I have a question about how to output the variance-covariance matrix of fixed effect parameter and random effect predictor In Glimmix ... How to build a exponentially weighted moving average covariance ...... How to build a exponentially weighted moving average covariance ... Exponential Moving Average without For Loop - comp.soft-sys.matlab ... Variance Covariance Matrix ... Ridge Regression -- parameters and variance? - comp.soft-sys ...Hi Friends: I have a question about how to output the variance-covariance matrix of fixed effect parameter and random effect predictor In Glimmix ... Portfolio optimization using minimum-variance (fmincon) - comp ...Hi, Could anyone please help me with this portfolio optimization problem: how is it possible to write the function Min. w'*H*w, where H is a covariance matrix of ... calculate varians and covarians matrix - comp.soft-sys.matlab ...Variance Covariance Matrix - comp.soft-sys.matlab Using an unnecessary for loop instead of ... Calculating and ... data are spread around some central value, such as a ... Re: Help with panel data analysis - comp.soft-sys.sas... that a RANDOM intercept statement can be, at times, mathematically equivalent to a REPEATED statement with a specified compound symmetric variance/covariance matrix in ... mixed models with repeated measurements - comp.soft-sys.stat.spss ...> > > Kind regards, > > Ruben > > Ruben, > > Generally, I do not believe an AR residual variance-covariance matrix > is appropriate for data that are collected at ... Pearson Correlation of two distance matrices - comp.soft-sys ...Pearson Correlation of two distance matrices - comp.soft-sys ... PROC CORR then uses the standard Pearson correlation formula on the partial variance-covariance matrix to ... Covariance matrix - Wikipedia, the free encyclopediaIn probability theory and statistics, a covariance matrix (also known as dispersion matrix or variance covariance matrix) is a matrix whose element in the i, j ... Variance-Covariance Matrix - Statistics, Probability, and Survey ...How to use matrix methods to generate a variance-covariance matrix from a matrix of raw data. Includes problems with solutions. Source: Stat Trek free, online matrix ... 7/25/2012 5:51:16 AM
|