options(warn = -1)12_12_report
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/data/all_objects_12_11.RData")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,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")+
theme_void()
print(p1)
p2<- ggplot(aug_res_20,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")+
theme_void()
print(p2)
p3<- ggplot(aug_res_30,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")+
theme_void()
print(p3)
p4<- ggplot(aug_res_60,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")+
theme_void()
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")'
load("Z:/Isaac/Visual Features/data/all_objects_12_12.RData")plots for the mean value residuals accounting for hour of the day
for (i in 1:5){
p1<- ggplot(aug_res_10_var,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")+
theme_void()
print(p1)
p2<- ggplot(aug_res_20_var,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")+
theme_void()
print(p2)
p3<- ggplot(aug_res_30_var,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")+
theme_void()
print(p3)
p4<- ggplot(aug_res_60_var,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")+
theme_void()
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")'
Notes
get rid of warnings for rendering document the residual calculation and have it match up with the fitted value or whatever to get the resid filter the data to atleast have a full day of recording try putting the ttf as response ttf~hour+(1|sow)+feature(s) features could vary, many to few step BIC survival analysis cox regression response is all 0 and 1 with 1 for farrowing 1 stop at the end of farrowing