In this set of exercises we shall practice the functions for network statistics, using package igraph.If you don’t have package already installed, install it using the following code: install.packages(“igraph”) and load it into the session using the following code: library(“igraph”) before proceeding. You can find more info about the package and graphs in general here […]

## Network Analysis Part 2 Solutions

Below are the solutions to these exercises, Network Analysis Part 2. #################### # # # Exercise 1 # # # #################### d <- read.csv("sociogram-employees-un.csv", header=FALSE) g <- graph.adjacency(as.matrix(d), mode="directed") V(g)$name <- LETTERS[1:NCOL(d)] V(g)$color <- "yellow" V(g)$shape <- "sphere" E(g)$color <- "gray" E(g)$arrow.size <- 0.2 #################### # # # Exercise 2 # # # #################### plot(g) […]

## Network Analysis Part 1 Exercises

In this set of exercises we shall create an empty graph and practice the functions for basic manipulation with vertices and edges, using the package igraph. If you don’t have the package already installed, install it using the following code: install.packages(“igraph”) and load it into the session using the following code: library(“igraph”) before proceeding. You […]

## Network Analysis Part 1 Solutions

Below are the solutions to these exercises on analysing networks. #################### # # # Exercise 1 # # # #################### g <- make_empty_graph(n=5, directed=TRUE) V(g)$color = "yellow" V(g)$shape = "sphere" #################### # # # Exercise 2 # # # #################### g <- add.edges(g, c(1,2, 1,3, 2,4, 3,4, 4,5)) #################### # # # Exercise 3 # […]

## Fundamental and Technical Analysis of Shares Exercises

In this set of exercises we shall explore possibilities for fundamental and technical analysis of stocks offered by the quantmod package. If you don’t have the package already installed, install it using the following code: install.packages(“quantmod”) and load it into the session using the following code: library(“quantmod”) before proceeding. Answers to the exercises are available […]

## Fundamental and Technical Analysis of Shares Solutions

Below are the solutions to these exercises on Fundamental and Technical analysis of shares exercises. #################### # # # Exercise 1 # # # #################### # rata fb.p <- getSymbols("FB", env=NULL) #################### # # # Exercise 2 # # # #################### Cl(to.monthly(fb.p["2015::2015-12-31"])) ## Warning: timezone of object (UTC) is different than current timezone (). ## […]

## Using MANOVA to Analyse a Banking Crisis Exercises

In this set of exercises we will practice multivariate analysis of variance – MANOVA. We shall try to find if there is a difference in the combination of export and bank reserves, depending on the status of banking sector (is there a crisis or not). The data set is fictitious and servers for education purposes […]

## Using MANOVA to analyse banking crises solutions

Below are the solutions to these exercises on Using MANOVA to analyse banking crises. #################### # # # Exercise 1 # # # #################### # read data data <- read.csv("http://r-exercises.com/wp-content/uploads/2016/08/banking-crises-data.csv", sep=",", header=TRUE) aggregate(. ~ crisis, data = data, FUN=function(x){sum(!is.na(x))}, na.action = na.pass) ## crisis export reserves ## 1 No 67 67 ## 2 Yes 12 […]

## Stock Prices Analysis part 3 – Exercises

This is the third and the final part of the exercises dedicated to analysis of stock prices. In this part we will provide exercises for testing the type of distribution of stock prices and analysing and predicting stock prices using ARIMA models. You dont need to be an expert stock’s trader in order to understand […]

## Stock Prices Analysis – part 3 Solutions

Below are the solutions to these exercises on Analysis of stock prices – part 3. # read data data <- read.csv(“http://r-exercises.com/wp-content/uploads/2016/07/data.csv”, sep=”,”, header=TRUE) # data frame from exercise 6, part 1 data.close <- reshape(data[c(“Symbol”, “Date”, “Close”)], timevar=”Symbol”, idvar=”Date”, direction=”wide”) colnames(data.close) <- c(“Date”, as.character(unique(data$Symbol))) data.close$Date <- as.Date(data.close$Date) data.close <- data.close[with(data.close, order(Date)), ] library(“tseries”) library(“forecast”) #################### # […]