0

So I am trying to calculate this formula but the results are strange. The elements are extremely large so I am not sure where I went wrong. I have attached a photo of the formula:enter image description here

and here is my code:

*calculating mu_sum and sigma_sum;
T_hat=180;
mu_sum_first_part={0,0,0,0};
mu_sum_second_part={0,0,0,0};
mu_sum={0,0,0,0};

*calculating mu_sum;
do i = 0 to T_hat;
    term=(T_hat - i)*(B0**i)*a;
    mu_sum_first_part = mu_sum_first_part + term;
end;
do i=1 to T_hat; 
    term =B0**i;
    mu_sum_second_part = mu_sum_second_part + term;
end;
mu_sum = mu_sum_first_part + mu_sum_second_part*zt;
print mu_sum;

*calculating sigma_sum;
term=I(4);
sigma_sum=sigma;
do j=1 to T_hat;
    term = term + B0**j;
    sigma_sum = sigma_sum + (term*sigma*(term`));
end;
print sigma_sum;

I know this is long but please help!!

5
  • What is this calculating, I would like to look it up? Is Bo a scalar, vector, or matrix? I would have thought a vector, but I+Bo doesn't make sense in that way. Commented Jul 12, 2017 at 14:42
  • @DomPazz I am doing a asset allocation task. this is from a paper by Barberis (2000 JF) "Investing for the long run when returns are predictable". Bo is a 4x4 matrix with the first column being zeros. alpha is a 4x1 matrix and sigma is a 4x4 matrix. Commented Jul 13, 2017 at 1:37
  • I haven't pulled the paper, is the power operator on the matrix a matrix power or element-wise power? IE B^2 = B`*B or B#B where # is an element-wise multiplication Commented Jul 13, 2017 at 14:17
  • The "double star operator" is repeated matrix multiplication. Commented Jul 13, 2017 at 15:49
  • @DomPazz the power operator is matrix power, not element-wise power Commented Jul 15, 2017 at 3:46

2 Answers 2

0

First thing that jumps out at me is your loop first term in mu has 1 too many:

do i = 0 to T_hat;
    term=(T_hat - i)*(B0**i)*a;
    mu_sum_first_part = mu_sum_first_part + term;
end;

Should be:

do i = 0 to T_hat-1;
    term=(T_hat - i)*(B0**i)*a;
    mu_sum_first_part = mu_sum_first_part + term;
end;
Sign up to request clarification or add additional context in comments.

1 Comment

both should be the same as (T-hat - i) = 0 when i = T_hat so the last term is 0.
0

There is nothing mathematically wrong with your program. When you are raising a matrix to the 180th power, you should not be surprised to see very large or very small values. For example, if you let B0 = { 0 1 0 0, 0 0 1 0, 0 0 0 1, 0 1 1 1 }; then elements of B0**T are O( 1E47 ). If you divide B0 by 2 and raise the result to the 180th power, then the elements are O( 1E-8 ).

Presumably these formulas are intended for matrices B0 that have a special structure, such as ||B0**n|| --> 0 as n --> infinity. Otherwise the power series won't converge. I suggest you double-check that the B0 you are using satisfies the assumptions of the reference.

You didn't ask about efficiency, but you would be wise to compute the truncated power series by using Horner's method in SAS/IML, rather than explicitly forming powers of B0.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.