Dear Members,


Greetings! I would like to know how to create the lag variable for my data.



# Load data and create time series object ----

oil <- read_xlsx("crudefinal.xlsx")



pricet=ts(oil$price, start = c(2020, 22), frequency = 365)

roilt=ts(diff(log(oil$price))*100,start=c(2020,22),freq=365)



# Fit MSW model ----

roilt.lag0 = window(roilt,start=c(2020,23),end=c(2021,215),freq=365) # get
al the lags right

roilt.lag1 = window(roilt,start=c(2020,22),end=c(2021,214),freq=365)

roilt.lag2 = window(roilt,start=c(2020,20),end=c(2021,213),freq=365)

roilt.lag3 = window(roilt,start=c(2020,20),end=c(2021,212),freq=365)

roilt.lag4 = window(roilt,start=c(2020,19),end=c(2021,211),freq=365)



I am getting error (length is not matching), while creating lag. I will
grateful to you if you can tell me where  I am making mistakes.



Regards,

Upananda Pani

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to