Matlab日期两组数据不匹配。帮帮我! [英] Matlab Dates mismatch between two sets of data. Help!

查看:560
本文介绍了Matlab日期两组数据不匹配。帮帮我!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Matlab日期在两组数据之间不匹配。帮助!



请原谅问题的简单性,但我的第一天;



我正在与两个一系列时间序列:1)1977年以来S& P 500的价格(每日收盘价和日期)和2)1977年以来的债券收益率(每日收盘价和日期)。



问题是,几个月后,日期不再一致(也许债券市场有一天关闭,股市开盘等)所以我有两个不再正确对齐的数据集。在我甚至开始询问如何取代差距之前(我将使用平均值,当我到达这个桥梁),我需要知道如何让matlab调整两个证券的日期,以至于我至少知道差距在哪里对于每个安全性,即在哪个日期是一个安全性缺失价格。我正在考虑创建一个自己的(或使用一个证券的日期)日历列,然后使用它作为基准日期列来排列最终输出,并将价格与新数据匹配...也许这是错误的思考方式,但任何帮助将非常感激:)

解决方案

如果您只是使用从系列中的任何一个的日期,因为他们每个可能有在另一个缺少的日期。我会做的是开始一个干净的3列矩阵,包含日期范围内的所有工作日。 Mathworks博客上的这篇文章可以提供一些洞察力关于怎么做然后使用两个数据系列的值填写另外两列。这样,您将确保所有的值都在矩阵中,如果您决定添加更多数据,将使您的生活更简单。



至于填写缺少的日期,您只需使用: 1-D内插功能


Matlab Dates mismatch between two sets of data. Help!

Please forgive the simplicity of the question but its my first day;

I am working with two sets of time series: 1) Price of S&P 500 since 1977 (daily close & date) and 2) Bond Yield since 1977 (daily close & date).

The problem is that after a few months the the dates are no longer aligned with each other (maybe the bond market was closed one day and the stock market was opened etc) so I have two data sets that are no longer correctly aligned. Before I even start asking about how to replace the gaps (I will use averages when I get to that bridge), I need to know how to get matlab to align the dates for both securities so that I at least know where the gaps are are for each security i.e at which date is one security missing the price. I was thinking of creating a my own (or using the dates from one of the securities) calendar column and then use that as the base date column to stardedise the final output and match the prices to the new data... maybe this is the wrong way of thinking about it but any help would be much appreciated :)

解决方案

You might have a problem if you just use the dates from either one of the series because each of them might have dates that are missing in the other. What I would do is start with a clean 3-column matrix that contains all the weekdays in the date range. This post on the Mathworks blog can offer some insight on how to do it. Then fill in the two other columns with the values from your two data series. This way you will be sure all your values are in the matrix and will make your life simpler if you decide to add more data.

As for filling in the missing dates, you can just use : the 1-D interpolate function

这篇关于Matlab日期两组数据不匹配。帮帮我!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆