





Studia grazie alle numerose risorse presenti su Docsity
Guadagna punti aiutando altri studenti oppure acquistali con un piano Premium
Questa pagina non è visibile nell’anteprima
Non perderti parti importanti!






Exercise class 1 Introduction to RStudio Legend: Code Output Comments
If you write the name of any object (e.g. the variable just created “t”) and run the code, it returns values contained in the object in your console. t [1] "2017- 01 - 01" "2017- 02 - 01" "2017- 03 - 01" "2017- 04 - 01" "2017- 05 - 01" "2017- 06 - 01" "2017- 07 - 01" [8] "2017- 08 - 01" "2017- 09 - 01" "2017- 10 - 01" "2017- 11 - 01" "2017- 12 - 01" "2018- 01 - 01" "2018- 02 - 01" [50] "2021- 02 - 01" "2021- 03 - 01" "2021- 04 - 01" "2021- 05 - 01" "2021- 06 - 01" "2021- 07 - 01" "2021- 08 - 01" [57] "2021- 09 - 01" "2021- 10 - 01" "2021- 11 - 01" "2021- 12 - 01" "2022- 01 - 01" "2022- 02 - 01" "2022- 03 - 01" [64] "2022- 04 - 01" "2022- 05 - 01" "2022- 06 - 01" "2022- 07 - 01" "2022- 08 - 01" class(t) [1]"Date" Before plotting and computing any calculation, be sure the class of the variables you are using is “numeric”. class(Dataset$Electricity price) [1] "numeric"
You may compute returns by using the log-difference proxy 𝑟𝑡 =
≅ ln
ReturnsPUN <- diff(log(Dataset[,3])) ReturnsPSV <- diff(log(Dataset[,2])) Drawing a scatter plot of Gas and Electricity price returns allows you to infer the relationship between the two variables (in this case positive and linear). plot(ReturnsPSV, ReturnsPUN, col="blue", xlab="ReturnsPSV (%)", ylab="ReturnsPUN (%)") title("Scatter plot of PUN and PSV returns 2017-2022")