Thursday 28 December 2017

تتحرك من المتوسط ، منظمة العمل ضد الجوع


استخدام R لتحليل السلاسل الزمنية تحليل السلاسل الزمنية يشرح لك هذا الكتيب كيفية استخدام البرنامج الإحصائي R لتنفيذ بعض التحليلات البسيطة الشائعة في تحليل بيانات السلاسل الزمنية. يفترض هذا الكتيب أن القارئ لديه بعض المعرفة الأساسية لتحليل السلاسل الزمنية، والتركيز الرئيسي للكتيب ليس لشرح تحليل السلاسل الزمنية، وإنما شرح كيفية إجراء هذه التحليلات باستخدام R. إذا كنت جديدا على سلسلة زمنية تحليل، وتريد معرفة المزيد عن أي من المفاهيم المقدمة هنا، أود أن أوصي كتاب جامعة مفتوحة 8220Time Series8221 (رمز المنتج M24902)، وهي متاحة من متجر جامعة المفتوحة. في هذا الكتيب، سأستخدم مجموعات بيانات السلاسل الزمنية التي تم توفيرها من قبل روب هيندمان في مكتبة بيانات سلسلة الوقت الخاصة به في روبجيندمانتسدل. إذا کنت تحب ھذا الکتیب، قد ترغب أیضا في الاطلاع علی کتیبي حول استخدام R للإحصاءات الطبیة الحیویة، a-little-book-of-r-for-biomedical-statistics. readthedocs. org. وكتيب بلدي حول استخدام R للتحليل متعدد المتغيرات، القليل من الكتاب، قراءة البيانات سلسلة الوقت أول شيء سوف تريد القيام به لتحليل البيانات سلسلة الوقت الخاص بك وسوف يكون لقراءتها في R، ومؤامرة سلسلة زمنية. يمكنك قراءة البيانات إلى R باستخدام وظيفة المسح الضوئي ()، والتي تفترض أن بياناتك لنقاط زمنية متعاقبة موجودة في ملف نص بسيط يحتوي على عمود واحد. على سبيل المثال، يحتوي ملف robjhyndmantsdldatamisckings. dat على بيانات عن عمر وفاة الملوك المتعاقبين لإنجلترا، بدءا من وليام الفاتح (المصدر الأصلي: هيبل و مكليود، 1994). تبدو مجموعة البيانات كما يلي: تم عرض الأسطر القليلة الأولى فقط من الملف. الأسطر الثلاثة الأولى تحتوي على بعض التعليقات على البيانات، ونحن نريد أن نتجاهل هذا عندما نقرأ البيانات إلى R. يمكننا استخدام هذا باستخدام المعلمة 8220skip8221 للدالة المسح الضوئي ()، الذي يحدد عدد الخطوط في الجزء العلوي من ملف لتجاهل. لقراءة الملف في R، تجاهل الخطوط الثلاثة الأولى، ونحن نكتب: في هذه الحالة سن الموت من 42 ملوك المتعاقبة انكلترا قد قرأ في المتغير 8216kings8217. بمجرد قراءة بيانات سلسلة الوقت إلى R، الخطوة التالية هي تخزين البيانات في كائن سلسلة زمنية في R، بحيث يمكنك استخدام R8217s العديد من الوظائف لتحليل بيانات سلسلة الوقت. لتخزين البيانات في كائن سلسلة زمنية، نستخدم الدالة تيسي () في R. على سبيل المثال، لتخزين البيانات في المتغير 8216kings8217 ككائن سلسلة زمنية في R، نكتب: أحيانا مجموعة بيانات سلسلة الوقت التي قد تكون قد جمعت على فترات منتظمة كانت أقل من سنة، على سبيل المثال، شهرية أو ربع سنوية. في هذه الحالة، يمكنك تحديد عدد المرات التي تم جمع البيانات فيها سنويا باستخدام المعلمة 8216frequency8217 في الدالة تيسي (). للحصول على بيانات سلسلة زمنية شهرية، يمكنك تعيين التردد 12، بينما لبيانات سلسلة زمنية ربع سنوية، يمكنك تعيين التردد 4. يمكنك أيضا تحديد السنة الأولى التي تم جمع البيانات، والفاصل الزمني الأول في ذلك العام باستخدام المعلمة 8216start8217 في الدالة تيسي (). على سبيل المثال، إذا كانت نقطة البيانات الأولى تتوافق مع الربع الثاني من عام 1986، يمكنك تعيين ستارتك (1986،2). ومن الأمثلة على ذلك مجموعة بيانات عن عدد المواليد شهريا في مدينة نيويورك، من كانون الثاني / يناير 1946 إلى كانون الأول / ديسمبر 1959 (التي جمعتها نيوتن أصلا). هذه البيانات متوفرة في ملف robjhyndmantsdldatadatanybirths. dat يمكننا قراءة البيانات في R، وتخزينها ككائن سلسلة زمنية، عن طريق كتابة: وبالمثل، يحتوي ملف robjhyndmantsdldatadatafancy. dat المبيعات الشهرية لمتجر للهدايا التذكارية في بلدة منتجع الشاطئ في كوينزلاند، أوستراليا، فور جانوري 1987-ديسمبر 1993 (أورجنال داتا فروم ويلوريت أند هيندمان، 1998). يمكننا قراءة البيانات إلى R عن طريق كتابة: التآمر سلسلة الوقت مرة واحدة كنت قد قرأت سلسلة زمنية في R، فإن الخطوة التالية هي عادة لجعل مؤامرة من البيانات سلسلة الوقت، والتي يمكنك القيام به مع وظيفة plot. ts () في R. على سبيل المثال، لرسم سلسلة زمنية من سن الموت من 42 ملوك المتعاقبة من انكلترا، ونحن نكتب: يمكننا أن نرى من مؤامرة الوقت أن هذه السلسلة الزمنية يمكن وصفها ربما باستخدام نموذج المضافة، منذ التقلبات العشوائية في البيانات هي ثابتة تقريبا في الحجم مع مرور الوقت. وبالمثل، لرسم سلسلة زمنية من عدد المواليد شهريا في مدينة نيويورك، ونحن نكتب: يمكننا أن نرى من هذه السلسلة الزمنية أنه يبدو أن هناك تباين موسمي في عدد المواليد شهريا: هناك ذروة كل صيف ، وحوض صغير كل شتاء. ومرة أخرى، يبدو أن هذه السلسلة الزمنية يمكن وصفها على الأرجح باستخدام نموذج مضاف، حيث أن التقلبات الموسمية ثابتة تقريبا في الحجم بمرور الوقت ولا يبدو أنها تعتمد على مستوى السلاسل الزمنية، ويبدو أن التقلبات العشوائية أيضا ثابت تقريبا في الحجم مع مرور الوقت. وبالمثل، لرسم سلسلة زمنية من المبيعات الشهرية لمتجر الهدايا التذكارية في بلدة منتجع الشاطئ في كوينزلاند، أستراليا، ونحن نكتب: في هذه الحالة، يبدو أن نموذج المضافة ليست مناسبة لوصف هذه السلسلة الزمنية، لأن حجم من التقلبات الموسمية والتقلبات العشوائية ويبدو أن زيادة مع مستوى السلاسل الزمنية. وبالتالي، قد نحتاج إلى تحويل السلاسل الزمنية من أجل الحصول على سلسلة زمنية محولة يمكن وصفها باستخدام نموذج مضاف. على سبيل المثال، يمكننا تحويل السلاسل الزمنية من خلال حساب السجل الطبيعي للبيانات الأصلية: هنا يمكننا أن نرى أن حجم التقلبات الموسمية والتقلبات العشوائية في السلاسل الزمنية المحولة من السجل تبدو ثابتة تقريبا مع مرور الوقت، وتفعل لا تعتمد على مستوى السلاسل الزمنية. وبالتالي، يمكن وصف السلسلة الزمنية المحولة السجل باستخدام نموذج مضاف. تحلیل السلاسل الزمنیة یعني تحلیل السلاسل الزمنیة فصلھا إلی مکوناتھا التأسیسیة، وھي عادة مکونات اتجاهیة ومکون غیر منتظم، وإذا کانت سلسلة زمنیة موسمیة، وھي عنصر موسمي. تحلیل البیانات غیر الموسمية تتألف السلاسل الزمنیة غیر الموسمیة من عنصر الاتجاه ومکون غیر منتظم. تحليل السلسلة الزمنية ينطوي على محاولة لفصل السلاسل الزمنية في هذه المكونات، وهذا هو، تقدير عنصر الاتجاه والمكون غير النظامي. ولتقدير عنصر الاتجاه لسلسلة زمنية غير موسمية يمكن وصفها باستخدام نموذج مضاف، من الشائع استخدام طريقة التجانس، مثل حساب المتوسط ​​المتحرك البسيط للمسلسلات الزمنية. يمكن استخدام الدالة سما () في حزمة 8220TTR8221 R لتسلسل بيانات السلاسل الزمنية باستخدام متوسط ​​متحرك بسيط. لاستخدام هذه الدالة، نحتاج أولا إلى تثبيت حزمة 8220TTR8221 R (للحصول على إرشادات حول كيفية تثبيت حزمة R، راجع كيفية تثبيت حزمة R). بمجرد تثبيت حزمة 8220TTR8221 R يمكنك تحميل حزمة 8220TTR8221 R عن طريق كتابة: يمكنك ثم استخدام الدالة 8220SMA () 8221 لتسلسل البيانات سلسلة الوقت. لاستخدام الدالة سما ()، تحتاج إلى تحديد الترتيب (سبان) للمتوسط ​​المتحرك البسيط، باستخدام المعلمة 8220n8221. على سبيل المثال، لحساب متوسط ​​متحرك بسيط من النظام 5، نقوم بتعيين n5 في الدالة سما (). على سبيل المثال، كما نوقش أعلاه، فإن السلاسل الزمنية لسن الوفاة من 42 ملوك متتالي انكلترا يبدو غير موسمي، ويمكن وصفها على الأرجح باستخدام نموذج اضافي، حيث ان التقلبات العشوائية في البيانات هي ثابتة تقريبا في الحجم فوق الوقت: وبالتالي، يمكننا محاولة لتقدير عنصر الاتجاه من هذه السلسلة الزمنية من خلال تمهيد باستخدام المتوسط ​​المتحرك بسيط. لتسلسل السلاسل الزمنية باستخدام متوسط ​​متحرك بسيط من النظام 3، ومؤامرة البيانات سلسلة الوقت ممهدة، ونحن نكتب: لا يزال يبدو أن هناك الكثير جدا من التقلبات العشوائية في السلاسل الزمنية ممهدة باستخدام المتوسط ​​المتحرك بسيط من النظام 3. وبالتالي، لتقدير عنصر الاتجاه بشكل أكثر دقة، قد نرغب في محاولة تمهيد البيانات بمتوسط ​​متحرك بسيط من أجل أعلى. هذا يأخذ قليلا من التجربة والخطأ، للعثور على كمية مناسبة من التمهيد. على سبيل المثال، يمكننا أن نحاول استخدام متوسط ​​متحرك بسيط من أجل 8: البيانات ممهدة مع متوسط ​​متحرك بسيط من النظام 8 يعطي صورة أوضح عن عنصر الاتجاه، ويمكننا أن نرى أن سن وفاة الملوك الإنجليزية يبدو أن قد انخفض من حوالي 55 سنة إلى حوالي 38 سنة في عهد الملوك الأول 20، ثم ارتفع بعد ذلك إلى حوالي 73 سنة بحلول نهاية عهد الملك ال 40 في السلسلة الزمنية. تحلیل البیانات الموسمية تتألف السلاسل الزمنیة الموسمیة من عنصر الاتجاه، والعنصر الموسمي والمکون غیر النظامي. تحليل السلسلة الزمنية يعني فصل السلسلة الزمنية في هذه المكونات الثلاثة: أي، تقدير هذه المكونات الثلاثة. لتقدير مكون الاتجاه والمكون الموسمية لسلسلة زمنية موسمية يمكن وصفها باستخدام نموذج مضاف، يمكننا استخدام الدالة 8220decompose () 8221 في R. تقوم هذه الدالة بتقدير مكونات الاتجاه، الموسمية، وغير المنتظمة لسلسلة زمنية يمكن وصفها باستخدام نموذج المضافة. الدالة 8220decompose () 8221 تقوم بإرجاع كائن قائمة كنتيجة له ​​حيث يتم تخزين تقديرات المكون الموسمية وعنصر الاتجاه والمكون غير النظامي في العناصر المسماة من كائنات القائمة تلك التي تسمى 8220seasonal8221 و 8220trend8221 و 8220random8221 على التوالي. على سبيل المثال، كما نوقش أعلاه، فإن السلاسل الزمنية لعدد المواليد شهريا في مدينة نيويورك موسمية مع ذروة كل صيف وقاع كل شتاء، ويمكن وصفها على الأرجح باستخدام نموذج مضافة منذ التقلبات الموسمية والعشوائية ويبدو أن تكون ثابتة تقريبا في الحجم مع مرور الوقت: لتقدير الاتجاه، المكونات الموسمية وغير النظامية من هذه السلسلة الزمنية، ونحن نكتب: يتم تخزين القيم المقدرة للمكونات الموسمية، والاتجاه وغير النظامية الآن في متغيرات بيرثستيمزيريزكومبوننتسونسونال، بيرثستيمزيريزكومبوننتسترند و بيرثستيمزيريزكومبونينتساندوماند. على سبيل المثال، يمكننا طباعة القيم المقدرة للمكون الموسمي عن طريق كتابة: يتم إعطاء العوامل الموسمية المقدرة للأشهر من كانون الثاني (يناير) إلى كانون الأول (ديسمبر)، وهي نفسها لكل سنة. وأكبر عامل موسمية هو يوليو (حوالي 1.46)، والأدنى هو لشهر فبراير (حوالي -2.08)، مما يشير إلى أن هناك على ما يبدو ذروة في المواليد في يوليو وحوض في الولادات في فبراير من كل عام. يمكننا رسم الاتجاه المقدر والمكونات الموسمية وغير المنتظمة للسلاسل الزمنية باستخدام الدالة 8220plot () 8221، على سبيل المثال: تظهر المؤامرة أعلاه السلسلة الزمنية الأصلية (أعلى) ومكون الاتجاه المقدر (الثاني من الأعلى) والمكون الموسمي المقدر (الثالث من أعلى)، والمكون غير المنتظم المقدر (أسفل). ونحن نرى أن مكون الاتجاه المقدر يظهر انخفاضا طفيفا من حوالي 24 في عام 1947 إلى حوالي 22 في عام 1948، تليها زيادة مطردة من ثم إلى حوالي 27 في عام 1959. ضبط موسميا إذا كان لديك سلسلة زمنية الموسمية التي يمكن وصفها باستخدام وهو نموذج إضافي، يمكنك ضبط موسميا من خلال تقدير العنصر الموسمية، وطرح المكون الموسمي المقدر من السلسلة الزمنية الأصلية. يمكننا القيام بذلك باستخدام تقدير العنصر الموسمية محسوبة الدالة 8220decompose () 8221. على سبيل المثال، لضبط موسميا من عدد المواليد شهريا في مدينة نيويورك، يمكننا تقدير العنصر الموسمية باستخدام 8220decompose () 8221، ومن ثم طرح المكون الموسمية من سلسلة الوقت الأصلي: يمكننا بعد ذلك رسم سلسلة زمنية معدلة موسميا باستخدام الدالة 8220plot () 8221، وذلك بكتابة: يمكنك أن ترى أن الاختلاف الموسمي قد تمت إزالته من السلسلة الزمنية المعدلة موسميا. سلسلة الوقت المعدلة موسميا الآن يحتوي فقط على عنصر الاتجاه والمكون غير النظامية. ويمكن استخدام التنبؤات باستخدام التمهيد الأسي التمهيد الأسي لجعل التنبؤات قصيرة الأجل للبيانات سلسلة زمنية. تمهيد الأسي بسيط إذا كان لديك سلسلة زمنية يمكن وصفها باستخدام نموذج المضافة مع مستوى ثابت وليس الموسمية، يمكنك استخدام التمهيد الأسي بسيط لجعل التوقعات على المدى القصير. توفر طريقة التجانس الأسي البسيط طريقة لتقدير المستوى عند النقطة الزمنية الحالية. يتم التحكم بالتلميع بواسطة ألفا المعلمة لتقدير المستوى عند نقطة الزمن الحالية. قيمة ألفا تكمن بين 0 و 1. القيم ألفا التي هي قريبة من 0 يعني أنه يتم وضع القليل من الوزن على الملاحظات الأخيرة عند وضع توقعات القيم المستقبلية. على سبيل المثال، يحتوي ملف robjhyndmantsdldatahurstprecip1.dat على مجموع الأمطار السنوية في البوصة إلى لندن، من 1813-1912 (البيانات الأصلية من هيبل وماكلويد، 1994). يمكننا قراءة البيانات إلى R ورسمها عن طريق كتابة: يمكنك أن ترى من المؤامرة أن هناك مستوى ثابت تقريبا (متوسط ​​يبقى ثابت في حوالي 25 بوصة). ويبدو أن التقلبات العشوائية في السلاسل الزمنية ثابتة تقريبا في الحجم مع مرور الوقت، ولذلك فمن المناسب وصف البيانات باستخدام نموذج مضاف. وهكذا، يمكننا أن نجعل التنبؤات باستخدام التمهيد الأسي بسيط. لجعل التنبؤات باستخدام التمهيد الأسي بسيط في R، يمكننا أن تناسب نموذج التنموية الأسي بسيط باستخدام الدالة 8220HoltWinters () 8221 في R. لاستخدام هولتوينترس () لتمهيد الأسي بسيط، نحن بحاجة إلى تعيين المعلمات بيتافالس و غامافالس في دالة هولتوينترز () تستخدم معلمات بيتا و غاما من أجل التمدد الأسي هولت 8217s، أو التمدد الأسي هولت-وينتر، كما هو موضح أدناه). ترجع الدالة هولتوينترس () متغير قائمة يحتوي على العديد من العناصر المسماة. على سبيل المثال، لاستخدام تمهيد الأسي بسيط لجعل التنبؤات لسلسلة زمنية من هطول الأمطار السنوي في لندن، ونحن نكتب: إخراج هولتوينترس () يخبرنا أن القيمة المقدرة للمعلمة ألفا حوالي 0.024. وهذا قريب جدا من الصفر، يخبرنا أن التنبؤات تستند إلى ملاحظات حديثة وأقل حداثة (على الرغم من أنه قد تم وضع وزن أكبر نسبيا على الملاحظات الأخيرة). افتراضيا، هولتوينترس () يجعل مجرد توقعات لنفس الفترة الزمنية التي تغطيها لدينا سلسلة زمنية الأصلي. في هذه الحالة، شملت سلسلة زمنية لدينا الأصلية هطول الأمطار في لندن من 1813-1912، وبالتالي فإن التوقعات هي أيضا 1813-1912. في المثال أعلاه، قمنا بتخزين إخراج الدالة هولتوينترس () في متغير القائمة 8220rainseriesforecasts8221. يتم تخزين التنبؤات التي قام بها هولتوينترز () في عنصر اسمه من هذا المتغير قائمة تسمى 8220fitted8221، حتى نتمكن من الحصول على قيمهم عن طريق كتابة: يمكننا رسم سلسلة زمنية الأصلي ضد التوقعات عن طريق كتابة: المؤامرة يظهر سلسلة الوقت الأصلي في الأسود، والتنبؤات كخط أحمر. السلاسل الزمنية للتنبؤات أكثر سلاسة من السلاسل الزمنية للبيانات الأصلية هنا. وكمقياس لدقة التنبؤات، يمكننا حساب مجموع الأخطاء المربعة لأخطاء التنبؤ داخل العينة، أي أخطاء التنبؤ للفترة الزمنية التي تغطيها السلاسل الزمنية الأصلية. يتم تخزين مجموع-مربع-الأخطاء في عنصر اسمه من المتغير قائمة 8220rainseriesforecasts8221 يسمى 8220SSE8221، حتى نتمكن من الحصول على قيمته عن طريق كتابة: وهذا هو، هنا مجموع من مربع-الأخطاء هو 1828.855. ومن الشائع في التمهيد الأسي بسيط لاستخدام القيمة الأولى في السلاسل الزمنية كقيمة أولية للمستوى. على سبيل المثال، في السلسلة الزمنية لسقوط الأمطار في لندن، القيمة الأولى هي 23.56 (بوصة) للمطر في 1813. يمكنك تحديد القيمة الأولية للمستوى في الدالة هولتوينترس () باستخدام المعلمة 8220l. start8221. على سبيل المثال، لجعل التوقعات مع القيمة الأولية للمستوى المحدد إلى 23.56، نكتب: كما هو موضح أعلاه، افتراضيا هولتوينترس () يجعل فقط التوقعات للفترة الزمنية التي تغطيها البيانات الأصلية، وهو 1813-1912 لهطول الأمطار السلاسل الزمنية. يمكننا أن نجعل التنبؤات لمزيد من النقاط الزمنية باستخدام 8220forecast. HoltWinters () 8221 وظيفة في حزمة R 8220forecast8221. لاستخدام وظيفة. HoltWinters ()، نحتاج أولا إلى تثبيت حزمة 8220forecast8221 R (للحصول على إرشادات حول كيفية تثبيت حزمة R، راجع كيفية تثبيت حزمة R). بمجرد تثبيت حزمة 8220forecast8221 R، يمكنك تحميل حزمة 8220forecast8221 R عن طريق كتابة: عند استخدام الدالة Forecast. HoltWinters ()، كوسيطتها الأولى (إدخال)، يمكنك تمرير النموذج التنبؤي الذي قمت بتجهيزه بالفعل باستخدام هولتوينترس () وظيفة. على سبيل المثال، في حالة السلاسل الزمنية لهطول الأمطار، قمنا بتخزين النموذج التنبئي الذي تم باستخدام هولتوينترز () في المتغير 8220rainseriesforecasts8221. يمكنك تحديد عدد نقاط الوقت الإضافية التي تريد جعل التنبؤات باستخدام المعلمة 8220h8221 في التنبؤ. هولتوينترز (). على سبيل المثال، لجعل توقعات هطول الأمطار لسنوات 1814-1820 (8 سنوات أخرى) باستخدام التنبؤ. هولتوينترس ()، ونحن نكتب: وظيفة التنبؤ. هولتوينترس () يعطيك توقعات لمدة عام، فاصل التنبؤ 80 ل والتنبؤ، وفترة التنبؤ 95 للتنبؤ. على سبيل المثال، فإن هطول الأمطار المتوقع لعام 1920 حوالي 24.68 بوصة، مع فاصل التنبؤ 95 من (16.24، 33.11). لتخطيط التنبؤات التي أدلى بها التنبؤ. هولتوينترز ()، يمكننا استخدام 8220plot. forecast () 8221 الدالة: هنا يتم رسم توقعات 1913-1920 كخط أزرق، الفاصل الزمني التنبؤ 80 كمنطقة مظللة البرتقالي، و 95 فترة التنبؤ كمنطقة مظللة صفراء. وتحسب الأخطاء 8216forecast8217 القيم الملحوظة ناقص القيم المتوقعة، لكل نقطة زمنية. يمكننا فقط حساب أخطاء التنبؤ للفترة الزمنية التي تغطيها سلسلة زمنية لدينا الأصلية، وهو 1813-1912 للبيانات هطول الأمطار. وكما ذكر أعلاه، فإن مقياسا واحدا من دقة النموذج التنبؤية هو أخطاء مجموع المربعات (سس) في أخطاء التنبؤ داخل العينة. يتم تخزين أخطاء التنبؤ داخل العينة في العنصر المسمى 8220residuals8221 من متغير القائمة التي يتم إرجاعها بواسطة التنبؤ. هولتوينترس (). وإذا تعذر تحسين النموذج التنبئي، ينبغي ألا تكون هناك ترابط بين أخطاء التنبؤ بالتنبؤات المتعاقبة. وبعبارة أخرى، إذا كانت هناك ارتباطات بين أخطاء التنبؤ بالتنبؤات المتعاقبة، فمن المحتمل أن يكون من الممكن تحسين التنبؤات الأسية البسيطة للتمهيد بواسطة تقنية التنبؤ الأخرى. لمعرفة ما إذا كان هذا هو الحال، يمكننا الحصول على الرسم البياني لأخطاء التنبؤ داخل العينة للتخلف 1-20. يمكننا حساب الرسم البياني لأخطاء التنبؤ باستخدام الدالة 8220acf () 8221 في R. لتحديد الفارق الزمني الأقصى الذي نريد أن ننظر إليه، نستخدم المعلمة 8220lag. max8221 في أكف (). على سبيل المثال، لحساب الرسم البياني لأخطاء التنبؤ في العينة لبيانات هطول الأمطار في لندن للتخلف 1-20، نكتب: يمكنك أن ترى من عينة الرسم البياني أن الارتباط الذاتي في تأخر 3 هو مجرد لمس حدود الأهمية. لاختبار ما إذا كان هناك دليل كبير على ارتباطات غير صفرية في الفترات الزمنية 1-20، يمكننا إجراء اختبار لجونغ بوكس. ويمكن القيام بذلك في R باستخدام 8220Box. test () 8221، وظيفة. يتم تحديد الفارق الزمني الأقصى الذي نريد أن ننظر إليه باستخدام المعلمة 8220lag8221 في الدالة Box. test (). على سبيل المثال، لاختبار ما إذا كانت هناك أوتوكوريلاتيونس غير صفرية في الفترات الزمنية 1-20، لأخطاء التنبؤ داخل العينة لبيانات هطول الأمطار في لندن، ونحن نكتب: هنا إحصائية اختبار لجونغ بوكس ​​هو 17.4، وقيمة P هو 0.6 ، ولذلك لا يوجد دليل يذكر على وجود ارتباطات ذاتية غير صفرية في أخطاء التنبؤ داخل العينة عند الفترات الزمنية 1-20. وللتأكد من أن النموذج التنبؤي لا يمكن تحسينه، فمن الجيد أيضا التحقق مما إذا كانت أخطاء التنبؤ موزعة عادة مع متوسط ​​الصفر والتباين المستمر. ولتحقق ما إذا كان لأخطاء التنبؤ تباين ثابت، يمكننا أن نجعل مؤامرة زمنية لأخطاء التنبؤ في العينة: توضح المؤامرة أن أخطاء التنبؤ داخل العينة يبدو أنها تباين ثابت تقريبا مع مرور الوقت، على الرغم من أن حجم التقلبات في قد يكون بداية السلاسل الزمنية (1820-1830) أقل قليلا من ذلك في التواريخ اللاحقة (على سبيل المثال 1840-1850). ولتحقق ما إذا كانت أخطاء التنبؤ موزعة عادة بمتوسط ​​صفر، يمكننا رسم رسم بياني لأخطاء التنبؤ، مع منحنى عادي مضاف له صفر ونفس الانحراف المعياري مثل توزيع أخطاء التنبؤ. للقيام بذلك، يمكننا تحديد وظيفة R 8220plotForecastErrors () 8221، أدناه: سيكون لديك لنسخ وظيفة أعلاه إلى R من أجل استخدامه. يمكنك بعد ذلك استخدام بلوتفوريكاسترورس () لرسم رسم بياني (مع منحنى عادي مضاف إليه) لأخطاء التنبؤ بتنبؤات هطول الأمطار: توضح المؤامرة أن توزيع أخطاء التنبؤ يتمركز تقريبا على الصفر، ويتم توزيعها بشكل طبيعي أو أكثر، على الرغم من يبدو أن يكون منحرف قليلا إلى اليمين بالمقارنة مع منحنى العادي. ومع ذلك، فإن الانحراف الصحيح صغير نسبيا، ولذا فمن المعقول أن أخطاء التنبؤ توزع عادة مع متوسط ​​صفر. وأظهر اختبار لجونغ بوكس ​​أن هناك القليل من الأدلة على وجود ارتباطات ذاتية غير صفرية في أخطاء التنبؤ داخل العينة، ويبدو أن توزيع أخطاء التنبؤ موزعة عادة بمعدل صفر. وهذا يشير إلى أن طريقة التمهيد الأسي البسيط توفر نموذجا تنبؤيا كافيا لهطول الأمطار في لندن، وهو ما قد لا يمكن تحسينه. وعلاوة على ذلك، فإن الافتراضات التي تستند إلى الفواصل الزمنية للتنبؤات 80 و 95 تستند إلى (عدم وجود علاقة ذاتية في أخطاء التنبؤات، وعادة ما توزع أخطاء التنبؤ مع متوسط ​​الصفر والتباين الثابت) على الأرجح. Holt8217s التماسك الأسي إذا كان لديك سلسلة زمنية يمكن وصفها باستخدام نموذج إضافي مع الاتجاه المتزايد أو المتناقص وليس موسمية، يمكنك استخدام تمهيد هولت 8217s الأسي لجعل التوقعات على المدى القصير. ويقدر Holt8217s التمهيد الأسي مستوى والانحدار في نقطة الوقت الحالي. يتم التحكم بالتلميع بواسطة معلمتين، ألفا، لتقدير المستوى عند النقطة الزمنية الحالية، وبيتا لتقدير المنحدر b لعنصر الاتجاه في النقطة الزمنية الحالية. كما هو الحال مع التجانس الأسي البسيط، فإن قيمتي ألفا وبيتا لها قيم بين 0 و 1، والقيم التي تقترب من 0 تعني أن القليل من الوزن يوضع على الملاحظات الأخيرة عند وضع توقعات القيم المستقبلية. مثال على السلاسل الزمنية التي يمكن وصفها على الأرجح باستخدام نموذج مضافة مع اتجاه ولا موسمية هي سلسلة زمنية من قطرها السنوي من التنانير النسائية 8217s في تنحنح، من 1866 إلى 1911. تتوفر البيانات في ملف روجيندمانتسدلداتاروبيرتسكيرتس. دات (البيانات الأصلية من هيبل وماكلويد، 1994). يمكننا أن نقرأ في ورسم البيانات في R عن طريق كتابة: يمكننا أن نرى من المؤامرة التي كانت هناك زيادة في قطر تنحنح من حوالي 600 في عام 1866 إلى حوالي 1050 في عام 1880، وأنه بعد ذلك انخفض قطر تنحنح إلى حوالي 520 في عام 1911.لإجراء التنبؤات، يمكننا أن نلائم نموذج تنبؤي باستخدام الدالة هولتوينترس () في R. لاستخدام هولتوينترز () ل هولتوينترز الأسي، يجب أن نضع المعلمة غامافالس (يتم استخدام المعلمة غاما ل هولت-وينترس الأسي التمهيد، كما هو موضح أدناه). على سبيل المثال، لاستخدام هولت 8217s التمهيد الأسي لتناسب نموذج تنبئي للتنورة تنحنح القطر، ونحن نكتب: القيمة المقدرة ألفا هو 0.84، وبيتا هو 1.00. وكلاهما مرتفع، ويخبرنا أن تقدير القيمة الحالية للمستوى، والمنحدر (ب) لعنصر الاتجاه، يستندان في معظمه إلى ملاحظات حديثة جدا في السلاسل الزمنية. وهذا يجعل الشعور بديهية جيدة، منذ مستوى ومنحدر السلاسل الزمنية على حد سواء تغيير الكثير جدا مع مرور الوقت. قيمة أخطاء مجموع المربعات لأخطاء التنبؤ في العينة هي 16954. يمكننا رسم السلسلة الزمنية الأصلية كخط أسود، مع القيم المتوقعة كخط أحمر فوق ذلك، من خلال كتابة: نحن يمكن أن نرى من الصورة أن التنبؤات داخل العينة تتفق بشكل جيد مع القيم الملحوظة، على الرغم من أنها تميل إلى التخلف عن القيم الملحوظة قليلا. إذا كنت ترغب في ذلك، يمكنك تحديد القيم الأولية للمستوى والمنحدر b من مكون الاتجاه باستخدام الدالات 8220l. start8221 و 8220b. start8221 للدالة هولتوينترس (). ومن الشائع تحديد القيمة الأولية للمستوى إلى القيمة الأولى في السلسلة الزمنية (608 لبيانات التنانير)، والقيمة الأولية للمنحدر إلى القيمة الثانية مطروحا منها القيمة الأولى (9 بالنسبة إلى بيانات التنانير). على سبيل المثال، لتتناسب مع نموذج تنبؤي لبيانات تنحنح تنورة باستخدام التجانس الأسي هولت 8217s، مع القيم الأولية من 608 للمستوى و 9 للمنحدر ب من عنصر الاتجاه، ونحن نكتب: أما بالنسبة للتمهيد الأسي بسيط، يمكننا أن نجعل التنبؤات لأوقات مستقبلية لا تغطيها السلسلة الزمنية الأصلية باستخدام وظيفة التنبؤ. هولتوينترس () في حزمة 8220forecast8221. على سبيل المثال، كانت بيانات السلاسل الزمنية للتنورة هي 1866 إلى 1911، حتى نتمكن من تقديم تنبؤات لعام 1912 إلى 1930 (19 نقطة بيانات إضافية)، ورسمها، عن طريق كتابة: تظهر التوقعات كخط أزرق، مع 80 فترات كمنطقة برتقالية مظللة، وفترات التنبؤ 95 كمنطقة مظللة صفراء. أما بالنسبة للتجانس الأسي البسيط فيمكننا التحقق مما إذا كان من الممكن تحسين النموذج التنبئي عن طريق التحقق مما إذا كانت أخطاء التنبؤ داخل العينة تظهر ارتباطات ذاتية غير صفرية عند الفترات الزمنية 1-20. على سبيل المثال، لبيانات تنحنح تنورة، يمكننا أن نجعل من الرسم البياني، وإجراء اختبار يجونغ بوكس، عن طريق كتابة: هنا يظهر الرسم البياني أن الارتباط الذاتي العينة لأخطاء التنبؤ في العينة في تأخر 5 يتجاوز حدود الأهمية. ومع ذلك، فإننا نتوقع واحد في 20 من أوتوكوريلاتيونس لأول عشرين الفترات تتجاوز حدود الأهمية 95 عن طريق الصدفة وحدها. في الواقع، عندما نقوم بإجراء اختبار يجونغ بوكس، قيمة p هي 0.47، مما يدل على أن هناك القليل من الأدلة على عدم الصفر أوتوكوريلاتيونس في أخطاء التنبؤ داخل العينة في الفترات الزمنية 1-20. أما بالنسبة للتجانس الأسي البسيط، فينبغي أن نتحقق أيضا من أن أخطاء التنبؤ لها تباين ثابت مع مرور الوقت، وتوزع عادة بمتوسط ​​صفر. ويمكننا أن نفعل ذلك من خلال وضع مخطط زمني لأخطاء التنبؤات، ورسم بياني لتوزيع أخطاء التنبؤ مع منحنى عادي مضاف إليه: توضح المؤامرة الزمنية لأخطاء التنبؤ أن أخطاء التنبؤ لها تباين ثابت تقريبا مع مرور الوقت. ويبين الرسم البياني لأخطاء التنبؤ أنه من المعقول أن تكون أخطاء التنبؤ موزعة عادة بمتوسط ​​صفر وتغير ثابت. وهكذا، يظهر اختبار لجونغ بوكس ​​أن هناك القليل من الأدلة على الارتباطات التلقائية في أخطاء التنبؤ، في حين أن مؤامرة الوقت والمخطط البياني لأخطاء التنبؤ تبين أنه من المعقول أن يتم توزيع أخطاء التنبؤ عادة مع متوسط ​​الصفر والتباين المستمر. لذلك، يمكننا أن نستنتج أن هولت 8217s الأسي التمهيد يوفر نموذج تنبؤي كاف للتنورة تنحنح أقطار، والتي ربما لا يمكن تحسينها على. وبالإضافة إلى ذلك، فهذا يعني أن الافتراضات التي تستند إلى الفترات الزمنية للتنبؤات 80 و 95 قد تكون صحيحة. هولت-وينترس الأسي التنعيم إذا كان لديك سلسلة زمنية يمكن وصفها باستخدام نموذج المضافة مع زيادة أو انخفاض الاتجاه والموسمية، يمكنك استخدام هولت الشتاء الشتاء الأسي لجعل التنبؤات على المدى القصير. هولت-وينترس الأسي التمهيد يقدر المستوى، المنحدر والمكون الموسمية في الوقت الحالي نقطة. يتم التحكم بالتلميع بثلاث معلمات: ألفا، بيتا، و غاما، لتقديرات المستوى، المنحدر b لعنصر الاتجاه، والمكون الموسمي، على التوالي، عند النقطة الزمنية الحالية. وتتراوح قيم المعلمات ألفا وبيتا و غاما بين 0 و 1، والقيم القريبة من 0 تعني أن الوزن القليل نسبيا يوضع على الملاحظات الأخيرة عند وضع توقعات للقيم المستقبلية. ومن الأمثلة على السلاسل الزمنية التي يمكن وصفها على الأرجح باستخدام نموذج مضاف مع الاتجاه والموسمية هو التسلسل الزمني لسجل المبيعات الشهرية لمتجر الهدايا التذكارية في مدينة منتجع على الشاطئ في كوينزلاند بأستراليا (تمت مناقشته أعلاه): التنبؤات، ونحن يمكن أن يصلح نموذج التنبؤي باستخدام وظيفة هولتوينترس (). على سبيل المثال، لتناسب نموذج تنبؤي لسجل المبيعات الشهرية في متجر الهدايا التذكارية، نكتب: القيم المقدرة ألفا وبيتا وغاما هي 0.41، 0.00، و 0.96 على التوالي. قيمة ألفا (0.41) منخفضة نسبيا، مما يشير إلى أن تقدير المستوى في الوقت الحالي يستند إلى الملاحظات الأخيرة وبعض الملاحظات في الماضي البعيد. وتبلغ قيمة بيتا 0.00، مما يشير إلى أن تقدير المنحدر b لمكون الاتجاه لا يتم تحديثه على مدى السلاسل الزمنية، وبدلا من ذلك يتم تعيينه مساويا لقيمته الأولية. وهذا يجعل الشعور بديهية جيدة، كما يتغير مستوى قليلا على مدى سلسلة زمنية، ولكن المنحدر ب من عنصر الاتجاه لا يزال تقريبا نفس. وعلى النقيض من ذلك، فإن قيمة غاما (0.96) مرتفعة، مما يشير إلى أن تقدير العنصر الموسمية في النقطة الزمنية الحالية يستند فقط إلى ملاحظات حديثة جدا. أما بالنسبة للتمهيد الأسي بسيط و هولت 8217s التمهيد الأسي، يمكننا رسم سلسلة الوقت الأصلي كخط أسود، مع القيم المتوقعة كخط أحمر على رأس ذلك: ونحن نرى من مؤامرة أن الأساليب هولت الشتاء الأسية هي ناجحة جدا في التنبؤ بالقمم الموسمية، والتي تحدث تقريبا في نوفمبر من كل عام. لجعل التنبؤات في الأوقات المستقبلية غير المدرجة في السلسلة الزمنية الأصلية، نستخدم 8220forecast. HoltWinters () 8221 الدالة في 8220forecast8221 الحزمة. على سبيل المثال، البيانات الأصلية لمبيعات الهدايا التذكارية هي من كانون الثاني / يناير 1987 إلى كانون الأول / ديسمبر 1993. وإذا أردنا أن نجعل التنبؤات من كانون الثاني / يناير 1994 إلى كانون الأول / ديسمبر 1998 (48 شهرا أخرى)، ورسم التوقعات، سنكتب: خط أزرق، والمناطق البرتقالية والأصفر المظللة تظهر 80 و 95 فترات التنبؤ، على التوالي. ويمكننا التحقيق فيما إذا كان بالإمكان تحسين النموذج التنبئي عن طريق التحقق مما إذا كانت أخطاء التنبؤ داخل العينة تظهر أوتوكوريلاتيونس غير الصفر عند الفترات الزمنية 1-20، من خلال إجراء رسم تشعبي وإجراء اختبار لجونغ بوكس: يوضح الرسم البياني أن الارتباطات التلقائية (أوتوكوريلاتيونس) لأن أخطاء التنبؤ داخل العينة لا تتجاوز حدود الأهمية للتخلف 1-20. وعلاوة على ذلك، فإن قيمة p للاختبار لجونغ بوكس ​​هو 0.6، مشيرا إلى أن هناك القليل من الأدلة على أوتوكوريلاتيونس غير الصفر في التأخر 1-20. ويمكننا التحقق مما إذا كانت أخطاء التنبؤ لها تباين مستمر مع مرور الوقت، وتوزع عادة بمتوسط ​​صفر، وذلك بوضع مخطط زمني لأخطاء التنبؤات ومدرج بياني (مع منحنى عادي مضاف إليه): من المؤامرة الزمنية، يبدو من المعقول أن أخطاء التنبؤ لها تباين مستمر مع مرور الوقت. من الرسم البياني لأخطاء التنبؤ، يبدو من المعقول أن يتم توزيع أخطاء التنبؤ عادة مع متوسط ​​صفر. وهكذا، لا يوجد دليل ضئيل على الترابط الذاتي عند الفترات الزمنية 1-20 لأخطاء التنبؤ، ويبدو أن أخطاء التنبؤ توزع عادة بمتوسط ​​صفر وتغير ثابت مع مرور الوقت. هذا يشير إلى أن هولت-وينترس الأسي التمهيد يوفر نموذج تنبؤي كاف من سجل المبيعات في متجر للهدايا التذكارية، والتي ربما لا يمكن تحسينها. Furthermore, the assumptions upon which the prediction intervals were based are probably valid. ARIMA Models Exponential smoothing methods are useful for making forecasts, and make no assumptions about the correlations between successive values of the time series. However, if you want to make prediction intervals for forecasts made using exponential smoothing methods, the prediction intervals require that the forecast errors are uncorrelated and are normally distributed with mean zero and constant variance. While exponential smoothing methods do not make any assumptions about correlations between successive values of the time series, in some cases you can make a better predictive model by taking correlations in the data into account. Autoregressive Integrated Moving Average (ARIMA) models include an explicit statistical model for the irregular component of a time series, that allows for non-zero autocorrelations in the irregular component. Differencing a Time Series ARIMA models are defined for stationary time series. Therefore, if you start off with a non-stationary time series, you will first need to 8216difference8217 the time series until you obtain a stationary time series. If you have to difference the time series d times to obtain a stationary series, then you have an ARIMA(p, d,q) model, where d is the order of differencing used. You can difference a time series using the 8220diff()8221 function in R. For example, the time series of the annual diameter of women8217s skirts at the hem, from 1866 to 1911 is not stationary in mean, as the level changes a lot over time: We can difference the time series (which we stored in 8220skirtsseries8221, see above) once, and plot the differenced series, by typing: The resulting time series of first differences (above) does not appear to be stationary in mean. Therefore, we can difference the time series twice, to see if that gives us a stationary time series: Formal tests for stationarity Formal tests for stationarity called 8220unit root tests8221 are available in the fUnitRoots package, available on CRAN, but will not be discussed here. The time series of second differences (above) does appear to be stationary in mean and variance, as the level of the series stays roughly constant over time, and the variance of the series appears roughly constant over time. Thus, it appears that we need to difference the time series of the diameter of skirts twice in order to achieve a stationary series. If you need to difference your original time series data d times in order to obtain a stationary time series, this means that you can use an ARIMA(p, d,q) model for your time series, where d is the order of differencing used. For example, for the time series of the diameter of women8217s skirts, we had to difference the time series twice, and so the order of differencing (d) is 2. This means that you can use an ARIMA(p,2,q) model for your time series. The next step is to figure out the values of p and q for the ARIMA model. Another example is the time series of the age of death of the successive kings of England (see above): From the time plot (above), we can see that the time series is not stationary in mean. To calculate the time series of first differences, and plot it, we type: The time series of first differences appears to be stationary in mean and variance, and so an ARIMA(p,1,q) model is probably appropriate for the time series of the age of death of the kings of England. By taking the time series of first differences, we have removed the trend component of the time series of the ages at death of the kings, and are left with an irregular component. We can now examine whether there are correlations between successive terms of this irregular component if so, this could help us to make a predictive model for the ages at death of the kings. Selecting a Candidate ARIMA Model If your time series is stationary, or if you have transformed it to a stationary time series by differencing d times, the next step is to select the appropriate ARIMA model, which means finding the values of most appropriate values of p and q for an ARIMA(p, d,q) model. To do this, you usually need to examine the correlogram and partial correlogram of the stationary time series. To plot a correlogram and partial correlogram, we can use the 8220acf()8221 and 8220pacf()8221 functions in R, respectively. To get the actual values of the autocorrelations and partial autocorrelations, we set 8220plotFALSE8221 in the 8220acf()8221 and 8220pacf()8221 functions. Example of the Ages at Death of the Kings of England For example, to plot the correlogram for lags 1-20 of the once differenced time series of the ages at death of the kings of England, and to get the values of the autocorrelations, we type: We see from the correlogram that the autocorrelation at lag 1 (-0.360) exceeds the significance bounds, but all other autocorrelations between lags 1-20 do not exceed the significance bounds. To plot the partial correlogram for lags 1-20 for the once differenced time series of the ages at death of the English kings, and get the values of the partial autocorrelations, we use the 8220pacf()8221 function, by typing: The partial correlogram shows that the partial autocorrelations at lags 1, 2 and 3 exceed the significance bounds, are negative, and are slowly decreasing in magnitude with increasing lag (lag 1: -0.360, lag 2: -0.335, lag 3:-0.321). The partial autocorrelations tail off to zero after lag 3. Since the correlogram is zero after lag 1, and the partial correlogram tails off to zero after lag 3, this means that the following ARMA (autoregressive moving average) models are possible for the time series of first differences: an ARMA(3,0) model, that is, an autoregressive model of order p3, since the partial autocorrelogram is zero after lag 3, and the autocorrelogram tails off to zero (although perhaps too abruptly for this model to be appropriate) an ARMA(0,1) model, that is, a moving average model of order q1, since the autocorrelogram is zero after lag 1 and the partial autocorrelogram tails off to zero an ARMA(p, q) model, that is, a mixed model with p and q greater than 0, since the autocorrelogram and partial correlogram tail off to zero (although the correlogram probably tails off to zero too abruptly for this model to be appropriate) We use the principle of parsimony to decide which model is best: that is, we assum e that the model with the fewest parameters is best. The ARMA(3,0) model has 3 parameters, the ARMA(0,1) model has 1 parameter, and the ARMA(p, q) model has at least 2 parameters. Therefore, the ARMA(0,1) model is taken as the best model. An ARMA(0,1) model is a moving average model of order 1, or MA(1) model. This model can be written as: Xt - mu Zt - (theta Zt-1), where Xt is the stationary time series we are studying (the first differenced series of ages at death of English kings), mu is the mean of time series Xt, Zt is white noise with mean zero and constant variance, and theta is a parameter that can be estimated. A MA (moving average) model is usually used to model a time series that shows short-term dependencies between successive observations. Intuitively, it makes good sense that a MA model can be used to describe the irregular component in the time series of ages at death of English kings, as we might expect the age at death of a particular English king to have some effect on the ages at death of the next king or two, but not much effect on the ages at death of kings that reign much longer after that. Shortcut: the auto. arima() function The auto. arima() function can be used to find the appropriate ARIMA model, eg. type 8220library(forecast)8221, then 8220auto. arima(kings)8221. The output says an appropriate model is ARIMA(0,1,1). Since an ARMA(0,1) model (with p0, q1) is taken to be the best candidate model for the time series of first differences of the ages at death of English kings, then the original time series of the ages of death can be modelled using an ARIMA(0,1,1) model (with p0, d1, q1, where d is the order of differencing required). Example of the Volcanic Dust Veil in the Northern Hemisphere Let8217s take another example of selecting an appropriate ARIMA model. The file file robjhyndmantsdldataannualdvi. dat contains data on the volcanic dust veil index in the northern hemisphere, from 1500-1969 (original data from Hipel and Mcleod, 1994). This is a measure of the impact of volcanic eruptions8217 release of dust and aerosols into the environment. We can read it into R and make a time plot by typing: From the time plot, it appears that the random fluctuations in the time series are roughly constant in size over time, so an additive model is probably appropriate for describing this time series. Furthermore, the time series appears to be stationary in mean and variance, as its level and variance appear to be roughly constant over time. Therefore, we do not need to difference this series in order to fit an ARIMA model, but can fit an ARIMA model to the original series (the order of differencing required, d, is zero here). We can now plot a correlogram and partial correlogram for lags 1-20 to investigate what ARIMA model to use: We see from the correlogram that the autocorrelations for lags 1, 2 and 3 exceed the significance bounds, and that the autocorrelations tail off to zero after lag 3. The autocorrelations for lags 1, 2, 3 are positive, and decrease in magnitude with increasing lag (lag 1: 0.666, lag 2: 0.374, lag 3: 0.162). The autocorrelation for lags 19 and 20 exceed the significance bounds too, but it is likely that this is due to chance, since they just exceed the significance bounds (especially for lag 19), the autocorrelations for lags 4-18 do not exceed the signifiance bounds, and we would expect 1 in 20 lags to exceed the 95 significance bounds by chance alone. From the partial autocorrelogram, we see that the partial autocorrelation at lag 1 is positive and exceeds the significance bounds (0.666), while the partial autocorrelation at lag 2 is negative and also exceeds the significance bounds (-0.126). The partial autocorrelations tail off to zero after lag 2. Since the correlogram tails off to zero after lag 3, and the partial correlogram is zero after lag 2, the following ARMA models are possible for the time series: an ARMA(2,0) model, since the partial autocorrelogram is zero after lag 2, and the correlogram tails off to zero after lag 3, and the partial correlogram is zero after lag 2 an ARMA(0,3) model, since the autocorrelogram is zero after lag 3, and the partial correlogram tails off to zero (although perhaps too abruptly for this model to be appropriate) an ARMA(p, q) mixed model, since the correlogram and partial correlogram tail off to zero (although the partial correlogram perhaps tails off too abruptly for this model to be appropriate) Shortcut: the auto. arima() function Again, we can use auto. arima() to find an appropriate model, by typing 8220auto. arima(volcanodust)8221, which gives us ARIMA(1,0,2), which has 3 parameters. However, different criteria can be used to select a model (see auto. arima() help page). If we use the 8220bic8221 criterion, which penalises the number of parameters, we get ARIMA(2,0,0), which is ARMA(2,0): 8220auto. arima(volcanodust, ic8221bic8221)8221. The ARMA(2,0) model has 2 parameters, the ARMA(0,3) model has 3 parameters, and the ARMA(p, q) model has at least 2 parameters. Therefore, using the principle of parsimony, the ARMA(2,0) model and ARMA(p, q) model are equally good candidate models. An ARMA(2,0) model is an autoregressive model of order 2, or AR(2) model. This model can be written as: Xt - mu (Beta1 (Xt-1 - mu)) (Beta2 (Xt-2 - mu)) Zt, where Xt is the stationary time series we are studying (the time series of volcanic dust veil index), mu is the mean of time series Xt, Beta1 and Beta2 are parameters to be estimated, and Zt is white noise with mean zero and constant variance. An AR (autoregressive) model is usually used to model a time series which shows longer term dependencies between successive observations. Intuitively, it makes sense that an AR model could be used to describe the time series of volcanic dust veil index, as we would expect volcanic dust and aerosol levels in one year to affect those in much later years, since the dust and aerosols are unlikely to disappear quickly. If an ARMA(2,0) model (with p2, q0) is used to model the time series of volcanic dust veil index, it would mean that an ARIMA(2,0,0) model can be used (with p2, d0, q0, where d is the order of differencing required). Similarly, if an ARMA(p, q) mixed model is used, where p and q are both greater than zero, than an ARIMA(p,0,q) model can be used. Forecasting Using an ARIMA Model Once you have selected the best candidate ARIMA(p, d,q) model for your time series data, you can estimate the parameters of that ARIMA model, and use that as a predictive model for making forecasts for future values of your time series. You can estimate the parameters of an ARIMA(p, d,q) model using the 8220arima()8221 function in R. Example of the Ages at Death of the Kings of England For example, we discussed above that an ARIMA(0,1,1) model seems a plausible model for the ages at deaths of the kings of England. You can specify the values of p, d and q in the ARIMA model by using the 8220order8221 argument of the 8220arima()8221 function in R. To fit an ARIMA(p, d,q) model to this time series (which we stored in the variable 8220kingstimeseries8221, see above), we type: As mentioned above, if we are fitting an ARIMA(0,1,1) model to our time series, it means we are fitting an an ARMA(0,1) model to the time series of first differences. An ARMA(0,1) model can be written Xt - mu Zt - (theta Zt-1), where theta is a parameter to be estimated. From the output of the 8220arima()8221 R function (above), the estimated value of theta (given as 8216ma18217 in the R output) is -0.7218 in the case of the ARIMA(0,1,1) model fitted to the time series of ages at death of kings. Specifying the confidence level for prediction intervals You can specify the confidence level for prediction intervals in forecast. Arima() by using the 8220level8221 argument. For example, to get a 99.5 prediction interval, we would type 8220forecast. Arima(kingstimeseriesarima, h5, levelc(99.5))8221. We can then use the ARIMA model to make forecasts for future values of the time series, using the 8220forecast. Arima()8221 function in the 8220forecast8221 R package. For example, to forecast the ages at death of the next five English kings, we type: The original time series for the English kings includes the ages at death of 42 English kings. The forecast. Arima() function gives us a forecast of the age of death of the next five English kings (kings 43-47), as well as 80 and 95 prediction intervals for those predictions. The age of death of the 42nd English king was 56 years (the last observed value in our time series), and the ARIMA model gives the forecasted age at death of the next five kings as 67.8 years. We can plot the observed ages of death for the first 42 kings, as well as the ages that would be predicted for these 42 kings and for the next 5 kings using our ARIMA(0,1,1) model, by typing: As in the case of exponential smoothing models, it is a good idea to investigate whether the forecast errors of an ARIMA model are normally distributed with mean zero and constant variance, and whether the are correlations between successive forecast errors. For example, we can make a correlogram of the forecast errors for our ARIMA(0,1,1) model for the ages at death of kings, and perform the Ljung-Box test for lags 1-20, by typing: Since the correlogram shows that none of the sample autocorrelations for lags 1-20 exceed the significance bounds, and the p-value for the Ljung-Box test is 0.9, we can conclude that there is very little evidence for non-zero autocorrelations in the forecast errors at lags 1-20. To investigate whether the forecast errors are normally distributed with mean zero and constant variance, we can make a time plot and histogram (with overlaid normal curve) of the forecast errors: The time plot of the in-sample forecast errors shows that the variance of the forecast errors seems to be roughly constant over time (though perhaps there is slightly higher variance for the second half of the time series). The histogram of the time series shows that the forecast errors are roughly normally distributed and the mean seems to be close to zero. Therefore, it is plausible that the forecast errors are normally distributed with mean zero and constant variance. Since successive forecast errors do not seem to be correlated, and the forecast errors seem to be normally distributed with mean zero and constant variance, the ARIMA(0,1,1) does seem to provide an adequate predictive model for the ages at death of English kings. Example of the Volcanic Dust Veil in the Northern Hemisphere We discussed above that an appropriate ARIMA model for the time series of volcanic dust veil index may be an ARIMA(2,0,0) model. To fit an ARIMA(2,0,0) model to this time series, we can type: As mentioned above, an ARIMA(2,0,0) model can be written as: written as: Xt - mu (Beta1 (Xt-1 - mu)) (Beta2 (Xt-2 - mu)) Zt, where Beta1 and Beta2 are parameters to be estimated. The output of the arima() function tells us that Beta1 and Beta2 are estimated as 0.7533 and -0.1268 here (given as ar1 and ar2 in the output of arima()). Now we have fitted the ARIMA(2,0,0) model, we can use the 8220forecast. ARIMA()8221 model to predict future values of the volcanic dust veil index. The original data includes the years 1500-1969. To make predictions for the years 1970-2000 (31 more years), we type: We can plot the original time series, and the forecasted values, by typing: One worrying thing is that the model has predicted negative values for the volcanic dust veil index, but this variable can only have positive values The reason is that the arima() and forecast. Arima() functions don8217t know that the variable can only take positive values. Clearly, this is not a very desirable feature of our current predictive model. Again, we should investigate whether the forecast errors seem to be correlated, and whether they are normally distributed with mean zero and constant variance. To check for correlations between successive forecast errors, we can make a correlogram and use the Ljung-Box test: The correlogram shows that the sample autocorrelation at lag 20 exceeds the significance bounds. However, this is probably due to chance, since we would expect one out of 20 sample autocorrelations to exceed the 95 significance bounds. Furthermore, the p-value for the Ljung-Box test is 0.2, indicating that there is little evidence for non-zero autocorrelations in the forecast errors for lags 1-20. To check whether the forecast errors are normally distributed with mean zero and constant variance, we make a time plot of the forecast errors, and a histogram: The time plot of forecast errors shows that the forecast errors seem to have roughly constant variance over time. However, the time series of forecast errors seems to have a negative mean, rather than a zero mean. We can confirm this by calculating the mean forecast error, which turns out to be about -0.22: The histogram of forecast errors (above) shows that although the mean value of the forecast errors is negative, the distribution of forecast errors is skewed to the right compared to a normal curve. Therefore, it seems that we cannot comfortably conclude that the forecast errors are normally distributed with mean zero and constant variance Thus, it is likely that our ARIMA(2,0,0) model for the time series of volcanic dust veil index is not the best model that we could make, and could almost definitely be improved upon Links and Further Reading Here are some links for further reading. For a more in-depth introduction to R, a good online tutorial is available on the 8220Kickstarting R8221 website, cran. r-project. orgdoccontribLemon-kickstart . There is another nice (slightly more in-depth) tutorial to R available on the 8220Introduction to R8221 website, cran. r-project. orgdocmanualsR-intro. html . You can find a list of R packages for analysing time series data on the CRAN Time Series Task View webpage . To learn about time series analysis, I would highly recommend the book 8220Time series8221 (product code M24902) by the Open University, available from the Open University Shop . There are two books available in the 8220Use R8221 series on using R for time series analyses, the first is Introductory Time Series with R by Cowpertwait and Metcalfe, and the second is Analysis of Integrated and Cointegrated Time Series with R by Pfaff. Acknowledgements I am grateful to Professor Rob Hyndman. for kindly allowing me to use the time series data sets from his Time Series Data Library (TSDL) in the examples in this booklet. Many of the examples in this booklet are inspired by examples in the excellent Open University book, 8220Time series8221 (product code M24902), available from the Open University Shop . Thank you to Ravi Aranke for bringing auto. arima() to my attention, and Maurice Omane-Adjepong for bringing unit root tests to my attention, and Christian Seubert for noticing a small bug in plotForecastErrors(). Thank you for other comments to Antoine Binard and Bill Johnston. I will be grateful if you will send me (Avril Coghlan) corrections or suggestions for improvements to my email address alc 64 sanger 46 ac 46 ukIdentifying the numbers of AR or MA terms in an ARIMA model ACF and PACF plots: After a time series has been stationarized by differencing, the next step in fitting an ARIMA model is to determine whether AR or MA terms are needed to correct any autocorrelation that remains in the differenced series. Of course, with software like Statgraphics, you could just try some different combinations of terms and see what works best. But there is a more systematic way to do this. By looking at the autocorrelation function (ACF) and partial autocorrelation (PACF) plots of the differenced series, you can tentatively identify the numbers of AR andor MA terms that are needed. You are already familiar with the ACF plot: it is merely a bar chart of the coefficients of correlation between a time series and lags of itself. The PACF plot is a plot of the partial correlation coefficients between the series and lags of itself. In general, the quotpartialquot correlation between two variables is the amount of correlation between them which is not explained by their mutual correlations with a specified set of other variables. For example, if we are regressing a variable Y on other variables X1, X2, and X3, the partial correlation between Y and X3 is the amount of correlation between Y and X3 that is not explained by their common correlations with X1 and X2. This partial correlation can be computed as the square root of the reduction in variance that is achieved by adding X3 to the regression of Y on X1 and X2. A partial auto correlation is the amount of correlation between a variable and a lag of itself that is not explained by correlations at all lower-order - lags. The autocorrelation of a time series Y at lag 1 is the coefficient of correlation between Y t and Y t - 1 . which is presumably also the correlation between Y t -1 and Y t -2 . But if Y t is correlated with Y t -1 . and Y t -1 is equally correlated with Y t -2 . then we should also expect to find correlation between Y t and Y t-2 . In fact, the amount of correlation we should expect at lag 2 is precisely the square of the lag-1 correlation. Thus, the correlation at lag 1 quotpropagatesquot to lag 2 and presumably to higher-order lags. The partial autocorrelation at lag 2 is therefore the difference between the actual correlation at lag 2 and the expected correlation due to the propagation of correlation at lag 1. Here is the autocorrelation function (ACF) of the UNITS series, before any differencing is performed: The autocorrelations are significant for a large number of lags--but perhaps the autocorrelations at lags 2 and above are merely due to the propagation of the autocorrelation at lag 1. This is confirmed by the PACF plot: Note that the PACF plot has a significant spike only at lag 1, meaning that all the higher-order autocorrelations are effectively explained by the lag-1 autocorrelation. The partial autocorrelations at all lags can be computed by fitting a succession of autoregressive models with increasing numbers of lags. In particular, the partial autocorrelation at lag k is equal to the estimated AR( k ) coefficient in an autoregressive model with k terms--i. e. a multiple regression model in which Y is regressed on LAG(Y,1), LAG(Y,2), etc. up to LAG(Y, k ). Thus, by mere inspection of the PACF you can determine how many AR terms you need to use to explain the autocorrelation pattern in a time series: if the partial autocorrelation is significant at lag k and not significant at any higher order lags--i. e. if the PACF quotcuts offquot at lag k --then this suggests that you should try fitting an autoregressive model of order k The PACF of the UNITS series provides an extreme example of the cut-off phenomenon: it has a very large spike at lag 1 and no other significant spikes, indicating that in the absence of differencing an AR(1) model should be used. However, the AR(1) term in this model will turn out to be equivalent to a first difference, because the estimated AR(1) coefficient (which is the height of the PACF spike at lag 1) will be almost exactly equal to 1. Now, the forecasting equation for an AR(1) model for a series Y with no orders of differencing is: If the AR(1) coefficient 981 1 in this equation is equal to 1, it is equivalent to predicting that the first difference of Y is constant--i. e. it is equivalent to the equation of the random walk model with growth: The PACF of the UNITS series is telling us that, if we dont difference it, then we should fit an AR(1) model which will turn out to be equivalent to taking a first difference. In other words, it is telling us that UNITS really needs an order of differencing to be stationarized. AR and MA signatures: If the PACF displays a sharp cutoff while the ACF decays more slowly (i. e. has significant spikes at higher lags), we say that the stationarized series displays an quotAR signature, quot meaning that the autocorrelation pattern can be explained more easily by adding AR terms than by adding MA terms. You will probably find that an AR signature is commonly associated with positive autocorrelation at lag 1--i. e. it tends to arise in series which are slightly under differenced. The reason for this is that an AR term can act like a quotpartial differencequot in the forecasting equation . For example, in an AR(1) model, the AR term acts like a first difference if the autoregressive coefficient is equal to 1, it does nothing if the autoregressive coefficient is zero, and it acts like a partial difference if the coefficient is between 0 and 1. So, if the series is slightly underdifferenced--i. e. if the nonstationary pattern of positive autocorrelation has not completely been eliminated, it will quotask forquot a partial difference by displaying an AR signature. Hence, we have the following rule of thumb for determining when to add AR terms: Rule 6: If the PACF of the differenced series displays a sharp cutoff andor the lag-1 autocorrelation is positive --i. e. if the series appears slightly quotunderdifferencedquot--then consider adding an AR term to the model. The lag at which the PACF cuts off is the indicated number of AR terms. In principle, any autocorrelation pattern can be removed from a stationarized series by adding enough autoregressive terms (lags of the stationarized series) to the forecasting equation, and the PACF tells you how many such terms are likely be needed. However, this is not always the simplest way to explain a given pattern of autocorrelation: sometimes it is more efficient to add MA terms (lags of the forecast errors) instead. The autocorrelation function (ACF) plays the same role for MA terms that the PACF plays for AR terms--that is, the ACF tells you how many MA terms are likely to be needed to remove the remaining autocorrelation from the differenced series. If the autocorrelation is significant at lag k but not at any higher lags--i. e. if the ACF quotcuts offquot at lag k-- this indicates that exactly k MA terms should be used in the forecasting equation. In the latter case, we say that the stationarized series displays an quotMA signature, quot meaning that the autocorrelation pattern can be explained more easily by adding MA terms than by adding AR terms. An MA signature is commonly associated with negative autocorrelation at lag 1--i. e. it tends to arise in series which are slightly over differenced. The reason for this is that an MA term can quotpartially cancelquot an order of differencing in the forecasting equation . To see this, recall that an ARIMA(0,1,1) model without constant is equivalent to a Simple Exponential Smoothing model. The forecasting equation for this model is where the MA(1) coefficient 952 1 corresponds to the quantity 1 - 945 in the SES model. If 952 1 is equal to 1, this corresponds to an SES model with 945 0, which is just a CONSTANT model because the forecast is never updated. This means that when 952 1 is equal to 1, it is actually cancelling out the differencing operation that ordinarily enables the SES forecast to re-anchor itself on the last observation. On the other hand, if the moving-average coefficient is equal to 0, this model reduces to a random walk model--i. e. it leaves the differencing operation alone. So, if 952 1 is something greater than 0, it is as if we are partially cancelling an order of differencing. If the series is already slightly over differenced--i. e. if negative autocorrelation has been introduced--then it will quotask forquot a difference to be partly cancelled by displaying an MA signature. (A lot of arm-waving is going on here A more rigorous explanation of this effect is found in the Mathematical Structure of ARIMA Models handout.) Hence the following additional rule of thumb: Rule 7: If the ACF of the differenced series displays a sharp cutoff andor the lag-1 autocorrelation is negative --i. e. if the series appears slightly quotoverdifferencedquot--then consider adding an MA term to the model. The lag at which the ACF cuts off is the indicated number of MA terms. A model for the UNITS series--ARIMA(2,1,0): Previously we determined that the UNITS series needed (at least) one order of nonseasonal differencing to be stationarized. After taking one nonseasonal difference--i. e. fitting an ARIMA(0,1,0) model with constant--the ACF and PACF plots look like this: Notice that (a) the correlation at lag 1 is significant and positive, and (b) the PACF shows a sharper quotcutoffquot than the ACF. In particular, the PACF has only two significant spikes, while the ACF has four. Thus, according to Rule 7 above, the differenced series displays an AR(2) signature. If we therefore set the order of the AR term to 2--i. e. fit an ARIMA(2,1,0) model--we obtain the following ACF and PACF plots for the residuals: The autocorrelation at the crucial lags--namely lags 1 and 2--has been eliminated, and there is no discernible pattern in higher-order lags. The time series plot of the residuals shows a slightly worrisome tendency to wander away from the mean: However, the analysis summary report shows that the model nonetheless performs quite well in the validation period, both AR coefficients are significantly different from zero, and the standard deviation of the residuals has been reduced from 1.54371 to 1.4215 (nearly 10) by the addition of the AR terms. Furthermore, there is no sign of a quotunit rootquot because the sum of the AR coefficients (0.2522540.195572) is not close to 1. (Unit roots are discussed on more detail below .) On the whole, this appears to be a good model. The (untransformed) forecasts for the model show a linear upward trend projected into the future: The trend in the long-term forecasts is due to fact that the model includes one nonseasonal difference and a constant term: this model is basically a random walk with growth fine-tuned by the addition of two autoregressive terms--i. e. two lags of the differenced series. The slope of the long-term forecasts (i. e. the average increase from one period to another) is equal to the mean term in the model summary (0.467566). The forecasting equation is: where 956 is the constant term in the model summary (0.258178), 981 1 is the AR(1) coefficient (0.25224) and 981 2 is the AR(2) coefficient (0.195572). Mean versus constant: In general, the quotmeanquot term in the output of an ARIMA model refers to the mean of the differenced series (i. e. the average trend if the order of differencing is equal to 1), whereas the quotconstantquot is the constant term that appears on the right-hand-side of the forecasting equation . The mean and constant terms are related by the equation: CONSTANT MEAN(1 minus the sum of the AR coefficients). In this case, we have 0.258178 0.467566(1 - 0.25224 - 0.195572) Alternative model for the UNITS series--ARIMA(0,2,1): Recall that when we began to analyze the UNITS series, we were not entirely sure of the correct order of differencing to use. One order of nonseasonal differencing yielded the lowest standard deviation (and a pattern of mild positive autocorrelation), while two orders of nonseasonal differencing yielded a more stationary-looking time series plot (but with rather strong negative autocorrelation). Here are both the ACF and PACF of the series with two nonseasonal differences: The single negative spike at lag 1 in the ACF is an MA(1) signature, according to Rule 8 above. Thus, if we were to use 2 nonseasonal differences, we would also want to include an MA(1) term, yielding an ARIMA(0,2,1) model. According to Rule 5, we would also want to suppress the constant term. Here, then, are the results of fitting an ARIMA(0,2,1) model without constant: Notice that the estimated white noise standard deviation (RMSE) is only very slightly higher for this model than the previous one (1.46301 here versus 1.45215 previously). The forecasting equation for this model is: where theta-1 is the MA(1) coefficient. Recall that this is similar to a Linear Exponential Smoothing model, with the MA(1) coefficient corresponding to the quantity 2(1-alpha) in the LES model. The MA(1) coefficient of 0.76 in this model suggests that an LES model with alpha in the vicinity of 0.72 would fit about equally well. Actually, when an LES model is fitted to the same data, the optimal value of alpha turns out to be around 0.61, which is not too far off. Here is a model comparison report that shows the results of fitting the ARIMA(2,1,0) model with constant, the ARIMA(0,2,1) model without constant, and the LES model: The three models perform nearly identically in the estimation period, and the ARIMA(2,1,0) model with constant appears slightly better than the other two in the validation period. On the basis of these statistical results alone, it would be hard to choose among the three models. However, if we plot the long-term forecasts made by the ARIMA(0,2,1) model without constant (which are essentially the same as those of the LES model), we see a significant difference from those of the earlier model: The forecasts have somewhat less of an upward trend than those of the earlier model--because the local trend near the end of the series is slightly less than the average trend over the whole series--but the confidence intervals widen much more rapidly. The model with two orders of differencing assumes that the trend in the series is time-varying, hence it considers the distant future to be much more uncertain than does the model with only one order of differencing. Which model should we choose That depends on the assumptions we are comfortable making with respect to the constancy of the trend in the data. The model with only one order of differencing assumes a constant average trend--it is essentially a fine-tuned random walk model with growth--and it therefore makes relatively conservative trend projections. It is also fairly optimistic about the accuracy with which it can forecast more than one period ahead. The model with two orders of differencing assumes a time-varying local trend--it is essentially a linear exponential smoothing model--and its trend projections are somewhat more more fickle. As a general rule in this kind of situation, I would recommend choosing the model with the lower order of differencing, other things being roughly equal. In practice, random-walk or simple-exponential-smoothing models often seem to work better than linear exponential smoothing models. Mixed models: In most cases, the best model turns out a model that uses either only AR terms or only MA terms, although in some cases a quotmixedquot model with both AR and MA terms may provide the best fit to the data. However, care must be exercised when fitting mixed models. It is possible for an AR term and an MA term to cancel each others effects . even though both may appear significant in the model (as judged by the t-statistics of their coefficients). Thus, for example, suppose that the quotcorrectquot model for a time series is an ARIMA(0,1,1) model, but instead you fit an ARIMA(1,1,2) model--i. e. you include one additional AR term and one additional MA term. Then the additional terms may end up appearing significant in the model, but internally they may be merely working against each other. The resulting parameter estimates may be ambiguous, and the parameter estimation process may take very many (e. g. more than 10) iterations to converge. Hence: Rule 8: It is possible for an AR term and an MA term to cancel each others effects, so if a mixed AR-MA model seems to fit the data, also try a model with one fewer AR term and one fewer MA term--particularly if the parameter estimates in the original model require more than 10 iterations to converge. For this reason, ARIMA models cannot be identified by quotbackward stepwisequot approach that includes both AR and MA terms. In other words, you cannot begin by including several terms of each kind and then throwing out the ones whose estimated coefficients are not significant. Instead, you normally follow a quotforward stepwisequot approach, adding terms of one kind or the other as indicated by the appearance of the ACF and PACF plots. Unit roots: If a series is grossly under - or overdifferenced--i. e. if a whole order of differencing needs to be added or cancelled, this is often signalled by a quotunit rootquot in the estimated AR or MA coefficients of the model. An AR(1) model is said to have a unit root if the estimated AR(1) coefficient is almost exactly equal to 1. (By quotexactly equal quot I really mean not significantly different from . in terms of the coefficients own standard error . ) When this happens, it means that the AR(1) term is precisely mimicking a first difference, in which case you should remove the AR(1) term and add an order of differencing instead. (This is exactly what would happen if you fitted an AR(1) model to the undifferenced UNITS series, as noted earlier.) In a higher-order AR model, a unit root exists in the AR part of the model if the sum of the AR coefficients is exactly equal to 1. In this case you should reduce the order of the AR term by 1 and add an order of differencing. A time series with a unit root in the AR coefficients is nonstationary --i. e. it needs a higher order of differencing. Rule 9: If there is a unit root in the AR part of the model--i. e. if the sum of the AR coefficients is almost exactly 1--you should reduce the number of AR terms by one and increase the order of differencing by one. Similarly, an MA(1) model is said to have a unit root if the estimated MA(1) coefficient is exactly equal to 1. When this happens, it means that the MA(1) term is exactly cancelling a first difference, in which case, you should remove the MA(1) term and also reduce the order of differencing by one. In a higher-order MA model, a unit root exists if the sum of the MA coefficients is exactly equal to 1. Rule 10: If there is a unit root in the MA part of the model--i. e. if the sum of the MA coefficients is almost exactly 1--you should reduce the number of MA terms by one and reduce the order of differencing by one. For example, if you fit a linear exponential smoothing model (an ARIMA(0,2,2) model) when a simple exponential smoothing model (an ARIMA(0,1,1) model) would have been sufficient, you may find that the sum of the two MA coefficients is very nearly equal to 1. By reducing the MA order and the order of differencing by one each, you obtain the more appropriate SES model. A forecasting model with a unit root in the estimated MA coefficients is said to be noninvertible . meaning that the residuals of the model cannot be considered as estimates of the quottruequot random noise that generated the time series. Another symptom of a unit root is that the forecasts of the model may quotblow upquot or otherwise behave bizarrely. If the time series plot of the longer-term forecasts of the model looks strange, you should check the estimated coefficients of your model for the presence of a unit root. Rule 11: If the long-term forecasts appear erratic or unstable, there may be a unit root in the AR or MA coefficients. None of these problems arose with the two models fitted here, because we were careful to start with plausible orders of differencing and appropriate numbers of AR and MA coefficients by studying the ACF and PACF models. More detailed discussions of unit roots and cancellation effects between AR and MA terms can be found in the Mathematical Structure of ARIMA Models handout. Time Series Analysis and Its Applications: With R Examples Code Used in the Text Examples The page uses JavaScript for syntax highlighting. Its not necessary to turn it on, but the code will be harder to read. Below is the code used for each numerical example in the text. This stuff wont work unless you have loaded astsa first. If this is your first time here, you might want to read the astsa package notes page for further information. The code for plots in the text were often shortened for the display (to save space). The actual code for all the graphs in the text can be found at GitHub. Click to expand or collapse section. Click - to collapse entire page. Or Expand Entire Page You dont have JavaScript enabled so these wont work for you. Chapter 1 Example 1.1 Example 1.2 Example 1.3 Example 1.4 Example 1.5 Example 1.6 Example 1.7 Example 1.9 Example 1.10 Example 1.11 Example 1.12 Example 1.24 Example 1.25 Example 1.26 Example 1.27 Example 1.28 Example 1.29 Example 1.30 Example 1.31 Chapter 2 Example 2.1 Example 2.2 Examples 2.3 Examples 2.4 and 2.5 Example 2.6 Example 2.7 Example 2.8 Example 2.9 Example 2.10 Example 2.11 Example 2.12 Example 2.13 Example 2.14 Example 2.15 Chapter 3 Example 3.2 Example 3.5 Example 3.7 Example 3.8 Example 3.11 Example 3.12 Example 3.16 Example 3.18 Example 3.25 Example 3.26 Example 3.28 Example 3.29 Example 3.31 Example 3.33 Example 3.36 Example 3.38 Example 3.39, 3.40, and 3.43 Example 3.41 Example 3.44 Example 3.45 Example 3.46 Example 3.47 Example 3.49 Chapter 4 Example 4.1 Example 4.2 Example 4.3 Examples 4.5, 4.6, 4.7 Example 4.10 Example 4.13 Example 4.14 Example 4.15 Example 4.16 Example 4.17 Example 4.18 Example 4.21 Example 4.22 Example 4.24 Example 4.25 Example 4.26 Chapter 5 Example 5.1 Example 5.1 redux Example 5.2 Example 5.3 Example 5.4 Example 5.5 and 5.6 Example 5.7 Example 5.8 and 5.9 Example 5.10 and 5.11 Example 5.12 Chapter 6 Example 6.1 Example 6.2 Example 6.5 Example 6.6 Example 6.7 Example 6.8 Example 6.9 Example 6.10 Example 6.12 Example 6.13 Example 6.14 Example 6.16 Example 6.17 Example 6.18 Example 6.22 Example 6.23 Example 6.24 Example 6.26 Chapter 7 Code in Introduction Example 7.1 Example 7.2 Example 7.5 Example 7.6 Example 7.7 Example 7.8 Example 7.9 Example 7.10 Example 7.11 Example 7.12 Example 7.13 Example 7.14 Example 7.16 Example 7.17

No comments:

Post a Comment