Please somebody help me!
Show older comments
Hello everybody,
I face this streange problem
i try to find opportunity cost measure for my portfolio and i run this code:
function [opcost] = expopportcost(Retwv,Retnv,g)
i = 0;
exponential_utility_wv = -exp(-(1+Retwv).*g)./g;
expected_utility_wv = sum(exponential_utility_wv)/length(Retwv);
for theta = -0.5:0.0001:0.5
exponential_utility_nv = -exp(-(1+Retnv+theta).*g)./g;
i = i+1;
objective_function(i) = abs(expected_utility_wv - sum(exponential_utility_nv/length(Retwv)));
end
[val, position] = min(objective_function);
theta = -0.5 + 0.0001*(position-1);
opcost = theta;
end
Its for exponential utility and Retwv = xlsread("file1.xlsx") and Retnv=xlsread("file2.xlsx") ......the returns for two assets and g=2 (risk averse coefficient) i define the g.
when i run the code with monthly retuns = 38 monthly observations everything is fine!
but when i run the code with daily returns = 755 daily observations always the "val = NaN" and the result is -0.5 which is wrong!!!
i change only the returns in excel files ....i tried to change the format of values in excel but i think this is not problem...
Why this happend? i need help immidiately!
thanks in advance!!
4 Comments
Walter Roberson
on 16 Apr 2019
-0.5 exactly or that minus 0.0001?
Panos Raptis
on 16 Apr 2019
Walter Roberson
on 17 Apr 2019
Can you attach the files?
Panos Raptis
on 17 Apr 2019
Accepted Answer
More Answers (0)
Categories
Find more on Logical in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!