Try out NAG Library functions
Explore NAG maths and stats routines with interactive demos
Univariate time series, seasonal and non-seasonal differencing
differencing, time series | non-seasonal differencing | seasonal differencing | time series | univariate time series
This example reads in a set of data consisting of observations from a time series. Non-seasonal differencing of order and seasonal differencing of order (with seasonality of ) are applied to the input data, giving an output array holding differenced values and values which can be used to reconstitute the output array.
Program g13aafe ! G13AAF Example Program Text ! Mark 26 Release. NAG Copyright 2016. ! .. Use Statements .. Use nag_library, Only: g13aaf, nag_wp ! .. Implicit None Statement .. Implicit None ! .. Parameters .. Integer, Parameter :: nin = 5, nout = 6 ! .. Local Scalars .. Integer :: ifail, nd, nds, ns, nx, nxd ! .. Local Arrays .. Real (Kind=nag_wp), Allocatable :: x(:), xd(:) ! .. Executable Statements .. Write (nout,*) 'G13AAF Example Program Results' Write (nout,*) ! Skip heading in data file Read (nin,*) ! Read in the problem size Read (nin,*) nx, nd, nds, ns Allocate (x(nx),xd(nx)) ! Read in data Read (nin,*) x(1:nx) ! Perform differencing ifail = 0 Call g13aaf(x,nx,nd,nds,ns,xd,nxd,ifail) ! Display results Write (nout,99999) 'Non-seasonal differencing of order ', nd, & ' and seasonal differencing' Write (nout,99999) 'of order ', nds, ' with seasonality ', ns, & ' are applied' Write (nout,*) Write (nout,99998) 'The output array holds ', nx, & ' values, of which the first ', nxd, ' are differenced values' Write (nout,*) Write (nout,99997) xd(1:nx) 99999 Format (1X,A,I1,A,I1,A) 99998 Format (1X,A,I2,A,I2,A) 99997 Format (1X,5F9.1) End Program g13aafe