Esittely latautuu. Ole hyvä ja odota

Esittely latautuu. Ole hyvä ja odota

R ja QRMlib-kirjasto Anssi Käki 7.9.2011 Työn saa tallentaa ja julkistaa Aalto-yliopiston avoimilla verkkosivuilla. Muilta osin kaikki oikeudet pidätetään.

Samankaltaiset esitykset


Esitys aiheesta: "R ja QRMlib-kirjasto Anssi Käki 7.9.2011 Työn saa tallentaa ja julkistaa Aalto-yliopiston avoimilla verkkosivuilla. Muilta osin kaikki oikeudet pidätetään."— Esityksen transkriptio:

1 R ja QRMlib-kirjasto Anssi Käki 7.9.2011 Työn saa tallentaa ja julkistaa Aalto-yliopiston avoimilla verkkosivuilla. Muilta osin kaikki oikeudet pidätetään.

2 R-asennus 1.Install R (version 2-13.1), use root folder instead of "Program files". In these instructions, it is assumed that the home folder is C:\R\R-2.13.1\. Modify, if necessary. 2.Using My Computer or Explorer test for the existence of the folder C:\R\R-2.13.1\Users. If ‘Users’ folder does NOT EXIST, create it. Each separate project should be built in a subfolder of the ‘Users’ folder. Next create a ‘QRMBook’ subfolder beneath the ‘Users’ subfolder. You should now have a folder C:\R\R- 2.13.1\Users\QRMBook which you will use only for running code from the QRMlib package. 3.Right-click the desktop and choose New | Shortcut from the menu. 4.Copy the following line into your clipboard: C:\R\R-2.13.1\bin\i386\Rgui.exe and paste the line into the box labeled “Type the location of the item”. 5.Click the Next button. 6.Type QRMBook into the box labeled “Type a name of this shortcut”. Then click the Finish button. 7.Find the shortcut you just created on your desktop. It will be labeled “QRMBook”. Right-click the icon for the shortcut and choose ‘Properties’. 8.The ‘Start in’ box says C:\Program Files\R\R-2.10.0\bin. Modify it to read C:\R\R-2.13.1\Users\QRMBook Then click OK. 9.Test the shortcut to open R. Use command getwd() to verify that workspace is …/Users/QRMBook.

3 QRMlib-asennus 1.Start R. 2.Select Packages/Install Packages. 3.Choose some mirror server, e.g. Sweden, then select QRMlib from the list and click OK. 4.After a successful installation, there should be a folder QRMlib under...\R-2.13.1\library 5.Copy file.Rprofile from QRMlib (or, if not there, check QRMlib\Chap2 folder) to QRMBook folder => this will make QRMlib to be loaded automatically, when you run R in the QRMBook workspace. It is also possible to manually load QRMlib in R with command ‘library(QRMlib)’ 6.Copy also folders Chap2...8 to QRMBook folder. These folders contain scripts for different chapters in the book. In all exercises, modify the versions in the QRMBook folder, not the originals. 7.Data that is provided with the book is located at...\R-2.13.1\library\QRMlib\data. To load a particular dataset (e.g., sp500), use command 'data (sp500)' in R 8.To test, open script (File/Open script…) S1-ReturnDistributions.R under folder Chap2. 9.In the script windows, press Ctrl-A (to select all) and Ctrl-R (to run selection). Script should run, resulting in numerical outputs and few graphs. 10.When you close R, you can choose to save the workspace with the all loaded datasets, so there's no need to reload them later. (Select only folder QRMBook, workspace is automatically saved to.Rdata file)

4 Dokumentaatio •Kurssin kotisivuilta saat käyttöösi seuraavat dokumentit: –Geneerinen R:n käyttöopas: An introduction to R. Notes on R: A Programming Environment for Data Analysis and Graphics. (W. N. Venables, D. M. Smith and the R Development Core Team) –QRM-kirjaston kuvaus: QRMlib. Documentation of the R-language code to investigate concepts in a Quantitative Risk Management book. (S-Plus Original by Alexander McNeil; R-language port by Scott Ulman) •Jos edellä annetut ohjeet ja ym. opukset eivät riitä R:n ja QRMlib:n asennukseen, ota yhteys assisstenttiin!

5 Kotitehtävä 1.Suorita testisessio R:ssä liitteen A mukaisesti (kts. ”An Introduction to R”, s. 78-80). 2.Kirjoita R-skripti, joka: a)Generoi kaksi pistejoukkoa (n=100): 1.y1=x+ ɛ 1, missä x=[1,…,100] ja ɛ 1 ~N(10,20) 2.y2=2x+ ɛ 2, missä x=[1,…,100] ja ɛ 1 ~N(10,10) b)Sovittaa lineaariset regressiosuorat pistejoukkoihin c)Generoi viereisen kuvaajan. 3.Raportoi kohta 2. kirjallisesti (skripti ja kuvaaja riittävät)


Lataa ppt "R ja QRMlib-kirjasto Anssi Käki 7.9.2011 Työn saa tallentaa ja julkistaa Aalto-yliopiston avoimilla verkkosivuilla. Muilta osin kaikki oikeudet pidätetään."

Samankaltaiset esitykset


Iklan oleh Google