我目前在 csv 文件中有一个日期数据集、一个公司标识符和一个感兴趣的值。公司标识符和值都是数字。我的数据目前是平面文件格式,所以我目前有如下行
companyid date value
1111 09/14/1986 1234
1111 10/14/1986 5678
1111 11/14/1986 9012
换句话说,我有平面文件格式的时间序列。我想通过为每个公司构建一个时间序列对象来浓缩这些数据。然后我想生成每个时间点的某些分位数的时间序列图,汇总所有公司。需要指出的其他事项是 companyid/date 对是唯一的,因此数据集中没有重复项,并且数据已经按 companyid 和日期排序。
这是我迄今为止尝试过的:
% col 1 = companyid, col 2 = date, col 3 = value
[rows, cols] = size(data);
distinct_comp = 0;
for ii=1:rows
if data(ii, 1) ~= data(ii-1,1)
distinct_comp = distinct_comp + 1;
end
end
disp distinct_comp
%Create initial time series object and place data(1,3) and data(1,2) inside
for jj = 2:rows
if data(jj,1)==data(jj-1,1)
% Add data (jj,2) and data(jj, 3) to existing time series object
else
% Create new time series object and add data(jj,2) and data(jj,3)
end
end
% disp number of time-series objects to check if same as distinct_comp