Basically, I'm trying to create a portfolio data frame, where the coefficient estimates of the linear regressions are lagged. I've seen many similar issues like mine on stack overflow, but I can't understand what is meant when they say that the two vectors are of different length (I'm still a bit new to R and programming). Hopefully someone can better explain it for my situation.
I think the potential root to my problem is that before this code, Returns had 120 time-series observations and Dates had 121.
Portfolio_dataframe <- data.frame(Dates = Returns$Date[-c(1:Lookback)][1:(Periods*Holding)],
Market = Returns$Market.Close[-c(1:Lookback)][1:(Periods*Holding)],
Low_beta = unlist(Map(Holding_Period_Calculations, Holding_list, Portfolio_names,Portfolio_number = 1)),
Low_beta2 = unlist(Map(Holding_Period_Calculations, Holding_list, Portfolio_names,Portfolio_number = 2)),
Medium_beta = unlist(Map(Holding_Period_Calculations, Holding_list, Portfolio_names,Portfolio_number = 3)),
High_beta4 = unlist(Map(Holding_Period_Calculations, Holding_list, Portfolio_names,Portfolio_number = 4)),
High_beta = unlist(Map(Holding_Period_Calculations, Holding_list, Portfolio_names,Portfolio_number = 5)))
Lastly, the code runs well on my script, but the markdown fails to print this^^ section. enter image description here