R for Data Analytics
Preface
Part I
1
What is R?
1.1
Why should we learn R?
1.2
Installing R and RStudio on Windows
1.3
RStudio GUI/IDE
1.4
Installing Packages
1.5
Getting Help
1.6
Task Views in R-Introduction & Installation
1.7
R core packages
1.8
Example-1 Hello R!
2
R Data Types and Data Structures
2.1
Data Types
2.1.1
Double
2.1.2
Integer
2.1.3
Logical
2.1.4
Character
2.1.5
Factor
2.1.6
Date & Time
2.2
Data Structures in R
2.2.1
Vector
2.2.2
Matrices
2.2.3
Arrays
2.2.4
Data Frames
2.2.5
Lists
2.3
Data Import/Export in R
2.3.1
Reading Data from a Text File
2.3.2
Reading Data from CSV files
2.3.3
Reading from Excel Files
2.3.4
Reading from Data Files from other Statistical Systems
2.3.5
Importing Data using RStudio
3
R Programming - Short Introduction
3.1
Programming Control Flow
3.1.1
if-else Conditional Statements
3.1.2
Loops
3.1.3
\(\mathtt{while}\)
loop
3.1.4
\(\mathtt{repeat}\)
loop
3.2
Functions in R
4
Data Exploration
4.1
Data Preprocessing
4.1.1
Extracting Data
4.1.2
Combining Data Frames
4.1.3
Sub setting and Logical Data Selection
4.2
Data Transformation from Wide to Long (or vice versa)
4.3
Summary Statistics
4.3.1
Example-Descriptive Statistics of Stock Returns
5
Graphics in R (Part-I)
5.1
Basic Plots in R
5.1.1
Scatter Plot
5.1.2
Line Plot
5.1.3
Bar Plot
5.1.4
Pie Chart
5.1.5
Scatter Plot
5.2
R Graphical Parameters
5.3
Introduction to ggplot2
5.3.1
\(\mathtt{qplot}\)
5.3.2
Layered graphics using
\(\mathtt{ggplot}\)
5.3.3
Arranging plots using gridExtra
6
Graphics in R (Part-II)
6.1
Interactive Plots using Plotly
6.2
Animation using gganimate
6.3
Plot Maps
Part II
7
Linear Regression
7.1
Investment
\(\beta\)
using R (Single Index Model)
7.2
Data preprocessing
7.3
Visualisation
7.4
Regression analysis using lm
8
Multiple Regression
8.1
Fama-French Three Factor Model
8.1.1
Data Preprocessing
8.1.2
Regression Analysis
8.1.3
Visualisation
9
Panel Regression
9.1
Fixed and Random effects using the
plm
package
9.2
Fixed Effects Model
9.3
Random Effects Model
9.4
Testing
9.4.1
Panel or OLS
9.4.2
Fixed Effect or Random Effect
10
Technical Analysis using R
10.1
Technical Analysis (TA) using R
10.2
Technical Charts
10.2.1
Candlesticks and OHLC chart
10.2.2
Line chart
10.2.3
Candlestick chart
10.2.4
Add technical indicators
10.2.5
Adding indicators sequentially
11
Forecasting VaR using GARCH Models
11.1
Value at Risk
11.2
Volatility Modelling & Forecasting using GARCH
11.3
GARCH(1,1) to forecast VaR
11.4
VaR forecasts using out of sample
12
Portfolio Modelling using R
12.1
Portfolio Analysis (Quick Intro)
12.2
Mean Variance Portfolio: Important concepts
Expected Return
Risk
Covariance of Returns
Correlation
Portfolio Return
Portfolio Risk
Portfolio Risk for
N
Assets
12.3
Diversification & Markowitz Minimum Variance Portfolio
12.4
Minimum Variance Portfolio
12.4.1
Efficient Weights for Two Assets
12.4.2
Portfolio with N Risky Assets
12.5
Using R to Construct Multi-Asset Portfolio
12.5.1
Data
12.5.2
Portfolios with random weights
12.6
Efficient (Minimum Variance) Portfolio using R packages
12.6.1
Minimum Variance and portfolio for a given level of return
12.6.2
Portfolio with Box Constraints
12.7
Evaluating Portfoios: Risk Adjusted Performance
12.7.1
Sharpe Ratio
12.7.2
Roy’s Safety Ratio
12.7.3
Treynor’s Ratio
12.7.4
Sharpe Ratio (Portfolio) in R
Part III
13
Machine Learning using R-Introduction to Data Splitting, Sampling & Resampling
13.1
Machine Learning Process (Quick Intro)
13.2
Data Splitting: Sampling
13.3
Random Sampling
13.3.1
Base R
13.3.2
Using the
caret
package
13.3.3
Using the
rsample
package
13.4
Stratified Sampling
13.5
Resampling
13.6
K-fold Cross Validation
K-fold CV in R
13.7
CV for time series data
CV for time series in R
13.8
Bootstrapping
Bootsrapping in R
14
Logistic Regression & K-Nearest Neighbour (kNN) for Classification
14.1
Logistic Regression
14.2
K-Nearest Neighbour
Nearest Neighbour classification (Quick Introduction)
k-NN Algorithm
14.3
Forecasting Stock Price Movement using ML
14.3.1
Data & Indicators
14.3.2
Visualise the data
14.3.3
Using Logistic Regression
14.3.4
Using K-NN
15
Decision Trees using R
15.1
Import Data and Pre-processing
15.2
Visualisation some features
15.3
Creating Training and Testing Set and Control
15.4
Train the model on the training set
15.5
Prediction and Accuracy
15.5.1
Model-1
15.5.2
Model-2
15.6
Feature Interpretation
15.7
Tree visualisation
16
Text Mining using R
16.1
Introduction to Text Mining
16.1.1
Text Data
16.1.2
Generic Text Mining System
16.1.3
Data pre-processing in Text Mining
16.2
Mining Twitter Text Data using R
16.2.1
Obtaining Twitter Data
16.3
Download Data
16.4
Data Pre-processing
16.5
Some Visualisation
16.6
Sentiment Analysis
16.6.1
Method
16.7
Topic Modelling
17
Work in Progress
References
R for Data Analytics
Topic 11
Forecasting VaR using GARCH Models