These are the commands given, basically:
library(psych)
library(readxl)
library(minqa)
library(car)
COMDINHEIRO_UFESpro_capm <- read_excel("COMDINHEIRO_UFESpro_capm.xlsx")
View(COMDINHEIRO_UFESpro_capm)
setwd("C:/Users/Rodolfo Fabriz.ESCRAVo/Desktop/Rodolfo/Mestrado/Econometria")
COMDINHEIRO_UFESpro_capm <- read_excel("COMDINHEIRO_UFESpro_capm.xlsx")
View(COMDINHEIRO_UFESpro_capm)
calculating descriptive statistics and saving in a database (questions 1 and 2)
summarysComdinheiro <- as.data.frame(describe(COMDINHEIRO_UFESpro_capm))
View(summarysComdinheiro)
to generate file to be opened in excel
write.csv(summarysComdinheiro, file="descritiva_comdinheiro.csv")
attach the FATHER base to the next issues
attach(COMDINHEIRO_UFESpro_capm)
?attach
Generating Scatter Plots (Questions 3 and 4)
?par
par(mfrow=c(1,2))
plot(IBOV,PETR4,main="PETR X IBOV",xlab = "IBOV",ylab = "PETR",pch=19)
?pch
plot(IBOV,PETR4,main="PETR X IBOV",xlab = "IBOV",ylab = "PETR")
plot(IBOV,PETR4,main="PETR X IBOV",xlab = "IBOV",ylab = "PETR",pch=19)
plot(IBOV,CDI,main="CDI X IBOV",xlab = "IBOV",ylab = "CDI",pch=19)
calculating correlations generating database, with numeric data only, for use with the color function
?numeric
?as.data.frame
?data.frame
?data.class
COMDINHEIRO_numeric <- data.frame(PETR4,VALE3,BBAS3,NATU3,IBOV,CDI)
cor(COMDINHEIRO_numeric, use = "complete.obs")
rounding to two decimal places
round(cor(COMDINHEIRO_numeric, use = "complete.obs"),2)
generating excess returns on CDI (question 5)
COMDINHEIRO_UFESpro_capm$petr_exc <- (PETR4-CDI)
COMDINHEIRO_UFESpro_capm$vale_exc <- (VALE3-CDI)
COMDINHEIRO_UFESpro_capm$bbas_exc <- (BBAS3-CDI)
COMDINHEIRO_UFESpro_capm$natu_exc <- (NATU3-CDI)
COMDINHEIRO_UFESpro_capm$ibov_exc <- (IBOV-CDI)
I want the values of excess returns!