Вы находитесь на странице: 1из 3

Lab 1

Installing R
'

Learning Outcomes

Downloading R and relevant packages, Installing R and packages, Getting familiar with R, nding help les
&

Using tsdisplay to visualise time series.

1. R is a free software that you can download at http://cran.r-project.org/. Download the last version of R for your operating system (windows is assumed to be used here). 2. Once you have downloaded the install le (e.g. R-2.14.2-win.exe), double click on it to start the installation. You are going to be asked where to install the application: Dont install R on C: as it will be deleted from the computer in TCD labs each time your log out. Instead install it on your own space on the network ( U: ) or alternatively on your own USB key. 3. Once you have completed the installation, the R application to use is called Rgui.exe (GUI stands for Graphical User Interface) and it is located in the directory where you have installed R e.g.:

..\R\R-2.14.2\bin\i386\Rgui.exe
Figure 1.1 shows the Rgui application, note the menu at the top and the window R Console. 4. By default, the package stats is installed and it has some functionalities for time series analysis. In the R console, look for help about this package (using the symbol ?) as follow

> ? stats
A webpage is opening automatically describing briey the package. Click on the link index at the bottom of the webpage: another webpage is opening with a list of all functions available in the stats package. Similarly explore the package datasets also installed by default in R. 5. ldeaths is a time series available in the package datasets. Consult the help les to nd out what it is representing. 2

Figure 1.1: Application Rgui.exe 6. Visualise the values of ldeaths:

> ldeaths
Plot the time series ldeaths:

> plot(ldeaths)
What are the patterns appearing in this time series? 7. Note the function acf (and pacf ). Plot the acf of ldeaths and use the help le to understand the numbers plotted on the x-axis. 8. We want to use the package fma that is not installed by default. Go to http://cran.r-project.org/ and select Packages on the left menu. Then select Table of available packages, sorted by name (a list of packages are listed). Find fma and open its page (see gure 1.2). Download the windows binary in zip le and save it on your personal space (e.g. U: or USB drive). Do not unpack the zip. 9. To install fma package in R, go to Rgui, select Packages in the top menu and Install package(s) from local zip le. Select the fma_2.00.zip that you have just saved on your PC.

Figure 1.2: fma package webpage. 10. Once fma is installed, you should load it in the R console:

> require(fma)
an error message should appear stating that a package is missing. The fma package depends on other packages (see gure 1.2) like tseries and forecast that also needs to be installed. Install all the packages required until you have no more error message when loading fma package. 11. Once fma is loaded, you should have access to time series used in class such as beer, airpass, etc. :

> beer
Look for the help le for fma and see all the time series available in it. 12. Try the command tsdisplay e.g.

> tsdisplay(beer)
spot the differences with acf and pacf functions. Explore parameters in tsdisplay such as lag.max.

Вам также может понравиться