options(warn = -1)resid_plots
library(dplyr)
Attaching package: 'dplyr'
The following objects are masked from 'package:stats':
filter, lag
The following objects are masked from 'package:base':
intersect, setdiff, setequal, union
library(lmerTest)Loading required package: lme4
Loading required package: Matrix
Attaching package: 'lmerTest'
The following object is masked from 'package:lme4':
lmer
The following object is masked from 'package:stats':
step
library(tidyverse)── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ forcats 1.0.0 ✔ readr 2.1.5
✔ ggplot2 3.5.1 ✔ stringr 1.5.1
✔ lubridate 1.9.3 ✔ tibble 3.2.1
✔ purrr 1.0.2 ✔ tidyr 1.3.1
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ tidyr::expand() masks Matrix::expand()
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag() masks stats::lag()
✖ tidyr::pack() masks Matrix::pack()
✖ tidyr::unpack() masks Matrix::unpack()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(modelr)
library(purrr)
library(emmeans)Welcome to emmeans.
Caution: You lose important information if you filter this package's results.
See '? untidy'
library(gridExtra)
Attaching package: 'gridExtra'
The following object is masked from 'package:dplyr':
combine
library(writexl)
library(gt)
library(webshot2)
library(broom.mixed)
library(ggplot2)
load("Z:/Isaac/Visual Features/1-5/step2.RData")aug_res_10_filt <- aug_res_10 %>%
group_by(sow) %>%
filter(n() > 2000) %>%
ungroup()
aug_res_20_filt <- aug_res_20 %>%
group_by(sow) %>%
filter(n() > 1100) %>%
ungroup()
aug_res_30_filt <- aug_res_30 %>%
group_by(sow) %>%
filter(n() > 700) %>%
ungroup()
aug_res_60_filt <- aug_res_60 %>%
group_by(sow) %>%
filter(n() > 400) %>%
ungroup()plots for the mean value residuals accounting for hour of the day
options(repr.plot.width = 16, repr.plot.height = 250)
library(ggforce)
for (i in 1:5){
p1<- ggplot(aug_res_10_filt,aes(x=ttf,y=.resid,color=sow))+
geom_smooth(se=F)+
geom_smooth(aes(x=ttf,y=.resid),linewidth=1.2,color="black")+
facet_wrap_paginate(~feature,scales="free",ncol=2,nrow=2,page=i)+
ggtitle("10 min window mean")
print(p1)
p2<- ggplot(aug_res_20_filt,aes(x=ttf,y=.resid,color=sow))+
geom_smooth(se=F)+
geom_smooth(aes(x=ttf,y=.resid),linewidth=1.2,color="black")+
facet_wrap_paginate(~feature,scales="free",ncol=2,nrow=2,page=i)+
ggtitle("20 min window mean")
print(p2)
p3<- ggplot(aug_res_30_filt,aes(x=ttf,y=.resid,color=sow))+
geom_smooth(se=F)+
geom_smooth(aes(x=ttf,y=.resid),linewidth=1.2,color="black")+
facet_wrap_paginate(~feature,scales="free",ncol=2,nrow=2,page=i)+
ggtitle("30 min window mean")
print(p3)
p4<- ggplot(aug_res_60_filt,aes(x=ttf,y=.resid,color=sow))+
geom_smooth(se=F)+
geom_smooth(aes(x=ttf,y=.resid),linewidth=1.2,color="black")+
facet_wrap_paginate(~feature,scales="free",ncol=2,nrow=2,page=i)+
ggtitle("60 min window mean")
print(p4)
}`geom_smooth()` using method = 'loess' and formula = 'y ~ x'
`geom_smooth()` using method = 'gam' and formula = 'y ~ s(x, bs = "cs")'
`geom_smooth()` using method = 'loess' and formula = 'y ~ x'
`geom_smooth()` using method = 'gam' and formula = 'y ~ s(x, bs = "cs")'
`geom_smooth()` using method = 'loess' and formula = 'y ~ x'
`geom_smooth()` using method = 'gam' and formula = 'y ~ s(x, bs = "cs")'
`geom_smooth()` using method = 'loess' and formula = 'y ~ x'
`geom_smooth()` using method = 'gam' and formula = 'y ~ s(x, bs = "cs")'
`geom_smooth()` using method = 'loess' and formula = 'y ~ x'
`geom_smooth()` using method = 'gam' and formula = 'y ~ s(x, bs = "cs")'
`geom_smooth()` using method = 'loess' and formula = 'y ~ x'
`geom_smooth()` using method = 'gam' and formula = 'y ~ s(x, bs = "cs")'
`geom_smooth()` using method = 'loess' and formula = 'y ~ x'
`geom_smooth()` using method = 'gam' and formula = 'y ~ s(x, bs = "cs")'
`geom_smooth()` using method = 'loess' and formula = 'y ~ x'
`geom_smooth()` using method = 'gam' and formula = 'y ~ s(x, bs = "cs")'
`geom_smooth()` using method = 'loess' and formula = 'y ~ x'
`geom_smooth()` using method = 'gam' and formula = 'y ~ s(x, bs = "cs")'
`geom_smooth()` using method = 'loess' and formula = 'y ~ x'
`geom_smooth()` using method = 'gam' and formula = 'y ~ s(x, bs = "cs")'
`geom_smooth()` using method = 'loess' and formula = 'y ~ x'
`geom_smooth()` using method = 'gam' and formula = 'y ~ s(x, bs = "cs")'
`geom_smooth()` using method = 'loess' and formula = 'y ~ x'
`geom_smooth()` using method = 'gam' and formula = 'y ~ s(x, bs = "cs")'
`geom_smooth()` using method = 'loess' and formula = 'y ~ x'
`geom_smooth()` using method = 'gam' and formula = 'y ~ s(x, bs = "cs")'
`geom_smooth()` using method = 'loess' and formula = 'y ~ x'
`geom_smooth()` using method = 'gam' and formula = 'y ~ s(x, bs = "cs")'
`geom_smooth()` using method = 'loess' and formula = 'y ~ x'
`geom_smooth()` using method = 'gam' and formula = 'y ~ s(x, bs = "cs")'
`geom_smooth()` using method = 'loess' and formula = 'y ~ x'
`geom_smooth()` using method = 'gam' and formula = 'y ~ s(x, bs = "cs")'
`geom_smooth()` using method = 'loess' and formula = 'y ~ x'
`geom_smooth()` using method = 'gam' and formula = 'y ~ s(x, bs = "cs")'
`geom_smooth()` using method = 'loess' and formula = 'y ~ x'
`geom_smooth()` using method = 'gam' and formula = 'y ~ s(x, bs = "cs")'
`geom_smooth()` using method = 'loess' and formula = 'y ~ x'
`geom_smooth()` using method = 'gam' and formula = 'y ~ s(x, bs = "cs")'
`geom_smooth()` using method = 'loess' and formula = 'y ~ x'
`geom_smooth()` using method = 'gam' and formula = 'y ~ s(x, bs = "cs")'
aug_res_10_var_filt <- aug_res_10_var %>%
group_by(sow) %>%
filter(n() > 2000) %>%
ungroup()
aug_res_20_var_filt <- aug_res_20_var %>%
group_by(sow) %>%
filter(n() > 1100) %>%
ungroup()
aug_res_30_var_filt <- aug_res_30_var %>%
group_by(sow) %>%
filter(n() > 700) %>%
ungroup()
aug_res_60_var_filt <- aug_res_60_var %>%
group_by(sow) %>%
filter(n() > 400) %>%
ungroup()plots for the var value residuals accounting for hour of the day
for (i in 1:5){
p1<- ggplot(aug_res_10_var_filt,aes(x=ttf,y=.resid,color=sow))+
geom_smooth(se=F)+
geom_smooth(aes(x=ttf,y=.resid),linewidth=1.2,color="black")+
facet_wrap_paginate(~feature,scales="free",ncol=2,nrow=2,page=i)+
ggtitle("10 min window var")
print(p1)
p2<- ggplot(aug_res_20_var_filt,aes(x=ttf,y=.resid,color=sow))+
geom_smooth(se=F)+
geom_smooth(aes(x=ttf,y=.resid),linewidth=1.2,color="black")+
facet_wrap_paginate(~feature,scales="free",ncol=2,nrow=2,page=i)+
ggtitle("20 min window var")
print(p2)
p3<- ggplot(aug_res_30_var_filt,aes(x=ttf,y=.resid,color=sow))+
geom_smooth(se=F)+
geom_smooth(aes(x=ttf,y=.resid),linewidth=1.2,color="black")+
facet_wrap_paginate(~feature,scales="free",ncol=2,nrow=2,page=i)+
ggtitle("30 min window var")
print(p3)
p4<- ggplot(aug_res_60_var_filt,aes(x=ttf,y=.resid,color=sow))+
geom_smooth(se=F)+
geom_smooth(aes(x=ttf,y=.resid),linewidth=1.2,color="black")+
facet_wrap_paginate(~feature,scales="free",ncol=2,nrow=2,page=i)+
ggtitle("60 min window var")
print(p4)
}`geom_smooth()` using method = 'loess' and formula = 'y ~ x'
`geom_smooth()` using method = 'gam' and formula = 'y ~ s(x, bs = "cs")'
`geom_smooth()` using method = 'loess' and formula = 'y ~ x'
`geom_smooth()` using method = 'gam' and formula = 'y ~ s(x, bs = "cs")'
`geom_smooth()` using method = 'loess' and formula = 'y ~ x'
`geom_smooth()` using method = 'gam' and formula = 'y ~ s(x, bs = "cs")'
`geom_smooth()` using method = 'loess' and formula = 'y ~ x'
`geom_smooth()` using method = 'gam' and formula = 'y ~ s(x, bs = "cs")'
`geom_smooth()` using method = 'loess' and formula = 'y ~ x'
`geom_smooth()` using method = 'gam' and formula = 'y ~ s(x, bs = "cs")'
`geom_smooth()` using method = 'loess' and formula = 'y ~ x'
`geom_smooth()` using method = 'gam' and formula = 'y ~ s(x, bs = "cs")'
`geom_smooth()` using method = 'loess' and formula = 'y ~ x'
`geom_smooth()` using method = 'gam' and formula = 'y ~ s(x, bs = "cs")'
`geom_smooth()` using method = 'loess' and formula = 'y ~ x'
`geom_smooth()` using method = 'gam' and formula = 'y ~ s(x, bs = "cs")'
`geom_smooth()` using method = 'loess' and formula = 'y ~ x'
`geom_smooth()` using method = 'gam' and formula = 'y ~ s(x, bs = "cs")'
`geom_smooth()` using method = 'loess' and formula = 'y ~ x'
`geom_smooth()` using method = 'gam' and formula = 'y ~ s(x, bs = "cs")'
`geom_smooth()` using method = 'loess' and formula = 'y ~ x'
`geom_smooth()` using method = 'gam' and formula = 'y ~ s(x, bs = "cs")'
`geom_smooth()` using method = 'loess' and formula = 'y ~ x'
`geom_smooth()` using method = 'gam' and formula = 'y ~ s(x, bs = "cs")'
`geom_smooth()` using method = 'loess' and formula = 'y ~ x'
`geom_smooth()` using method = 'gam' and formula = 'y ~ s(x, bs = "cs")'
`geom_smooth()` using method = 'loess' and formula = 'y ~ x'
`geom_smooth()` using method = 'gam' and formula = 'y ~ s(x, bs = "cs")'
`geom_smooth()` using method = 'loess' and formula = 'y ~ x'
`geom_smooth()` using method = 'gam' and formula = 'y ~ s(x, bs = "cs")'
`geom_smooth()` using method = 'loess' and formula = 'y ~ x'
`geom_smooth()` using method = 'gam' and formula = 'y ~ s(x, bs = "cs")'
`geom_smooth()` using method = 'loess' and formula = 'y ~ x'
`geom_smooth()` using method = 'gam' and formula = 'y ~ s(x, bs = "cs")'
`geom_smooth()` using method = 'loess' and formula = 'y ~ x'
`geom_smooth()` using method = 'gam' and formula = 'y ~ s(x, bs = "cs")'
`geom_smooth()` using method = 'loess' and formula = 'y ~ x'
`geom_smooth()` using method = 'gam' and formula = 'y ~ s(x, bs = "cs")'
`geom_smooth()` using method = 'loess' and formula = 'y ~ x'
`geom_smooth()` using method = 'gam' and formula = 'y ~ s(x, bs = "cs")'