フィルターのクリア

how can i extrapolate the last value of a matrix?

8 ビュー (過去 30 日間)
tzaloupas
tzaloupas 2013 年 2 月 14 日
Dear all,
I have this matrix
clear all
A={
'02/2000' [NaN] [NaN]
'03/2000' [NaN] [3]
'04/2000' [NaN] [5]
'05/2000' [4] [4]
'06/2000' [3.9313] [0.9313]
'07/2000' [3.9313] [3.9313]
'08/2000' [NaN]} [45]}
'09/2000' [4.1583] [44.1583]
'10/2000' [3.9389] [334.9389]
'11/2000' [4.3944] [45.3944]
'12/2000' [4] [4.56]
'01/2001' [3.9313] [56.9313]
'02/2001' [3.743] [4.9543]
'03/2001' [NaN] [NaN]}
my goal is to extrapolate the values of the last observations, that is, the observations that corresponds to the
the date '03/2001'
Is there a way to do that in matlab?
Note that I have many such vectors and the last date for each vector is different.
Cheers

採用された回答

Jos (10584)
Jos (10584) 2013 年 2 月 14 日
編集済み: Jos (10584) 2013 年 2 月 14 日
You have to define a model first. As an example, assume you have data points (time, value) like this:
Time = [1 3 6 7 8]
Value = [10 11 15 19 25]
and you want to get the value at an unknown time. You could, for instance, fit a linear model "Value = a x Time +b" through the known data points by which you get the parameters a and b, and in turn retrieve the predicted values at unknown times.
p = polyfit(Time,Values,1)
Value10 = polyval(p,10)
However, there are many, many issues to be aware of! For instance, what is the underlying model? Linear or not? Also, extrapolation is often very tricky ...
  4 件のコメント
tzaloupas
tzaloupas 2013 年 2 月 14 日
thanks Jose . My data are on prices of goods. I tried to extrapolate the last observation and in some cases I obtain negative prices
I do not have a specific model in my mind. Is there anything you can do to help me with the above example?
thanks
José-Luis
José-Luis 2013 年 2 月 14 日
編集済み: José-Luis 2013 年 2 月 14 日
I am sorry, but if I had a reliable model to extrapolate the price of goods I would be a very very very very rich man. What you are asking is not simple, to say the least.

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

その他の回答 (1 件)

Image Analyst
Image Analyst 2013 年 2 月 14 日
編集済み: Image Analyst 2013 年 2 月 14 日
If you want to fit, say, 123 locations between -2 and 42 you could create your x data:
xFitted = linspace(-2, 42, 123);
Now get the fit:
monthNumber = % Extract this from column 1
column2 = % Extract this from column 2.
coefficients = polyfit(monthNumber , column2 , 1); % Or whatever order of polynomial you want.
Then do the fit/extrapolation:
yFitted = polyval(coefficients, xFitted);
yFitted will be the fitted y values between -2 and 42. Since your data went from month 2 to month 15, values from -2 to 2 and from 15 to 42 are extrapolated. Values between 2 and 15 are fitted/interpolated/regressed because they occur within the valid training range of your data.
  3 件のコメント
tzaloupas
tzaloupas 2013 年 2 月 14 日
please? I am struggling to find the answer and I cant
tzaloupas
tzaloupas 2013 年 2 月 14 日
anybody else?

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

カテゴリ

Help Center および File ExchangePrice and Analyze Financial Instruments についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by