Download presentation

Presentation is loading. Please wait.

Published byJaqueline Finch Modified over 2 years ago

1
Using R for Time Series Analysis R is a package that can be downloaded for free

2
When R is opened

3
To read in data from a file: Type > sunData<-read.table("C:/Users/User/Desktop/Sunspot.txt",header=TRUE) The name of the data or table The file name and file path Read the variable names The following line causes the data to be printed > sunData Year no 1 1770 101 2 1771 82 3 1772 66 4 1773 35 95 1864 47 96 1865 30 97 1866 16 98 1867 7 99 1868 37 100 1869 74

4
To plot a scatter plot of the data type: > plot(sunData[,2]) or > plot(sunData[,”no”])

5
To plot a line graph of the data type: plot(sunData[,”no”],type = "l")

6
To plot a line graph of the data with “Year” along the horizontal axis type: plot(sunData[,”Year”],sunData[,”no”],type = "l")

7
To plot the autococorrelaton function of “no” type: > acf(sunData[,”no”])

8
To plot the autococorrelaton function of “no”, up to lag 60 type: > acf(sunData[,”no”],60)

9
To plot the partial autococorrelaton function of “no”, up to lag 60 type: > pacf(sunData[,”no”],60)

10
To fit and ARIMA model type: > arima(sunData[,2],order = c(2,0,0)) The output Call: arima(x = sunData[, "no"], order = c(2, 0, 0)) Coefficients: ar1 ar2 intercept 1.4087 -0.7137 48.2124 s.e. 0.0704 0.0700 4.9553 sigma^2 estimated as 227.2: log likelihood = -414.46, aic = 836.91

11
To fit and ARIMA model using a specific method type: > arima(sunData[,”no”],order = c(2,0,0), method ="ML") The output Call: arima(x = sunData[, "no"], order = c(2, 0, 0), method = "ML") Coefficients: ar1 ar2 intercept 1.4088 -0.7137 48.2095 s.e. 0.0704 0.0700 4.9557 sigma^2 estimated as 227.2: log likelihood = -414.46, aic = 836.91

12
The Methods: 1.“CSS-ML“ - minimize conditional sum-of- squares to find starting values then maximum likelihood (the default method) 2.“ML" - maximum likelihood 3.“CSS" - minimize conditional sum-of-squares

13
ARIMA modelling of a univariate time series. arima(x, order = c(0, 0, 0), seasonal = list(order = c(0, 0, 0), period = NA), xreg = NULL, include.mean = TRUE, transform.pars = TRUE, fixed = NULL, init = NULL, method = c("CSS-ML", "ML", "CSS"), n.cond, optim.method = "BFGS", optim.control = list(), kappa = 1e6)

14
Arguments x a univariate time series order A specification of the non-seasonal part of the ARIMA model: the three components (p, d, q) are the AR order, the degree of differencing, and the MA order. seasonal A specification of the seasonal part of the ARIMA model, plus the period (which defaults to frequency(x)). This should be a list with components order and period, but a specification of just a numeric vector of length 3 will be turned into a suitable list with the specification as the order. xreg Optionally, a vector or matrix of external regressors, which must have the same number of rows as x.

15
include.mean Should the ARMA model include a mean/intercept term? The default is TRUE for undifferenced series, and it is ignored for ARIMA models with differencing. transform.pars Logical. If true, the AR parameters are transformed to ensure that they remain in the region of stationarity. Not used for method = "CSS". fixed optional numeric vector of the same length as the total number of parameters. If supplied, only NA entries in fixed will be varied. transform.pars = TRUE will be overridden (with a warning) if any AR parameters are fixed. It may be wise to set transform.pars = FALSE when fixing MA parameters, especially near non-invertibility.

16
init optional numeric vector of initial parameter values. Missing values will be filled in, by zeroes except for regression coefficients. Values already specified in fixed will be ignored. method Fitting method: maximum likelihood or minimize conditional sum-of-squares. The default (unless there are missing values) is to use conditional-sum- of-squares to find starting values, then maximum likelihood. n.cond Only used if fitting by conditional-sum-of-squares: the number of initial observations to ignore. It will be ignored if less than the maximum lag of an AR term.

17
optim.method The value passed as the method argument to optim.optim optim.control List of control parameters for optim.optim kappa the prior variance (as a multiple of the innovations variance) for the past observations in a differenced model. Do not reduce this.

18
Autocovariance, Autocorrelation function. acf(x, lag.max = NULL, type = c("correlation", "covariance", "partial"), plot = TRUE, na.action = na.fail, demean = TRUE,...) Examples acf(arima(sunData[,”no”], 60, type = "covariance") produces the autocovariace function acf(arima(sunData[,”no”], 60, type = “partial") produces the partial autocorrelation function (same result as) pacf(arima(sunData[,”no”], 60)

19
Cross-covariance, Cross-correlation function. ccf(x, y, lag.max = NULL, type = c("correlation", "covariance"), plot = TRUE, na.action = na.fail,...) This R function plots the Cross Cross- covariance or the Cross-correlation function.

Similar presentations

OK

FINANCIAL TIME-SERIES ECONOMETRICS SUN LIJIAN Feb 23,2001.

FINANCIAL TIME-SERIES ECONOMETRICS SUN LIJIAN Feb 23,2001.

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google

Ppt on networking related topics to biochemistry Free download ppt on circles for class 9 Ppt on conservation and management of soil Ppt on world environment day 2017 Ppt on verb forms Ppt online open section Ppt on distribution transformer monitoring system Ppt on motivation and leadership Ppt on online crime file management in java Ppt on indian textile industries in indonesia