This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
arc_month%>% | |
filter(!is.na(sampledate))%>% | |
plot_acf_diagnostics(sampledate, rochef, | |
.lags=24, | |
.facet_ncol = 2, | |
.facet_scales = "free") | |
arc_month%>% | |
filter(!is.na(sampledate))%>% | |
plot_seasonal_diagnostics(sampledate, rochef, .interactive = FALSE) | |
arc_month %>% |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
arc_month%>% | |
filter(!is.na(sampledate))%>% | |
plot_anomaly_diagnostics(sampledate, | |
rochef, | |
.facet_ncol = 2, | |
.facet_scales = "free") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
arc_month<-arc%>% | |
summarise_by_time(sampledate, | |
.by="month", | |
Weight=median(wt.s,na.rm=TRUE), | |
rochef=median(rochefant, na.rm=TRUE), | |
nirala=sum(`nir-ala`, na.rm=TRUE), | |
nirdha=median(`nir-dha`, na.rm=TRUE), | |
nirdpa=sum(`nir-dpa`, na.rm=TRUE), | |
nirepa=median(`nir-epa`,na.rm=TRUE), | |
nireta=sum(`nir-eta`,na.rm=TRUE), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ggplot(arc, aes(x=rochefant, y=length, colour=(as.factor(generation1)))) + | |
geom_point(alpha=0.4) + | |
facet_wrap(~`generation(a/s)`) + | |
theme_bw() | |
ggplot(arc, aes(x=rochefant, y=length, colour=(as.factor(generation1)))) + | |
geom_point(alpha=0.4) + | |
facet_wrap(~weightclass) + | |
theme_bw() | |
ggplot(arc, aes(x=rochefant, y=length, colour=weightclasshalv)) + | |
geom_point(alpha=0.4) + |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DataExplorer::plot_missing(arc) | |
DataExplorer::plot_correlation(arc_month, | |
cor_args = list("use" = "pairwise.complete.obs")) | |
DataExplorer::plot_correlation(arc_company, | |
cor_args = list("use" = "pairwise.complete.obs")) | |
ggplot(arc, aes(x=rochefant, colour=description)) + | |
geom_density(aes(fill=description), alpha=0.2) + | |
theme_bw() + facet_wrap(~description) | |
ggplot(arc, aes(x=rochefant, colour=strain)) + |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
arc<-as.data.frame(arc) | |
arcraw<-as.data.frame(arcraw) | |
varPlot(form=rochefant~(region), Data=arc) | |
varPlot(form=rochefant~(customer), Data=arc) # some customers for sure provided more data then others | |
varPlot(form=rochefant~(locality), Data=arc) | |
varPlot(form=rochefant~(slaughteryear), Data=arc) | |
varPlot(rochefant~(slaughteryear+slaughtermonth), arc, keep.order = FALSE, | |
MeanLine=list(var=c("int", "slaughteryear"), | |
col=c("magenta", "blue"), lwd=c(2,2))) | |
varPlot(form=rochefant~(strain), Data=arc) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interceptonlymodel <- lmer(formula = rochefant ~ 1 + (1|customer), | |
data = arc);summary(interceptonlymodel) | |
interceptonlymodel <- lmer(formula = rochefant ~ 1 + (1|locality), | |
data = arc);summary(interceptonlymodel) | |
interceptonlymodel <- lmer(formula = rochefant ~ 1 + (1|region), | |
data = arc);summary(interceptonlymodel) | |
interceptonlymodel <- lmer(formula = rochefant ~ 1 + (1|slaughteryear), | |
data = arc);summary(interceptonlymodel) | |
interceptonlymodel <- lmer(formula = rochefant ~ 1 + (1|description), | |
data = arc);summary(interceptonlymodel) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Create summary time-series datasets for quick relationship building | |
length(levels(arc$customer)) | |
length(levels(arc$locality)) | |
length(levels(arc$region)) | |
length(levels(arc$strain)) | |
length(levels(arc$generation1)) | |
length(levels(arc$`generation(a/s)`)) | |
arc_month<-arc%>% | |
summarise_by_time(sampledate, | |
.by="month", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Recode all character to factor data ## | |
arc[sapply(arc, is.character)]<-lapply(arc[sapply(arc, is.character)],as.factor) | |
str(arc) | |
## Recode Generation (A/S) | |
levels(arc$`generation(a/s)`)[levels(arc$`generation(a/s)`)=="05SB"]<-NA | |
### LOOK AT RAW DATA | |
dim(arc) | |
str(arc) | |
skim(arc) | |
## tabulate the data ### |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rm(list = ls()) | |
library(readxl) | |
library(caret) | |
library(dplyr) | |
library(readr) | |
library(DataExplorer) | |
library(skimr) | |
library(forecast) | |
library(lubridate) | |
library(xts) |