I have a database with daily returns of a share for the last 5 years. But for my regression I want to use only the daily returns on the last day of each month. In other words, only 60 data that are the performance of the last day of each of the 60 months.
My problem is that I don't know how to filter the database so that it only shows the last days of each month.
library(quantmod)
MSFT<-getSymbols("MSFT",
from="2015-07-01", src= "yahoo",
auto.assign=F)[,4]
SP500<-getSymbols("^GSPC",
from="2015-07-01", src= "yahoo",
auto.assign=F)[,4]
MSFT<-dailyReturn(MSFT,type = 'arithmetic')
SP500<-dailyReturn(SP500, type = 'arithmetic')
SP500_BD<-as.data.frame(SP500$daily.returns)
MSFT_BD<-as.data.frame(MSFT$daily.returns)
SP500_BD$Time<-rownames(SP500_BD)
MSFT_BD$Time<-rownames(MSFT_BD)
DatosRS<-merge(SP500_BD,MSFT_BD,by="Time")
RLSDatosRS<-lm(formula = daily.returns.y ~ daily.returns.x, DatosRS)
summary(RLSDatosRS)