R in Finance and Economics
eBook - ePub

R in Finance and Economics

A Beginner's Guide

Abhay Kumar Singh, David Edmund Allen

Share book
  1. 264 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

R in Finance and Economics

A Beginner's Guide

Abhay Kumar Singh, David Edmund Allen

Book details
Book preview
Table of contents
Citations

About This Book

This book provides an introduction to the statistical software R and its application with an empirical approach in finance and economics. It is specifically targeted towards undergraduate and graduate students. It provides beginner-level introduction to R using RStudio and reproducible research examples. It will enable students to use R for data cleaning, data visualization and quantitative model building using statistical methods like linear regression, econometrics (GARCH etc), Copulas, etc. Moreover, the book demonstrates latest research methods with applications featuring linear regression, quantile regression, panel regression, econometrics, dependence modelling, etc. using a range of data sets and examples.

Frequently asked questions

How do I cancel my subscription?
Simply head over to the account section in settings and click on “Cancel Subscription” - it’s as simple as that. After you cancel, your membership will stay active for the remainder of the time you’ve paid for. Learn more here.
Can/how do I download books?
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
What is the difference between the pricing plans?
Both plans give you full access to the library and all of Perlego’s features. The only differences are the price and subscription period: With the annual plan you’ll save around 30% compared to 12 months on the monthly plan.
What is Perlego?
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Do you support text-to-speech?
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Is R in Finance and Economics an online PDF/ePUB?
Yes, you can access R in Finance and Economics by Abhay Kumar Singh, David Edmund Allen in PDF and/or ePUB format, as well as other popular books in Volkswirtschaftslehre & Statistik für Volks- & Betriebswirtschaft. We have over one million books available in our catalogue for you to explore.

Information

Chapter 1

Introduction

R is an open source software package and environment for statistical computing and graphics. The R language has received a lot of attention in the last five years or so particularly with its growing use by Statisticians and data miners for their empirical analysis and software development. R started as a freely available implementation of the S programming language. R was created by Ross Ihaka and Robert Gentleman, of the University of Auckland, New Zealand, and now, R is developed by the R Development Core Team. R can be considered as a different implementation of S. There are some important differences, but much code written for S runs unaltered under R.
The official R website http://www.r-project.org/ provides the best description and explanation for R. This section and the section following in the introduction to R are majorly adopted from the R website.
According to Wikipedia, “R is a free software programming language and a software environment for statistical computing and graphics. The R language is widely used among Statisticians and data miners for developing statistical software and data analysis. Polls and surveys of data miners suggest R’s popularity has increased substantially in recent years”.
By design, R provides the possibility of further computations (methods) on the results (objects) of a statistical procedure. Also the graphical capabilities of R facilitate methods as simple as plot (x, y) to very specific and fine control over the output. The fact that R is based on a formal computer language gives it tremendous flexibility. Other systems present simpler interfaces in terms of menus and forms, but often the apparent user-friendliness turns into a hindrance in the longer run.

1.1Why Should We Learn R?

The growth in the number of R users in recent years has indicated that researchers around the world are either using R or will use it at some point. There are several advantages to using R for statistical computing other than its open source and doesn’t cost anything. The benefits of R for an introductory student and instructors are
R is free.
R is open source and runs on UNIX, Windows and Macintosh, so it can be used on multiple platforms.
R has an excellent built-in help system and also various online help pages including mailing lists and boards.
R has excellent graphing capabilities which are customisable.
R’s language has a powerful, easy to learn syntax with many built-in statistical functions which are provided by default built-in packages.
R is a computer programming language. It is easier for programmers to learn it and its intuitive enough for beginners.
R provides specific functions bundled in user created packages for a particular field. This makes it easier for an applied researcher to use these functions rather than having to reinvent the wheel.
R follows a type inference coding structure which enables the automatic deduction of the type of an expression in R. For example, a string is identified as character and need not be explicitly declared before. R provides a wide variety of statistical and graphical techniques, including:
Linear and nonlinear modelling,
Univariate and multivariate statistics,
Classical statistical tests,
Time series analysis/econometrics,
Simulation and modelling,
Data mining-classification, clustering, etc.,
For computationally intensive tasks, C, C++, and Fortran code can be linked and called at run time.
R is easily extensible through functions and extensions, and the R community is noted for its active contributions in terms of packages. R has over 8000 packages with new packages added more frequently than any other statistical software. The R command below should run with an Internet connection. We will discuss how to setup proxy on work computers later.
image
Although R is available for Macintosh, Unix and Linux as well, we will use R on windows in this book. In most cases, the examples and codes in this text can be used for other operating system unaltered.
Other statistical packages, such as SPSS, GRETL and Minitab, provide point-and-click graphical-user interfaces (GUIs), but R is command-oriented. Although basic R is command/script based and provides a basic script editor, GUI capabilities can be added to the R interface using packages like Rcmdr. The R interface provides a basic GUI with a console to type commands and a script editor to write scripts. It also provides a few other functionalities like loading packages, clearing workspace, changing directory, etc. Users normally type commands at a command prompt in the console or as a script in the R script editor to get a desired output.
RStudio, an integrated development environment (IDE) (http://www.rstudio.com/ide/) is a powerful and productive user interface for R. RStudio provides various additional functionalities to the basic R interface which makes RStudio the choice of IDE in this book. We will now discuss how to get R and RStudio along with installing them on windows1 in the following subsections while providing more details about the R Environment.

1.2R: Getting Started

1.2.1Installing R on windows

The latest version of R can be downloaded from the CRAN page https://cloud.r-project.org/bin/windows/base/. CRAN is a network of ftp and web servers around the world which store identical, up-to-date versions of code and documentation for R. The list of available CRAN mirrors can be found at http://cran.r-project.org/mirrors.html. The page also provides some instructions and FAQs on R installation. The R-base is an executable package which can be easily installed on a windows machine with Administrative privileges. As stated earlier R comes with a basic GUI, which has a basic source code editor and a console window for command input.
image
Figure 1.1: R GUI (Windows)
The R GUI in windows looks like as shown in Figure 1.1.

1.2.2RStudio: A better way to run R

RStudio is an IDE and is a powerful and productive user interface for R. It is freely available, and works on Windows, Mac, and Linux. RStudio also comes in a server version that can be used to run R on a remote web server. In that case,...

Table of contents