An IntRoduction to grey methods by using R Tan Xi Department of Statistics, NUFE Nov 6, 2009 2009-2-5
Contents: A brief introduction to Grey Methods An analysis of Degree of Grey Incidence Grey GM(, ) Model ()Construction (2)Test the accuracy of the model Some Envisions 2009-2-5 2
A brief introduction to Grey Methods Who? Professor Deng! A Chinese! When? Long ago About 970s! What? White, Grey, Black? Application? Many realms! Economics, Physics, Social Science, and the list will go on! 2009-2-5 3
An easy example Step by Step Suppose that the original sequence is Y { 0 = 8, 8.8,6,8, 24, 32 } comparative sequences are :. Y { = 0, 2.2, 9.28, 20.25, 23.4, 30.69 } Y { 2 = 6, 6.35, 6.57, 6.98, 8.35, 8.75} Which of the comparative sequences is much closer to the original series? Y 0 2009-2-5 4
Before computing the exact values, you can get the intuition by looking at the graph. (Ads: Where is Xie? ). 35 30 25 20 5 0 5 GET THE INTUITION 0 2 3 4 5 6 Y0 Y Y2 2009-2-5 5
Step: Initialize all sequences X X X 0 2 = {,.,2,2.25,3,4} = {,.22,.928, 2.205, 2.34, 3.069} = {,.0583,.0950,.633,.397,.4583} Step2 : Compute the absolute subtraction sequences Δ ( k) = Y ( k) Y( k) 0i 0 i 2009-2-5 6
Step3: Compute the two-step minimum and maximum of the absolute subtraction sequences Δ = min min Y ( k) Y( k) = 2.547 min 0 i k i Δ = max max Y ( k) Y( k) = 0 max 0 i k i 2009-2-5 7
Step4: Compute coefficients of Grey incidence Formula: γ ( Y ( k), Y( k)) 0 i Δ + ρ Δ min max = Δ oi ( k) + ρ Δ max of which the distinguishing coefficient is 0.5. ρ 2009-2-5 8
Step5: Compute the degree of Grey incidence 0 n γ( Y, Y) = γ( Y ( k), Yi( k)) 0 i 0 n k = γ ( Y, Y) = 0.825 Y0 Y2 γ (, ) = 0.6444 And so our intuition is right! The computed results show that Y 0 is much more closer to Y than to Y 2, which is in coincidence with our intuition! 2009-2-5 9
Recap: Initialize all sequences. Compute the absolute subtraction sequences Δ ( k) = Y ( k) Y( k) 0i 0 Compute the two-step minimum and maximum of the absolute subtraction sequences Δ = minmin Y ( k) Y( k) Δ max = maxmax Y0 ( k) Yi ( k) min 0 i k Compute coefficients of Grey incidence i Δ + ρ Δ γ ( Y ( k), Y( k)) = Δ + Δ min max 0 i oi ( k) ρ max 2009-2-5 0 i i k
Recap: Bingo!! Compute the degree of Grey incidence: n γ( Y, Y) = γ( Y ( k), Yi( k)) 0 i 0 n k = 2009-2-5
All steps in one function Are you bored or puzzled with these steps?? Alternatives: The first: R functions! I ve involved all preceding steps in one function: 灰色关联分析函数.R I ll show you how to use it! The second: Click-Mouse Statistical Packages It s your choice! It s all up to you! For R-Users?? 2009-2-5 2
GM(, )Model GM(, ) type of Grey model is the most widely used in the literature, pronounced as Grey Model First Order One Variable. This model is a time series forecasting model. The differential equations of the GM(, ) model have time-varying coefficients. 2009-2-5 3
How to construct the GM(,) Model? Consider a time sequence X (0), which has n observations, X (0) = { X (0) (), X (0) (2),, X (0) ( n)} When this sequence is subjected to the Accumulating Generation Operation (AGO), the following sequence X () is obtained where () X = X () X () X () n { (), (2),, ( )} k () X k = X (0) i ( ) ( ) i= 2009-2-5 4
How to construct the GM(,) Model? The grey difference equation of GM(,) is defined as follows: dx dt () () + = μ ax The least square estimate sequence of the grey difference equation of GM(,) is defined as follows: a μ ˆ α = = ( ) T T BB BY n 2009-2-5 5
How to construct the GM(,) Model? Solve the grey difference equation of GM(,), the predicted GM(,) Model can be obtained: μ X k X e a ˆ () (0) ak ( + ) = () + To obtain the predicted value of the primitive data at time ( k+ H), the IAGO is used to establish the following grey model: (0) (0) b a( k+ H ) a X p ( k+ H) = [ X () ] e ( e ) a μ a 2009-2-5 6
How to test the accuracy of the GM(,) Model? Residual Tests () i X () i Xˆ () i i,2,, n (0) (0) (0) Δ = = (0) Δ () i Φ ( i) = 00% i =, 2,, n (0) X () i 2009-2-5 7
How to test the accuracy of the GM(,) Model? The Test of the degree of Grey incidence γ = n n ˆ (0) (0) ˆ (0) (0) ( X, X ) γ( X ( i), X ( i)) i= According to experience, the GM(,) Model is qualified if ˆ (0) (0) γ ( X, X ) > 0.6 ρ = 0.5, when. 2009-2-5 8
How to test the accuracy of the GM(,) Model? C and P Criteria S = [ X ( i) X ] (0) (0) 2 n S 2 = [ Δ ( i) Δ ] (0) (0) 2 n S S = 2 C= 0.0887908 P = p Δ i Δ < S (0) (0) { ( ) 0.6745 } 2009-2-5 9
How to test the accuracy of the GM(,) Model? C and P Criteria 2009-2-5 20
An easy example executed by R Program Suppose the original sequence is: Construct the GM(,) Model and predict the values of 7~th Periods. R program : GM(,) 模型建立 检验和预测.R 2009-2-5 2
Step: Construct the AGO sequence: Step2: Construct the matrix B and the vector Y n () () [ () (2)] X + X 2 () () [ (2) (3)] X + X -42.45 2-74.60 () () B = [ X (3) + X (4)] = -08.05 2-43.00 () () [ X (4) + X (5)] -79.65 2 () () [ (5) (6)] X + X 2 (0) X (2) 3.5 (0) X (3) 32.8 = = (0) X (4) 34. (0) X (5) 35.8 (0) X (6) 37.5 2009-2-5 22 Y n
T Step3: Compute B B, ( T ) and BY. B B T n T 7765.09-547.75 B B = -547.75 5.00 T 0.000085 0.00936 ( BB) = 0.00936.22059 T BY n -0.043804 = 29.54220 Step4: Solve the vector of parameters by using the least square estimate. ˆ α = -0.043804 29.54220 a = -0.043804 μ = 29.54220 2009-2-5 23
Step5: Construct the GM(,) prediction Model dx dt dx dt () () () + =μ ax () 0.043804 29.54220 X = ˆ () (0) μ ak μ X ( k+ ) = X () e + a a (0) μ X () = 26.7, = -674.3883 a So the GM(,) prediction model is: ˆ () 0.043804k ( ) 70.0883-674.3883 X k+ = e 2009-2-5 24
Test the accuracy of the GM(,) Model Residual Test 2009-2-5 25
Residual Test 2009-2-5 26
The Test of the degree of Grey incidence γ X X = γ X i X i = n n ˆ (0) (0) ˆ (0) (0) (, ) ( ( ), ( )) 0.709 i= 2009-2-5 27
C and P Criteria S (0) (0) 2 [ X ( i) X ] = = n 3.775006 S 2 2 C= 0.0887908 (0) (0) 2 [ Δ ( i) Δ ] = = 0.0726863 n S S = 0 S = 2.54624 ei =Δ () i Δ (0) (0) = {0.06202667, 0.04460833, 0.062567, 0.057533, 0.05980467, 0.03259733} P = p Δ i Δ < S = (0) (0) { ( ) 0.6745 } 2009-2-5 28
GM(,) Model can be used to predict. 2009-2-5 29
R package? Some Envisions Any existing R package? Or can we write the first one? Collaboration More R programs and R Functions On grey methods? 2009-2-5 30
Reference: [] 邓聚龙, 灰理论基础 [M]. 上海 : 华中科技大学出版社, 2003. [2] 刘思峰, 谢思明, 灰色系统理论及其应用 [M]. 北京 : 科学出版社,2008. [3] 王庚, 现代数学建模方法 [M]. 北京 : 科学出版社,2008. [4] 徐国祥, 统计预测与决策 [M]. 上海 : 上海财经大学出版社,2005. [5] Erdal Kayacan, Baris Ulutas, Okyay Kaynak, Grey system theory-based models in time series prediction[j]. Expert Systems with Applications, 200:784 789. 2009-2-5 3
Acknowledgements I am grateful to all members of COS, without your excellent work, no R conferences could be held currently in China. I am also grateful to Professor Wang Gen for his help and suggestions on this topic. And thank everyone here for your patient listening and welcome any suggestions. 2009-2-5 32
Thank you! Contact Information: Tel: 3770636679 Email: xitannj@gmail.com 2009-2-5 33