how to match daily returns ?

1 回表示 (過去 30 日間)
jean claude
jean claude 2017 年 2 月 6 日
回答済み: Rik 2017 年 2 月 9 日
hello everyone, i have the dependent variable with daily returns y (1 column ), in the other hand daily returns for the independant variable x (1 column of daily returns). How to pick daily returns from x corresponding to y ( so must have same date) because daily returns could be missing some days in x and assign nan for the missing days in such way to make linear regression!
  2 件のコメント
John D'Errico
John D'Errico 2017 年 2 月 6 日
Huh? Perhaps you could give an example of what you want to do?
jean claude
jean claude 2017 年 2 月 9 日
編集済み: jean claude 2017 年 2 月 9 日
yep John, example y=[01012000 02012000 03012000, 100 200 300]; x=[02012000 05012000 07012000, 3 5 6]; so to regress y on x i would have x=[nan 3 nan] because in 2 january 2000 it matchs, then i can regress y=[100 200 300] on x=[nan 3 nan]. my problem is to construct variable x (i think unique could help)

サインインしてコメントする。

回答 (1 件)

Rik
Rik 2017 年 2 月 9 日
So you have two datasets that are sampled over time that you need to resample over a common/matched timeframe? Am I understanding you correctly?
I had something that sounded similar, but my data had different millisecond timestamps. I used interp1 to interpolate to a timestampvector, which would look something like this:
t=unique([y(1,:) x(1,:)]);
y2=interp1(y(1,:),y(2,:),t);
x2=interp1(x(1,:),x(2,:),t);
plot(x2,y2)
And then you can do all the fancy fitting you wish. You need to convert those dates into something that increments normally. I bet 2 second of google will result in a FEX submission that does that for you.

カテゴリ

Help Center および File ExchangeDescriptive Statistics についてさらに検索

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by