Time Series Analysis AMS 316



Similar documents
Viewing Ecological data using R graphics

Time Series Analysis with R - Part I. Walter Zucchini, Oleg Nenadić

How To Use R On A Pc Or Mac Or Macbook Or Macintosh (Windows) With A Microsoft Macbook (Windows Or Mac) With An Ipa (Windows/Apple) With R (Windows 2) With The Powerup)

Tutorial 3: Graphics and Exploratory Data Analysis in R Jason Pienaar and Tom Miller

Graphics in R. Biostatistics 615/815

Each function call carries out a single task associated with drawing the graph.

5 Correlation and Data Exploration

R Language Fundamentals

GETTING STARTED WITH R AND DATA ANALYSIS

# load in the files containing the methyaltion data and the source # code containing the SSRPMM functions

Lecture 2: Exploratory Data Analysis with R

Introduction to R and UNIX Working with microarray data in a multi-user environment

Introduction to R software for statistical computing

Getting started with qplot

Visualizing Data. Contents. 1 Visualizing Data. Anthony Tanbakuchi Department of Mathematics Pima Community College. Introductory Statistics Lectures

Package survpresmooth

Statistical Models in R

Importing Data into R

Lecture 5 : The Poisson Distribution

4 Other useful features on the course web page. 5 Accessing SAS

sample median Sample quartiles sample deciles sample quantiles sample percentiles Exercise 1 five number summary # Create and view a sorted

R Graphics II: Graphics for Exploratory Data Analysis

business statistics using Excel OXFORD UNIVERSITY PRESS Glyn Davis & Branko Pecar

Cluster Analysis using R

Lab 13: Logistic Regression

OVERVIEW OF R SOFTWARE AND PRACTICAL EXERCISE

Introduction to R and Exploratory data analysis

Data Visualization with R Language

R Graphics Cookbook. Chang O'REILLY. Winston. Tokyo. Beijing Cambridge. Farnham Koln Sebastopol

Data exploration with Microsoft Excel: univariate analysis

Diagrams and Graphs of Statistical Data

Business Statistics. Successful completion of Introductory and/or Intermediate Algebra courses is recommended before taking Business Statistics.

Computational Assignment 4: Discriminant Analysis

SECTION 2-1: OVERVIEW SECTION 2-2: FREQUENCY DISTRIBUTIONS

KSTAT MINI-MANUAL. Decision Sciences 434 Kellogg Graduate School of Management

Microsoft Excel. Qi Wei

Week 5: Multiple Linear Regression

A short course in Longitudinal Data Analysis ESRC Research Methods and Short Course Material for Practicals with the joiner package.

An introduction to using Microsoft Excel for quantitative data analysis

Getting started manual

Using R for Windows and Macintosh

Financial Econometrics MFE MATLAB Introduction. Kevin Sheppard University of Oxford

Data analysis and regression in Stata

Module 3: Correlation and Covariance

An Introduction to R. W. N. Venables, D. M. Smith and the R Core Team

Lecture 2: Descriptive Statistics and Exploratory Data Analysis

Psychology 205: Research Methods in Psychology

A Handbook of Statistical Analyses Using R. Brian S. Everitt and Torsten Hothorn

Bowerman, O'Connell, Aitken Schermer, & Adcock, Business Statistics in Practice, Canadian edition

Course Text. Required Computing Software. Course Description. Course Objectives. StraighterLine. Business Statistics

Directions for using SPSS

Financial Risk Models in R: Factor Models for Asset Returns. Workshop Overview

SPSS 12 Data Analysis Basics Linda E. Lucek, Ed.D

Chapter 1. Return Calculations. 1.1 The Time Value of Money Future value, present value and simple interest.

Exercise 1.12 (Pg )

Step 3: Go to Column C. Use the function AVERAGE to calculate the mean values of n = 5. Column C is the column of the means.

Package smoothhr. November 9, 2015

Engineering Problem Solving and Excel. EGN 1006 Introduction to Engineering

Module 2 Basic Data Management, Graphs, and Log-Files

Package polynom. R topics documented: June 24, Version 1.3-8

Data analysis process

Based on Chapter 11, Excel 2007 Dashboards & Reports (Alexander) and Create Dynamic Charts in Microsoft Office Excel 2007 and Beyond (Scheck)

Forecasting in STATA: Tools and Tricks

An Introduction to R. W. N. Venables, D. M. Smith and the R Core Team

Introduction to Microsoft Excel 2007/2010

A Handbook of Statistical Analyses Using R. Brian S. Everitt and Torsten Hothorn

A Short Guide to R with RStudio

Regression and Programming in R. Anja Bråthen Kristoffersen Biomedical Research Group

How long is the vector? >> length(x) >> d=size(x) % What are the entries in the matrix d?

Statistical Analysis with R

2015 Workshops for Professors

Prof. Nicolai Meinshausen Regression FS R Exercises

STATISTICAL ANALYSIS WITH EXCEL COURSE OUTLINE

Exploratory Data Analysis

Data Mining with R: learning by case studies

Bill Burton Albert Einstein College of Medicine April 28, 2014 EERS: Managing the Tension Between Rigor and Resources 1

FORECASTING. Operations Management

Why Taking This Course? Course Introduction, Descriptive Statistics and Data Visualization. Learning Goals. GENOME 560, Spring 2012

WESTMORELAND COUNTY PUBLIC SCHOOLS Integrated Instructional Pacing Guide and Checklist Computer Math

INSTRUCTOR HELP & WALKTHROUGH

Big Data and Scripting. Plotting in R

Table of Useful R commands

The R Environment. A high-level overview. Deepayan Sarkar. 22 July Indian Statistical Institute, Delhi

What is R? R s Advantages R s Disadvantages Installing and Maintaining R Ways of Running R An Example Program Where to Learn More

An Introduction to the Use of R for Clinical Research

"Excel with Excel 2013: Pivoting with Pivot Tables" by Venu Gopalakrishna Remani. October 28, 2014

An introduction to the analysis of extreme values using R and extremes

Kaspersky Security Center Web-Console

Descriptive statistics parameters: Measures of centrality

Quickstart for Desktop Version

9th Russian Summer School in Information Retrieval Big Data Analytics with R

Transcription:

Time Series Analysis AMS 316

Programming language and software environment for data manipulation, calculation and graphical display. Originally created by Ross Ihaka and Robert Gentleman at University of Auckland, and now developed by the R Development Core Team.

IT IS FREE Pre-compiled binary versions are provided for Microsoft Windows, Mac OS X, and several other Linux/Unix-like operating systems Open source code available freely available on GNU General Public License For computationally-intensive tasks, C, C++ and Fortran code can be linked and called at run time An effective data handling and storage facility A suite of operators for calculations on arrays, in particular matrices A large, coherent, integrated collection of intermediate tools for data analysis Graphical facilities for data analysis and display either directly at the computer or on hardcopy

>help.start()

> help(solve) // get more information on solve >?solve > help( [[ ) // help for special characters and if, for > help.start() // launch a Web browser

1. R is case sensitive. 2. Commands can be executed by calling an external file. > source( commands.r ) 3. The following functions can be used to display the names of (most of) the objects which are currently stored within R. > objects() > ls() 4. Objects can be removed by the following function. > rm(x, y, z)

1. Vectors and asignments > x<- c(10.4, 5.6, 4.1) > assign( x, c(10.4, 5.6, 4.1) ) > y <- c(x, 0, 1/x) 2. Vector arithmetic > v<-2*x + y +1 > sum( (x-mean(x))^2/length(x)-1) > sort(x) // returns a vector of the same size as x // with the elements arranged in increasing order. > max(x) > min(x) 3. Sequence generation > z <- seq(-5, 5, by=0.2) > z <- rep(x, times=5)

File types that can be imported into R:.data,.txt,.xls,.xlsx,.html,.xml, etc. Example of importing text files into R: data<-read.table( C:/ /data.txt, header=true, sep= \t ) Other data import commands: scan() For data import/export: http://cran.r-project.org/doc/manuals/r-data.html

Writing your own functions

attach(dummy) //Make the columns in the data frame visible as variables// lrf <- lowess(x, y) //Make a nonparametric local regression function// plot(x, y) //Standard point plot// lines(x, lrf$y) //Add in the local regression// abline(0, 1, lty=3) //The true regression line: (intercept 0, slope 1)// abline(coef(fm)) //Unweighted regression line// abline(coef(fm1), col = "red") //Weighted regression line// detach() //Remove data frame from the search path// plot(fitted(fm), resid(fm), xlab="fitted values", ylab="residuals", main="residuals vs Fitted") /*A standard regression diagnostic plot to check for qqnorm(resid(fm), main="residuals Rankit Plot") /*A normal scores plot to check for skewness, kurtosis and rm(fm, fm1, lrf, x, dummy) //Clean up again//

Plot Types: Line Charts, Bar Charts, Histograms, Pie Charts, Dot Charts, etc. Format: >PLOT-TYPE(PLOT-DATA, DETAILS) PLOT-TYPE: plot, plot.xy, barplot, pie, dotchart, etc. PLOT-DATA: Data, Data$XXX, as.matrix(data), etc. Details: axes, col, pch, lty, ylim, type, xlab, ylab, etc. For graphics plot: http://www.harding.edu/fmccown/r/

A comparison of GM monthly returns & SP500 monthly returns. GM and SP500 monthly return data during the period of Jan. 2002 to Jun. 2007 are taken. Plotted in R, they will be analyzed and compared. Data from: http://www.stanford.edu/~xing/ statfinbook/data.html

GM<-read.table("C:/R Data/GM.txt", header=true, sep= ") SP<-read.table("C:/R Data/SP.txt", header=true, sep="") plot(gm) lines(gm$logret, lty=1) lines(sp$logret, type="o", lty=1, pch="+", col="red") x<-1:66 GML<-lm(GM$logret~x) SPL<-lm(SP$logret~x) abline(coef(gml), type="h", lwd=3) abline(coef(spl), col="red", type="h", lwd=3)

Introduction to packages All R functions and datasets are stored in packages. Only when a package is loaded are its contents available. This is down both for efficiency, and to aid package developers. To see which packages are installed at your site, issue the command >library(boot) Users connected to the Internet can use install.packages() and update.packages() to install and update packages. To see packages currently loaded, use search().

An easier way: use TS functions to plot time series. US unemployment rate from 1987 to 2007 are taken as a time series for analysis. Data from http://www.stanford.edu/~xing/statfinbook/data.html

2004~2006 1948~2007

An easier way: use TS functions to plot time series. US unemployment rate from 1987 to 2007 are taken as a time series for analysis. Data from http://www.stanford.edu/~xing/statfinbook/data.html