Forecast: Forecasting Functions for Time Series and Linear Models

Total Page:16

File Type:pdf, Size:1020Kb

Forecast: Forecasting Functions for Time Series and Linear Models Package ‘forecast’ June 1, 2021 Version 8.15 Title Forecasting Functions for Time Series and Linear Models Description Methods and tools for displaying and analysing univariate time series forecasts including exponential smoothing via state space models and automatic ARIMA modelling. Depends R (>= 3.0.2), Imports colorspace, fracdiff, ggplot2 (>= 2.2.1), graphics, lmtest, magrittr, nnet, parallel, Rcpp (>= 0.11.0), stats, timeDate, tseries, urca, zoo Suggests forecTheta, knitr, methods, rmarkdown, rticles, seasonal, testthat, uroot LinkingTo Rcpp (>= 0.11.0), RcppArmadillo (>= 0.2.35) LazyData yes ByteCompile TRUE BugReports https://github.com/robjhyndman/forecast/issues License GPL-3 URL https://pkg.robjhyndman.com/forecast/, https://github.com/robjhyndman/forecast VignetteBuilder knitr Encoding UTF-8 RoxygenNote 7.1.1 NeedsCompilation yes Author Rob Hyndman [aut, cre, cph] (<https://orcid.org/0000-0002-2140-5352>), George Athanasopoulos [aut], Christoph Bergmeir [aut] (<https://orcid.org/0000-0002-3665-9021>), Gabriel Caceres [aut], Leanne Chhay [aut], Mitchell O'Hara-Wild [aut] (<https://orcid.org/0000-0001-6729-7695>), Fotios Petropoulos [aut] (<https://orcid.org/0000-0003-3039-4955>), Slava Razbash [aut], 1 2 R topics documented: Earo Wang [aut], Farah Yasmeen [aut] (<https://orcid.org/0000-0002-1479-5401>), R Core Team [ctb, cph], Ross Ihaka [ctb, cph], Daniel Reid [ctb], David Shaub [ctb], Yuan Tang [ctb] (<https://orcid.org/0000-0001-5243-233X>), Zhenyu Zhou [ctb] Maintainer Rob Hyndman <[email protected]> Repository CRAN Date/Publication 2021-06-01 11:20:12 UTC R topics documented: forecast-package . .4 accuracy . .4 Acf .............................................6 arfima . .9 Arima . 10 arima.errors . 13 arimaorder . 14 auto.arima . 14 autolayer . 18 autolayer.mts . 18 autoplot.acf . 20 autoplot.decomposed.ts . 22 autoplot.mforecast . 24 baggedModel . 25 bats ............................................. 27 bizdays . 29 bld.mbb.bootstrap . 30 BoxCox . 31 BoxCox.lambda . 32 checkresiduals . 33 croston . 34 CV.............................................. 36 CVar............................................. 37 dm.test . 38 dshw............................................. 40 easter . 42 ets.............................................. 43 findfrequency . 45 fitted.ARFIMA . 46 forecast . 48 forecast.baggedModel . 50 forecast.bats . 52 forecast.ets . 53 R topics documented: 3 forecast.fracdiff . 55 forecast.HoltWinters . 58 forecast.lm . 59 forecast.mlm . 61 forecast.modelAR . 63 forecast.mts . 65 forecast.nnetar . 67 forecast.stl . 70 forecast.StructTS . 73 fourier . 75 gas.............................................. 76 getResponse . 77 gghistogram . 78 gglagplot . 79 ggmonthplot . 81 ggseasonplot . 82 ggtsdisplay . 83 gold............................................. 85 is.acf . 86 is.constant . 86 is.forecast . 87 ma.............................................. 87 meanf . 88 modelAR . 90 monthdays . 92 mstl ............................................. 93 msts............................................. 94 na.interp . 95 ndiffs . 96 nnetar . 97 nsdiffs . 99 ocsb.test . 101 plot.Arima . 102 plot.bats . 104 plot.ets . 105 plot.forecast . 106 residuals.forecast . 109 rwf.............................................. 110 seasadj . 113 seasonal . 114 seasonaldummy . 115 ses.............................................. 116 simulate.ets . 119 sindexf . 122 splinef . 123 StatForecast . 125 subset.ts . 127 taylor . 129 4 accuracy tbats . 129 tbats.components . 131 thetaf . 132 tsclean . 134 tsCV............................................. 135 tslm ............................................. 136 tsoutliers . 138 wineind . 139 woolyrnq . 139 Index 140 forecast-package Forecasting Functions for Time Series and Linear Models Description Methods and tools for displaying and analysing univariate time series forecasts including exponen- tial smoothing via state space models and automatic ARIMA modelling. Details Package: forecast Type: Package License: GPL3 LazyLoad: yes Author(s) Rob J Hyndman Maintainer: [email protected] accuracy Accuracy measures for a forecast model Description Returns range of summary measures of the forecast accuracy. If x is provided, the function measures test set forecast accuracy based on x-f. If x is not provided, the function only produces training set accuracy measures of the forecasts based on f["x"]-fitted(f). All measures are defined and discussed in Hyndman and Koehler (2006). accuracy 5 Usage accuracy(object, ...) ## Default S3 method: accuracy(object, x, test =.
Recommended publications
  • Generalized Linear Models (Glms)
    San Jos´eState University Math 261A: Regression Theory & Methods Generalized Linear Models (GLMs) Dr. Guangliang Chen This lecture is based on the following textbook sections: • Chapter 13: 13.1 – 13.3 Outline of this presentation: • What is a GLM? • Logistic regression • Poisson regression Generalized Linear Models (GLMs) What is a GLM? In ordinary linear regression, we assume that the response is a linear function of the regressors plus Gaussian noise: 0 2 y = β0 + β1x1 + ··· + βkxk + ∼ N(x β, σ ) | {z } |{z} linear form x0β N(0,σ2) noise The model can be reformulate in terms of • distribution of the response: y | x ∼ N(µ, σ2), and • dependence of the mean on the predictors: µ = E(y | x) = x0β Dr. Guangliang Chen | Mathematics & Statistics, San Jos´e State University3/24 Generalized Linear Models (GLMs) beta=(1,2) 5 4 3 β0 + β1x b y 2 y 1 0 −1 0.0 0.2 0.4 0.6 0.8 1.0 x x Dr. Guangliang Chen | Mathematics & Statistics, San Jos´e State University4/24 Generalized Linear Models (GLMs) Generalized linear models (GLM) extend linear regression by allowing the response variable to have • a general distribution (with mean µ = E(y | x)) and • a mean that depends on the predictors through a link function g: That is, g(µ) = β0x or equivalently, µ = g−1(β0x) Dr. Guangliang Chen | Mathematics & Statistics, San Jos´e State University5/24 Generalized Linear Models (GLMs) In GLM, the response is typically assumed to have a distribution in the exponential family, which is a large class of probability distributions that have pdfs of the form f(x | θ) = a(x)b(θ) exp(c(θ) · T (x)), including • Normal - ordinary linear regression • Bernoulli - Logistic regression, modeling binary data • Binomial - Multinomial logistic regression, modeling general cate- gorical data • Poisson - Poisson regression, modeling count data • Exponential, Gamma - survival analysis Dr.
    [Show full text]
  • Evaluation of Several Error Measures Applied to the Sales Forecast System of Chemicals Supply Enterprises
    http://ijba.sciedupress.com International Journal of Business Administration Vol. 11, No. 4; 2020 Evaluation of Several Error Measures Applied to the Sales Forecast System of Chemicals Supply Enterprises Ma. del Rocío Castillo Estrada1, Marco Edgar Gómez Camarillo1, María Eva Sánchez Parraguirre1, Marco Edgar Gómez Castillo2, Efraín Meneses Juárez1 & M. Javier Cruz Gómez3 1 Facultad de Ciencias Básicas, Ingeniería y Tecnología, Universidad Autónoma de Tlaxcala, Mexico 2 Escuela de Graduados en Administración, Instituto Tecnológico y de Estudios Superiores de Monterrey, Mexico 3 Department of Chemical Engineering, Universidad Nacional Autónoma de México (UNAM), Coyoacán, México Correspondence: M. Javier Cruz Gómez, Full Professor, Department of Chemical Engineering, Universidad Nacional Autónoma de México (UNAM), Coyoacán, México. Tel: 52-55-5622-5359. Received: May 2, 2020 Accepted: June 12, 2020 Online Published: June 30, 2020 doi:10.5430/ijba.v11n4p39 URL: https://doi.org/10.5430/ijba.v11n4p39 Abstract The objective of the industry in general, and of the chemical industry in particular, is to satisfy consumer demand for products and the best way to satisfy it is to forecast future sales and plan its operations. Considering that the choice of the best sales forecast model will largely depend on the accuracy of the selected indicator (Tofallis, 2015), in this work, seven techniques are compared, in order to select the most appropriate, for quantifying the error presented by the sales forecast models. These error evaluation techniques are: Mean Percentage Error (MPE), Mean Square Error (MSE), Mean Absolute Error (MAE), Mean Absolute Percentage Error (MAPE), Mean Absolute Scaled Error (MASE), Symmetric Mean Absolute Percentage Error (SMAPE) and Mean Absolute Arctangent Percentage Error (MAAPE).
    [Show full text]
  • Another Look at Measures of Forecast Accuracy
    Another look at measures of forecast accuracy Rob J Hyndman Department of Econometrics and Business Statistics, Monash University, VIC 3800, Australia. Telephone: +61{3{9905{2358 Email: [email protected] Anne B Koehler Department of Decision Sciences & Management Information Systems Miami University Oxford, Ohio 45056, USA. Telephone: +1{513{529{4826 E-Mail: [email protected] 2 November 2005 1 Another look at measures of forecast accuracy Abstract: We discuss and compare measures of accuracy of univariate time series forecasts. The methods used in the M-competition and the M3-competition, and many of the measures recom- mended by previous authors on this topic, are found to be degenerate in commonly occurring situ- ations. Instead, we propose that the mean absolute scaled error become the standard measure for comparing forecast accuracy across multiple time series. Keywords: forecast accuracy, forecast evaluation, forecast error measures, M-competition, mean absolute scaled error. 2 Another look at measures of forecast accuracy 3 1 Introduction Many measures of forecast accuracy have been proposed in the past, and several authors have made recommendations about what should be used when comparing the accuracy of forecast methods applied to univariate time series data. It is our contention that many of these proposed measures of forecast accuracy are not generally applicable, can be infinite or undefined, and can produce misleading results. We provide our own recommendations of what should be used in empirical comparisons. In particular, we do not recommend the use of any of the measures that were used in the M-competition and the M3-competition.
    [Show full text]
  • How Prediction Statistics Can Help Us Cope When We Are Shaken, Scared and Irrational
    EGU21-15219 https://doi.org/10.5194/egusphere-egu21-15219 EGU General Assembly 2021 © Author(s) 2021. This work is distributed under the Creative Commons Attribution 4.0 License. How prediction statistics can help us cope when we are shaken, scared and irrational Yavor Kamer1, Shyam Nandan2, Stefan Hiemer1, Guy Ouillon3, and Didier Sornette4,5 1RichterX.com, Zürich, Switzerland 2Windeggstrasse 5, 8953 Dietikon, Zurich, Switzerland 3Lithophyse, Nice, France 4Department of Management,Technology and Economics, ETH Zürich, Zürich, Switzerland 5Institute of Risk Analysis, Prediction and Management (Risks-X), SUSTech, Shenzhen, China Nature is scary. You can be sitting at your home and next thing you know you are trapped under the ruble of your own house or sucked into a sinkhole. For millions of years we have been the figurines of this precarious scene and we have found our own ways of dealing with the anxiety. It is natural that we create and consume prophecies, conspiracies and false predictions. Information technologies amplify not only our rational but also irrational deeds. Social media algorithms, tuned to maximize attention, make sure that misinformation spreads much faster than its counterpart. What can we do to minimize the adverse effects of misinformation, especially in the case of earthquakes? One option could be to designate one authoritative institute, set up a big surveillance network and cancel or ban every source of misinformation before it spreads. This might have worked a few centuries ago but not in this day and age. Instead we propose a more inclusive option: embrace all voices and channel them into an actual, prospective earthquake prediction platform (Kamer et al.
    [Show full text]
  • Reliability Engineering: Trends, Strategies and Best Practices
    Reliability Engineering: Trends, Strategies and Best Practices WHITE PAPER September 2007 Predictive HCL’s Predictive Engineering encompasses the complete product life-cycle process, from concept to design to prototyping/testing, all the way to manufacturing. This helps in making decisions early Engineering in the design process, perfecting the product – thereby cutting down cycle time and costs, and Think. Design. Perfect! meeting set reliability and quality standards. Reliability Engineering: Trends, Strategies and Best Practices | September 2007 TABLE OF CONTENTS Abstract 3 Importance of reliability engineering in product industry 3 Current trends in reliability engineering 4 Reliability planning – an important task 5 Strength of reliability analysis 6 Is your reliability test plan optimized? 6 Challenges to overcome 7 Outsourcing of a reliability task 7 About HCL 10 © 2007, HCL Technologies. Reproduction Prohibited. This document is protected under Copyright by the Author, all rights reserved. Reliability Engineering: Trends, Strategies and Best Practices | September 2007 Abstract In reliability engineering, product industries now follow a conscious and planned approach to effectively address multiple issues related to product certification, failure returns, customer satisfaction, market competition and product lifecycle cost. Today, reliability professionals face new challenges posed by advanced and complex technology. Expertise and experience are necessary to provide an optimized solution meeting time and cost constraints associated with analysis and testing. In the changed scenario, the reliability approach has also become more objective and result oriented. This is well supported by analysis software. This paper discusses all associated issues including outsourcing of reliability tasks to a professional service provider as an alternate cost-effective option. Importance of reliability engineering in product industry The degree of importance given to the reliability of products varies depending on their criticality.
    [Show full text]
  • Prediction in Multilevel Generalized Linear Models
    J. R. Statist. Soc. A (2009) 172, Part 3, pp. 659–687 Prediction in multilevel generalized linear models Anders Skrondal Norwegian Institute of Public Health, Oslo, Norway and Sophia Rabe-Hesketh University of California, Berkeley, USA, and Institute of Education, London, UK [Received February 2008. Final revision October 2008] Summary. We discuss prediction of random effects and of expected responses in multilevel generalized linear models. Prediction of random effects is useful for instance in small area estimation and disease mapping, effectiveness studies and model diagnostics. Prediction of expected responses is useful for planning, model interpretation and diagnostics. For prediction of random effects, we concentrate on empirical Bayes prediction and discuss three different kinds of standard errors; the posterior standard deviation and the marginal prediction error standard deviation (comparative standard errors) and the marginal sampling standard devi- ation (diagnostic standard error). Analytical expressions are available only for linear models and are provided in an appendix. For other multilevel generalized linear models we present approximations and suggest using parametric bootstrapping to obtain standard errors. We also discuss prediction of expectations of responses or probabilities for a new unit in a hypotheti- cal cluster, or in a new (randomly sampled) cluster or in an existing cluster. The methods are implemented in gllamm and illustrated by applying them to survey data on reading proficiency of children nested in schools. Simulations are used to assess the performance of various pre- dictions and associated standard errors for logistic random-intercept models under a range of conditions. Keywords: Adaptive quadrature; Best linear unbiased predictor (BLUP); Comparative standard error; Diagnostic standard error; Empirical Bayes; Generalized linear mixed model; gllamm; Mean-squared error of prediction; Multilevel model; Posterior; Prediction; Random effects; Scoring 1.
    [Show full text]
  • A Philosophical Treatise of Universal Induction
    Entropy 2011, 13, 1076-1136; doi:10.3390/e13061076 OPEN ACCESS entropy ISSN 1099-4300 www.mdpi.com/journal/entropy Article A Philosophical Treatise of Universal Induction Samuel Rathmanner and Marcus Hutter ? Research School of Computer Science, Australian National University, Corner of North and Daley Road, Canberra ACT 0200, Australia ? Author to whom correspondence should be addressed; E-Mail: [email protected]. Received: 20 April 2011; in revised form: 24 May 2011 / Accepted: 27 May 2011 / Published: 3 June 2011 Abstract: Understanding inductive reasoning is a problem that has engaged mankind for thousands of years. This problem is relevant to a wide range of fields and is integral to the philosophy of science. It has been tackled by many great minds ranging from philosophers to scientists to mathematicians, and more recently computer scientists. In this article we argue the case for Solomonoff Induction, a formal inductive framework which combines algorithmic information theory with the Bayesian framework. Although it achieves excellent theoretical results and is based on solid philosophical foundations, the requisite technical knowledge necessary for understanding this framework has caused it to remain largely unknown and unappreciated in the wider scientific community. The main contribution of this article is to convey Solomonoff induction and its related concepts in a generally accessible form with the aim of bridging this current technical gap. In the process we examine the major historical contributions that have led to the formulation of Solomonoff Induction as well as criticisms of Solomonoff and induction in general. In particular we examine how Solomonoff induction addresses many issues that have plagued other inductive systems, such as the black ravens paradox and the confirmation problem, and compare this approach with other recent approaches.
    [Show full text]
  • Some Statistical Models for Prediction Jonathan Auerbach Submitted In
    Some Statistical Models for Prediction Jonathan Auerbach Submitted in partial fulfillment of the requirements for the degree of Doctor of Philosophy under the Executive Committee of the Graduate School of Arts and Sciences COLUMBIA UNIVERSITY 2020 © 2020 Jonathan Auerbach All Rights Reserved Abstract Some Statistical Models for Prediction Jonathan Auerbach This dissertation examines the use of statistical models for prediction. Examples are drawn from public policy and chosen because they represent pressing problems facing U.S. governments at the local, state, and federal level. The first five chapters provide examples where the perfunctory use of linear models, the prediction tool of choice in government, failed to produce reasonable predictions. Methodological flaws are identified, and more accurate models are proposed that draw on advances in statistics, data science, and machine learning. Chapter 1 examines skyscraper construction, where the normality assumption is violated and extreme value analysis is more appropriate. Chapters 2 and 3 examine presidential approval and voting (a leading measure of civic participation), where the non-collinearity assumption is violated and an index model is more appropriate. Chapter 4 examines changes in temperature sensitivity due to global warming, where the linearity assumption is violated and a first-hitting-time model is more appropriate. Chapter 5 examines the crime rate, where the independence assumption is violated and a block model is more appropriate. The last chapter provides an example where simple linear regression was overlooked as providing a sensible solution. Chapter 6 examines traffic fatalities, where the linear assumption provides a better predictor than the more popular non-linear probability model, logistic regression.
    [Show full text]
  • The Case of Astrology –
    The relation between paranormal beliefs and psychological traits: The case of Astrology – Brief report Antonis Koutsoumpis Department of Behavioral and Social Sciences, Vrije Universiteit Amsterdam Author Note Antonis Koutsoumpis ORCID: https://orcid.org/0000-0001-9242-4959 OSF data: https://osf.io/62yfj/?view_only=c6bf948a5f3e4f5a89ab9bdd8976a1e2 I have no conflicts of interest to disclose Correspondence concerning this article should be addressed to: De Boelelaan 1105, 1081HV Amsterdam, The Netherlands. Email: [email protected] The present manuscript briefly reports and makes public data collected in the spring of 2016 as part of my b-thesis at the University of Crete, Greece. The raw data, syntax, and the Greek translation of scales and tasks are publicly available at the OSF page of the project. An extended version of the manuscript (in Greek), is available upon request. To the best of my knowledge, this is the first public dataset on the astrological and paranormal beliefs in Greek population. Introduction The main goal of this work was to test the relation between Astrological Belief (AB) to a plethora of psychological constructs. To avoid a very long task, the study was divided into three separate studies independently (but simultaneously) released. Study 1 explored the relation between AB, Locus of Control, Optimism, and Openness to Experience. Study 2 tested two astrological hypotheses (the sun-sign and water-sign effects), and explored the relation between personality, AB, and zodiac signs. Study 3 explored the relation between AB and paranormal beliefs. Recruitment followed both a snowball procedure and it was also posted in social media groups of various Greek university departments.
    [Show full text]
  • Predictive Analytics
    Predictive Analytics L. Torgo [email protected] Faculdade de Ciências / LIAAD-INESC TEC, LA Universidade do Porto Dec, 2014 Introduction What is Prediction? Definition Prediction (forecasting) is the ability to anticipate the future. Prediction is possible if we assume that there is some regularity in what we observe, i.e. if the observed events are not random. Example Medical Diagnosis: given an historical record containing the symptoms observed in several patients and the respective diagnosis, try to forecast the correct diagnosis for a new patient for which we know the symptoms. © L.Torgo (FCUP - LIAAD / UP) Prediction Dec, 2014 2 / 240 Introduction Prediction Models Are obtained on the basis of the assumption that there is an unknown mechanism that maps the characteristics of the observations into conclusions/diagnoses. The goal of prediction models is to discover this mechanism. Going back to the medical diagnosis what we want is to know how symptoms influence the diagnosis. Have access to a data set with “examples” of this mapping, e.g. this patient had symptoms x; y; z and the conclusion was that he had disease p Try to obtain, using the available data, an approximation of the unknown function that maps the observation descriptors into the conclusions, i.e. Prediction = f (Descriptors) © L.Torgo (FCUP - LIAAD / UP) Prediction Dec, 2014 3 / 240 Introduction “Entities” involved in Predictive Modelling Descriptors of the observation: set of variables that describe the properties (features, attributes) of the cases in the data set Target variable: what we want to predict/conclude regards the observations The goal is to obtain an approximation of the function Y = f (X1; X;2 ; ··· ; Xp), where Y is the target variable and X1; X;2 ; ··· ; Xp the variables describing the characteristics of the cases.
    [Show full text]
  • A Note on the Mean Absolute Scaled Error
    View metadata, citation and similar papers at core.ac.uk brought to you by CORE provided by Erasmus University Digital Repository A note on the Mean Absolute Scaled Error Philip Hans Franses Econometric Institute Erasmus School of Economics Abstract Hyndman and Koehler (2006) recommend that the Mean Absolute Scaled Error (MASE) becomes the standard when comparing forecast accuracy. This note supports their claim by showing that the MASE nicely fits within the standard statistical procedures to test equal forecast accuracy initiated in Diebold and Mariano (1995). Various other criteria do not fit as they do not imply the relevant moment properties, and this is illustrated in some simulation experiments. Keywords: Forecast accuracy, Forecast error measures, Statistical testing This revised version: February 2015 Address for correspondence: Econometric Institute, Erasmus School of Economics, POB 1738, NL-3000 DR Rotterdam, the Netherlands, [email protected] Thanks to the Editor, an anonymous Associate Editor and an anonymous reviewer for helpful comments and to Victor Hoornweg for excellent research assistance. 1 Introduction Consider the case where an analyst has two competing one-step-ahead forecasts for a time series variable , namely , and , , for a sample = 1,2, . , . The forecasts bring along the forecast errors , and� 1 , , respectively.�2 To examine which of the two sets of forecasts provides most accuracy, the1̂ analyst2̂ can use criteria based on some average or median of loss functions of the forecast errors. Well-known examples are the Root Mean Squared Error (RMSE) or the Median Absolute Error (MAE), see Hyndman and Koehler (2006) for an exhaustive list of criteria and see also Table 1 below.
    [Show full text]
  • Prediction in General Relativity
    Synthese (2017) 194:491–509 DOI 10.1007/s11229-015-0954-3 ORIGINAL RESEARCH Prediction in general relativity C. D. McCoy1 Received: 2 July 2015 / Accepted: 17 October 2015 / Published online: 27 October 2015 © Springer Science+Business Media Dordrecht 2015 Abstract Several authors have claimed that prediction is essentially impossible in the general theory of relativity, the case being particularly strong, it is said, when one fully considers the epistemic predicament of the observer. Each of these claims rests on the support of an underdetermination argument and a particular interpretation of the concept of prediction. I argue that these underdetermination arguments fail and depend on an implausible explication of prediction in the theory. The technical results adduced in these arguments can be related to certain epistemic issues, but can only be misleadingly or mistakenly characterized as related to prediction. Keywords Prediction · General theory of relativity · Theory interpretation · Global spacetime structure 1 Introduction Several authors have investigated the subject of prediction in the general theory of relativity (GTR), arguing on the strength of various technical results that making predictions is essentially impossible for observers in the spacetimes permitted by the theory (Geroch 1977; Hogarth 1993, 1997; Earman 1995; Manchak 2008). On the face of it, such claims seem to be in significant tension with the important successful predictions made on the theoretical basis of GTR. The famous experimental predictions of the precession of the perihelion of Mercury and of gravitational lensing, for example, are widely understood as playing a significant role in the confirmation of the theory (Brush 1999). Well-known relativist Clifford Will observes furthermore that “today, B C.
    [Show full text]