I have a dataset daf that ranges from 1976-1982. I would like to find the monthly regression model of its variance. I tried with the following code for its regression model. could anyone suggest to me how can I get for 12 months i.e. Ja... Dec respectively.
datetime measured synthetic yrmonth
<dttm> <dbl> <dbl> <chr>
1 1976-09-03 22:45:00 0 0 1976-09
2 1976-09-03 23:00:00 2.54 0 1976-09
3 1976-09-03 23:15:00 5.08 0 1976-09
4 1976-09-03 23:30:00 0 0 1976-09
5 1976-09-03 23:45:00 0 6 1976-09
6 1976-09-04 00:00:00 0 1 1976-09
library(tidyverse)
daf=read_csv("df.csv",col_names=TRUE)
daf$datetime=as.POSIXct(daf$datetime, format="%Y-%m-%d %H:%M:%S")
daf$yrmonth=format(as.Date(daf$datetime, format="%Y-%m-%d %H:%M:%S"),"%Y-%m")
df_var <- aggregate(cbind(measured,synthetic) ~ yrmonth, daf, var)
model <- lm(synthetic ~ measured, data = df_var)