#| warning: true
#| echo: true
#| label: data_prepataion
rm (list = ls ())
setwd ("C:/Users/anune/OneDrive/Desktop/PIC_DataAnalysis_files" )
data_PIC <- read.csv ("PIC_65_FIRE.AN.1.csv" )
data_PIC<- mutate (data_PIC,day_0 = dmy (START_DAY),
ENTRY_DATE = date (as.POSIXct (ENTRY_TIME, format= "%m/%d/%Y %H:%M" )),
DAYS_IN_FEED = as.numeric (ENTRY_DATE - day_0))
summary (data_PIC$ DAYS_IN_FEED)
Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
-364.0 14.0 31.0 31.2 48.0 68.0 25
data_PIC <- group_by (data_PIC, ID)
head (data_PIC)
# A tibble: 6 x 19
# Groups: ID [3]
ID LINE SIRE DAM LITTER PEN FARM ENTRY_TIME EXIT_TIME STAY_IN
<int> <int> <int> <int> <int> <chr> <int> <chr> <chr> <int>
1 96251326 65 91032775 9.22e7 7.80e7 B0113 774 10/27/202~ 10/27/20~ 649
2 96251327 65 91032775 9.22e7 7.80e7 B0113 774 10/27/202~ 10/27/20~ 1948
3 96251327 65 91032775 9.22e7 7.80e7 B0113 774 10/27/202~ 10/27/20~ 169
4 96284921 65 90218081 9.02e7 7.81e7 B0113 774 10/27/202~ 10/27/20~ 627
5 96284921 65 90218081 9.02e7 7.81e7 B0113 774 10/27/202~ 10/27/20~ 768
6 96284921 65 90218081 9.02e7 7.81e7 B0113 774 10/27/202~ 10/27/20~ 413
# i 9 more variables: FEED_INTK <int>, ENTRY_WT <int>, EXIT_WT <int>,
# FEEDER_NO <int>, START_DAY <chr>, OFFTEST_DAY <chr>, day_0 <date>,
# ENTRY_DATE <date>, DAYS_IN_FEED <dbl>
# A tibble: 6 x 19
# Groups: ID [5]
ID LINE SIRE DAM LITTER PEN FARM ENTRY_TIME EXIT_TIME STAY_IN
<int> <int> <int> <int> <int> <chr> <int> <chr> <chr> <int>
1 98350892 65 93693188 9.41e7 7.92e7 B0602 774 6/15/2023~ 6/15/202~ 423
2 98350892 65 93693188 9.41e7 7.92e7 B0602 774 6/15/2023~ 6/15/202~ 1237
3 98350934 65 93693188 9.41e7 7.92e7 B0602 774 6/19/2023~ 6/19/202~ 183
4 98332707 65 93423760 9.42e7 7.92e7 B0602 774 6/19/2023~ 6/19/202~ 6
5 98350859 65 93693188 9.41e7 7.92e7 B0602 774 6/19/2023~ 6/19/202~ 14
6 98340247 65 93513866 9.42e7 7.92e7 B0602 774 6/19/2023~ 6/19/202~ 29
# i 9 more variables: FEED_INTK <int>, ENTRY_WT <int>, EXIT_WT <int>,
# FEEDER_NO <int>, START_DAY <chr>, OFFTEST_DAY <chr>, day_0 <date>,
# ENTRY_DATE <date>, DAYS_IN_FEED <dbl>
#| warning: true
#| echo: true
#| label: function_definition
perform_quantile_regression <- function (data_PIC, quantiles = quantiles) {
quantile_models <- rq (FEED_INTK ~ STAY_IN, data = data_PIC, tau = quantiles)
storage_quantiles <- predict (quantile_models)
colnames (storage_quantiles) <- c ("Q1" , "Q2" , "Q3" )
outlier_band <- as.data.frame (storage_quantiles) %>%
mutate (IQR = Q3 - Q1, LB = Q1 - 1.5 * IQR, UP = Q3 + 1.5 * IQR)
id_band <- cbind (data_PIC, outlier_band) %>% mutate (ol = (FEED_INTK > UP) | (FEED_INTK < LB))
return (id_band)
}
id_data1_outlier <- function (data1, quantiles = c (0.25 , 0.75 )) {
id_data1_results <- data1 %>%
mutate (Q1U = quantile (STAY_IN, probs = quantiles[1 ]),
Q3U = quantile (STAY_IN, probs = quantiles[2 ]),
IQRU = Q3U - Q1U,
UBU = Q3U + 1.5 * IQRU,
LBU = Q1U - 1.5 * IQRU,
ol2 = (STAY_IN > UBU) | (STAY_IN < LBU))
return (id_data1_results)
}
quantiles <- c (0.25 , 0.5 , 0.75 )
storage_bygroup <- perform_quantile_regression (data_PIC, quantiles = quantiles)
head (storage_bygroup)
# A tibble: 6 x 26
# Groups: ID [3]
ID LINE SIRE DAM LITTER PEN FARM ENTRY_TIME EXIT_TIME STAY_IN
<int> <int> <int> <int> <int> <chr> <int> <chr> <chr> <int>
1 96251326 65 91032775 9.22e7 7.80e7 B0113 774 10/27/202~ 10/27/20~ 649
2 96251327 65 91032775 9.22e7 7.80e7 B0113 774 10/27/202~ 10/27/20~ 1948
3 96251327 65 91032775 9.22e7 7.80e7 B0113 774 10/27/202~ 10/27/20~ 169
4 96284921 65 90218081 9.02e7 7.81e7 B0113 774 10/27/202~ 10/27/20~ 627
5 96284921 65 90218081 9.02e7 7.81e7 B0113 774 10/27/202~ 10/27/20~ 768
6 96284921 65 90218081 9.02e7 7.81e7 B0113 774 10/27/202~ 10/27/20~ 413
# i 16 more variables: FEED_INTK <int>, ENTRY_WT <int>, EXIT_WT <int>,
# FEEDER_NO <int>, START_DAY <chr>, OFFTEST_DAY <chr>, day_0 <date>,
# ENTRY_DATE <date>, DAYS_IN_FEED <dbl>, Q1 <dbl>, Q2 <dbl>, Q3 <dbl>,
# IQR <dbl>, LB <dbl>, UP <dbl>, ol <lgl>
storage_id_data1 <- id_data1_outlier (storage_bygroup, quantiles = c (0.25 , 0.75 ))
head (storage_id_data1)
# A tibble: 6 x 32
# Groups: ID [3]
ID LINE SIRE DAM LITTER PEN FARM ENTRY_TIME EXIT_TIME STAY_IN
<int> <int> <int> <int> <int> <chr> <int> <chr> <chr> <int>
1 96251326 65 91032775 9.22e7 7.80e7 B0113 774 10/27/202~ 10/27/20~ 649
2 96251327 65 91032775 9.22e7 7.80e7 B0113 774 10/27/202~ 10/27/20~ 1948
3 96251327 65 91032775 9.22e7 7.80e7 B0113 774 10/27/202~ 10/27/20~ 169
4 96284921 65 90218081 9.02e7 7.81e7 B0113 774 10/27/202~ 10/27/20~ 627
5 96284921 65 90218081 9.02e7 7.81e7 B0113 774 10/27/202~ 10/27/20~ 768
6 96284921 65 90218081 9.02e7 7.81e7 B0113 774 10/27/202~ 10/27/20~ 413
# i 22 more variables: FEED_INTK <int>, ENTRY_WT <int>, EXIT_WT <int>,
# FEEDER_NO <int>, START_DAY <chr>, OFFTEST_DAY <chr>, day_0 <date>,
# ENTRY_DATE <date>, DAYS_IN_FEED <dbl>, Q1 <dbl>, Q2 <dbl>, Q3 <dbl>,
# IQR <dbl>, LB <dbl>, UP <dbl>, ol <lgl>, Q1U <dbl>, Q3U <dbl>, IQRU <dbl>,
# UBU <dbl>, LBU <dbl>, ol2 <lgl>
storage_id_data1= mutate (storage_id_data1, olf= ol| ol2, olc = ol* 2 + ol2 )
head (storage_id_data1)
# A tibble: 6 x 34
# Groups: ID [3]
ID LINE SIRE DAM LITTER PEN FARM ENTRY_TIME EXIT_TIME STAY_IN
<int> <int> <int> <int> <int> <chr> <int> <chr> <chr> <int>
1 96251326 65 91032775 9.22e7 7.80e7 B0113 774 10/27/202~ 10/27/20~ 649
2 96251327 65 91032775 9.22e7 7.80e7 B0113 774 10/27/202~ 10/27/20~ 1948
3 96251327 65 91032775 9.22e7 7.80e7 B0113 774 10/27/202~ 10/27/20~ 169
4 96284921 65 90218081 9.02e7 7.81e7 B0113 774 10/27/202~ 10/27/20~ 627
5 96284921 65 90218081 9.02e7 7.81e7 B0113 774 10/27/202~ 10/27/20~ 768
6 96284921 65 90218081 9.02e7 7.81e7 B0113 774 10/27/202~ 10/27/20~ 413
# i 24 more variables: FEED_INTK <int>, ENTRY_WT <int>, EXIT_WT <int>,
# FEEDER_NO <int>, START_DAY <chr>, OFFTEST_DAY <chr>, day_0 <date>,
# ENTRY_DATE <date>, DAYS_IN_FEED <dbl>, Q1 <dbl>, Q2 <dbl>, Q3 <dbl>,
# IQR <dbl>, LB <dbl>, UP <dbl>, ol <lgl>, Q1U <dbl>, Q3U <dbl>, IQRU <dbl>,
# UBU <dbl>, LBU <dbl>, ol2 <lgl>, olf <lgl>, olc <dbl>
full_outliers <- storage_id_data1
head (full_outliers)
# A tibble: 6 x 34
# Groups: ID [3]
ID LINE SIRE DAM LITTER PEN FARM ENTRY_TIME EXIT_TIME STAY_IN
<int> <int> <int> <int> <int> <chr> <int> <chr> <chr> <int>
1 96251326 65 91032775 9.22e7 7.80e7 B0113 774 10/27/202~ 10/27/20~ 649
2 96251327 65 91032775 9.22e7 7.80e7 B0113 774 10/27/202~ 10/27/20~ 1948
3 96251327 65 91032775 9.22e7 7.80e7 B0113 774 10/27/202~ 10/27/20~ 169
4 96284921 65 90218081 9.02e7 7.81e7 B0113 774 10/27/202~ 10/27/20~ 627
5 96284921 65 90218081 9.02e7 7.81e7 B0113 774 10/27/202~ 10/27/20~ 768
6 96284921 65 90218081 9.02e7 7.81e7 B0113 774 10/27/202~ 10/27/20~ 413
# i 24 more variables: FEED_INTK <int>, ENTRY_WT <int>, EXIT_WT <int>,
# FEEDER_NO <int>, START_DAY <chr>, OFFTEST_DAY <chr>, day_0 <date>,
# ENTRY_DATE <date>, DAYS_IN_FEED <dbl>, Q1 <dbl>, Q2 <dbl>, Q3 <dbl>,
# IQR <dbl>, LB <dbl>, UP <dbl>, ol <lgl>, Q1U <dbl>, Q3U <dbl>, IQRU <dbl>,
# UBU <dbl>, LBU <dbl>, ol2 <lgl>, olf <lgl>, olc <dbl>
table (storage_id_data1$ olc)
0 1 2 3
111713 425 2108 17
outlier_frequencies <- table (storage_id_data1$ olc)
outlier_percentages <- (outlier_frequencies / nrow (storage_id_data1)) * 100
outlier_summary <- data.frame (Frequencies = outlier_frequencies, Percentages = outlier_percentages)
print (outlier_summary)
Frequencies.Var1 Frequencies.Freq Percentages.Var1 Percentages.Freq
1 0 111713 0 97.76830645
2 1 425 1 0.37194892
3 2 2108 2 1.84486667
4 3 17 3 0.01487796
#Per ID##
id_frequencies <- table (storage_id_data1$ ID, storage_id_data1$ olc)
id_frequencies
0 1 2 3
96251326 178 0 15 0
96251327 135 0 1 0
96251328 193 0 28 0
96251346 193 0 1 0
96263569 176 1 23 0
96263570 205 0 3 0
96263592 288 2 25 0
96263593 252 0 1 0
96263594 177 0 0 0
96263848 236 8 0 0
96263849 242 7 1 0
96284921 203 0 0 0
96284922 215 1 0 0
96284923 208 4 0 0
96284927 155 0 4 0
96329097 180 0 1 0
96329098 218 0 0 0
96329099 223 0 1 0
96329100 205 0 16 0
96329103 184 0 0 0
96329105 384 1 5 0
96329106 190 1 1 0
96329107 221 0 4 0
96329111 151 0 2 0
96329112 294 0 2 0
96329113 215 0 9 0
96329115 231 0 0 0
96336569 179 0 0 0
96336570 224 0 1 0
96336578 257 1 1 0
96336579 208 0 0 0
96336591 236 1 1 0
96336596 189 0 0 0
96336598 203 0 1 0
96336601 211 5 1 0
96351936 106 0 19 0
96352145 177 0 1 0
96352149 178 0 6 0
96352158 104 0 1 0
96354524 199 0 1 0
96354533 216 0 3 0
96354534 238 0 1 0
96378634 227 0 2 0
96388718 183 0 0 0
96388719 248 0 1 0
96388720 203 1 1 0
96388721 194 0 2 0
96388725 266 0 4 0
96388736 163 0 0 0
96388745 179 2 2 0
96388746 219 0 1 0
96388747 222 2 0 0
96388748 109 0 35 0
96411292 168 5 0 0
96411293 251 0 0 0
96411302 168 0 1 0
96426059 232 0 1 0
96426080 277 0 0 0
96426245 191 0 0 0
96426258 241 0 0 0
96426261 292 0 1 0
96426262 202 0 1 0
96426373 251 0 3 0
96426375 187 1 4 0
96426378 208 0 1 0
96426379 221 0 3 0
96437502 217 0 0 0
96437546 341 0 3 1
96437558 204 0 3 0
96437643 154 0 2 0
96437644 181 0 5 0
96437706 188 0 4 0
96437722 176 0 0 0
96437726 204 1 3 0
96437729 196 0 3 0
96437730 264 0 1 0
96437743 175 0 0 0
96437917 204 0 0 0
96449413 189 0 0 0
96449421 195 2 11 0
96449432 143 4 5 0
96449435 194 0 3 0
96449448 162 0 6 0
96449461 237 0 2 0
96449466 185 0 1 0
96466410 171 0 3 0
96466411 147 0 19 0
96466413 154 0 3 0
96466420 121 0 0 0
96479452 217 4 29 0
96479456 152 0 1 0
96479471 217 0 3 0
96500686 190 0 2 0
96508440 265 0 4 0
96508442 234 0 3 0
96508443 308 0 10 0
96515289 233 0 8 0
96515292 377 0 3 0
96515296 149 0 0 0
96515302 259 0 2 0
96515303 224 0 1 0
96515304 198 0 3 0
96515305 192 0 6 0
96525556 218 0 2 0
96525594 214 0 0 0
96525840 310 0 5 0
96525846 211 0 8 0
96525847 285 0 13 0
96526087 300 0 2 0
96526101 298 1 2 0
96526102 322 0 5 0
96535149 334 0 2 0
96535150 237 2 0 0
96535151 194 0 0 0
96535152 233 0 2 0
96554667 189 0 4 0
96554668 235 0 2 0
96554669 337 0 3 0
96554670 194 0 1 0
96554676 167 0 1 0
96554678 169 0 0 0
96554679 197 0 3 0
96573973 209 4 52 0
96587411 179 0 1 0
96587424 147 1 1 0
96587426 123 0 2 0
96587427 100 0 1 0
96587428 130 0 0 0
96587429 184 0 0 0
96587437 120 1 1 0
96587439 126 0 28 0
96600078 185 0 1 0
96600199 164 0 3 0
96600204 148 0 3 0
96601065 161 1 0 0
96601075 226 0 6 0
96601076 222 0 1 0
96700367 231 0 14 0
96700401 232 0 1 0
96718260 219 0 3 0
96718263 193 0 3 0
96718330 190 0 3 0
96718348 205 1 2 0
96718394 190 0 0 0
96718395 419 1 0 0
96718397 243 3 24 0
96740219 260 0 3 0
96751302 236 0 16 0
96751350 285 0 2 0
96751368 312 0 2 0
96751370 246 2 1 0
96751392 197 1 5 0
96767514 214 0 3 0
96767872 272 1 2 0
96789743 191 0 3 0
96789838 185 0 16 0
96804877 249 6 3 0
96804883 217 0 1 0
96804896 178 0 0 0
96804950 185 0 10 1
96804972 317 0 2 0
96814444 214 1 47 0
96814452 253 0 2 0
96814455 255 1 1 0
96814487 208 1 2 0
96814490 303 0 1 0
96814494 244 0 4 0
96814510 198 2 1 0
96920449 220 0 17 0
96920460 154 2 28 0
96935899 207 6 4 0
96935906 178 0 10 0
96935908 178 0 3 0
96935923 164 0 15 0
96954301 200 1 5 0
96954425 219 0 4 0
96954427 215 2 18 0
96954436 193 0 23 0
96954450 148 0 1 0
96954479 175 0 8 0
96967605 107 0 5 0
96967675 189 0 14 0
97018983 156 0 2 0
97018985 178 0 11 0
97018989 140 0 2 0
97018990 196 0 1 0
97019116 152 0 0 0
97019137 235 1 0 0
97019138 185 0 1 0
97019271 205 0 4 0
97019275 178 0 0 0
97040416 173 4 36 0
97040422 222 0 0 0
97040428 160 11 0 0
97040431 145 1 0 0
97040432 121 0 0 0
97040443 215 1 1 0
97056774 122 0 0 0
97091383 224 0 1 0
97091386 159 0 3 0
97091421 146 0 1 0
97091422 204 0 0 0
97091428 225 0 2 0
97091438 192 4 17 0
97091491 137 0 27 0
97091492 166 0 6 0
97091524 239 5 0 0
97107441 242 0 2 0
97107501 214 0 1 0
97107553 186 1 3 0
97107574 207 13 1 0
97107584 162 2 0 0
97107587 218 1 1 0
97107601 200 0 7 0
97107627 229 2 0 0
97107668 186 3 3 0
97107674 303 7 1 0
97107675 193 1 0 0
97107692 196 4 0 0
97107709 182 0 1 0
97107715 164 0 2 0
97107719 221 0 1 0
97107830 212 0 29 0
97107840 183 0 0 0
97107874 217 0 3 0
97124745 159 1 24 0
97124774 149 0 0 0
97124782 191 0 2 0
97124789 186 1 1 0
97166077 230 2 0 0
97166129 195 2 0 0
97166163 210 0 2 0
97177930 229 0 3 0
97177935 128 0 3 0
97177969 226 0 2 0
97177973 215 2 6 0
97177992 157 0 3 0
97177995 248 0 0 0
97178017 198 0 1 0
97178035 157 0 2 0
97178041 197 0 0 0
97178057 206 1 0 0
97178062 210 2 1 0
97178069 254 0 1 0
97178075 185 2 2 0
97178081 186 0 3 0
97178088 125 1 0 0
97178097 165 0 0 1
97178100 219 0 0 0
97178138 254 0 0 0
97178224 267 1 4 0
97178318 180 1 4 0
97178346 189 1 0 0
97178347 202 0 3 0
97191094 235 0 2 0
97191138 196 0 7 0
97191147 177 0 1 0
97191193 105 3 1 0
97191206 129 0 1 0
97246325 143 0 3 0
97257249 104 0 4 0
97257312 119 1 2 0
97257313 155 0 4 0
97257314 179 1 2 0
97257315 176 0 4 0
97257316 174 0 5 0
97257596 155 0 7 0
97257713 233 0 2 0
97257714 164 0 1 0
97257715 151 0 3 0
97257716 164 0 6 0
97257717 158 0 4 0
97257718 150 0 2 1
97257742 167 0 1 0
97257747 160 0 1 0
97257792 174 0 2 0
97257832 208 0 4 0
97257833 174 0 7 0
97257834 306 0 3 0
97257835 177 0 3 0
97274848 215 0 3 0
97274851 181 0 1 0
97274881 102 0 2 0
97274908 360 0 3 0
97274913 219 0 3 0
97274924 262 0 2 0
97274932 138 0 6 0
97274940 110 0 0 0
97274970 137 0 1 0
97274971 208 0 0 0
97274982 186 0 3 0
97331515 210 0 2 0
97331519 253 4 1 0
97331606 317 1 4 0
97331609 287 0 9 0
97331612 249 0 1 0
97331618 211 2 1 0
97331621 204 3 32 0
97331622 237 0 4 0
97331623 202 0 1 0
97331761 218 2 0 0
97331764 202 0 1 0
97331765 251 0 2 0
97331772 216 2 2 0
97331779 189 0 0 0
97348833 301 4 2 0
97348839 238 0 2 0
97369612 194 0 1 0
97369627 234 0 14 0
97369644 180 0 0 0
97369649 328 1 4 0
97369651 339 0 5 0
97369662 171 0 1 0
97369670 233 0 7 0
97386249 189 0 15 0
97386251 257 1 2 0
97386254 186 0 1 0
97386262 301 0 5 0
97386280 208 0 24 0
97386307 193 1 4 0
97386339 231 0 12 0
97395107 200 0 3 0
97395168 200 0 3 0
97413579 261 0 0 0
97413762 253 3 8 0
97413776 248 8 1 0
97413835 265 0 0 0
97413841 195 0 0 0
97413847 309 1 1 0
97413873 334 8 2 0
97430939 200 0 0 0
97430948 221 0 2 0
97447271 214 3 1 0
97447356 169 0 2 0
97503205 227 0 7 0
97503220 289 0 9 0
97503247 193 0 23 0
97503250 167 1 4 2
97503252 159 0 0 1
97503364 276 2 0 1
97503498 286 0 4 0
97503536 243 2 7 1
97503662 203 0 3 0
97503754 233 0 4 1
97503777 295 0 34 1
97503779 183 0 2 0
97527871 224 0 11 2
97527886 220 3 45 1
97527915 308 3 12 0
97527961 135 0 2 1
97573957 212 0 0 0
97573975 214 0 0 0
97573995 270 3 1 0
97574068 199 0 1 0
97574075 173 5 0 0
97574310 217 5 0 0
97574347 284 2 0 0
97574411 119 6 3 0
97595610 142 5 30 0
97595693 188 0 15 0
97595710 219 0 2 0
97595737 225 1 0 0
97595828 332 3 1 0
97595847 187 0 1 0
97595852 254 0 10 0
97687408 158 0 1 0
97725548 183 0 3 0
97725549 182 0 4 0
97725550 181 0 7 0
97725552 223 0 8 0
97734349 216 0 1 0
97734519 255 1 6 0
97734521 177 1 5 0
97734522 218 0 7 0
97745649 293 2 13 0
97745656 172 0 9 0
97745675 174 0 3 0
97745676 191 1 3 0
97756377 222 9 8 0
97756378 130 0 10 0
97756384 175 0 4 0
97805156 140 0 1 0
97805268 225 0 2 0
97805279 234 0 1 0
97818325 170 0 0 0
97818352 145 0 1 0
97818574 193 0 1 0
97818587 200 0 1 0
97818598 131 0 1 0
97818683 161 0 0 0
97818686 155 0 0 0
97818711 168 0 0 0
97828750 185 0 0 0
97877787 252 0 0 0
97877789 248 5 1 0
97877791 166 0 2 0
97877792 246 0 2 0
97887754 130 1 0 0
97887755 138 0 1 0
97887808 359 2 1 0
97887841 164 0 1 0
97887845 266 0 1 0
97887847 266 0 2 0
97887848 249 4 0 0
97887849 182 0 0 0
97887850 265 0 0 0
97887851 152 0 2 0
97900208 268 0 0 0
97900222 155 7 1 0
97900231 189 2 0 0
97900275 195 1 1 0
97900390 206 0 1 0
97900438 237 0 0 0
97900463 106 6 22 0
97900486 307 3 0 0
97900489 208 1 0 0
97900500 166 0 2 0
97900523 194 1 13 0
97900559 250 1 2 0
97900577 169 1 1 0
97900590 168 0 1 0
97900594 173 4 0 0
97900600 253 0 1 0
97916803 174 0 0 0
97916804 188 0 3 0
97916874 251 2 0 0
97916929 222 0 1 0
97916940 222 1 0 0
97916970 252 0 3 0
97975754 154 0 0 0
97975836 171 0 14 0
97989023 220 1 0 0
97989292 261 6 0 0
97989303 182 1 0 0
97989366 202 3 9 0
97989418 231 6 0 0
97989419 205 0 0 0
97989456 243 1 0 0
98009706 199 0 0 0
98009744 207 0 0 0
98028673 252 3 0 0
98028708 180 0 1 0
98028761 162 0 1 0
98028775 225 0 0 0
98028797 163 0 1 0
98046350 109 0 14 0
98046360 157 1 1 0
98046376 215 0 4 0
98046404 154 0 94 0
98046423 203 0 1 0
98046426 336 6 5 0
98046504 257 0 0 0
98046505 189 0 3 0
98060602 212 0 2 0
98060624 212 0 2 0
98060651 273 0 0 0
98064866 250 2 1 0
98064867 123 0 2 0
98064919 152 0 0 0
98064944 209 0 0 0
98064952 126 4 1 0
98064957 162 6 1 0
98064963 179 0 0 0
98064975 156 0 6 0
98077938 168 0 0 0
98077955 263 0 1 0
98078010 149 0 0 0
98078013 169 0 2 0
98078039 204 1 4 0
98078056 171 0 3 0
98078063 153 0 1 0
98078066 107 0 0 0
98078086 208 2 0 0
98078091 189 0 0 0
98078270 207 0 0 0
98078287 178 0 1 0
98078326 194 0 1 0
98078331 176 0 1 0
98078354 153 0 3 0
98078358 179 0 10 0
98078360 128 3 1 0
98078402 246 1 0 0
98078405 182 1 1 0
98078406 213 1 0 0
98078425 217 0 5 0
98078428 205 0 5 0
98101510 229 0 4 0
98101593 304 0 2 0
98158010 196 0 1 0
98158069 165 1 0 0
98158087 275 1 0 0
98158105 189 0 0 0
98158108 163 0 0 0
98165337 159 0 0 0
98165366 153 1 1 0
98165370 145 0 0 0
98165378 184 1 0 0
98165415 200 0 0 0
98165419 184 0 0 0
98165465 154 0 1 0
98165482 161 0 0 0
98185065 224 0 2 0
98185106 216 0 11 0
98196730 195 0 1 0
98196770 245 1 0 0
98196775 195 0 7 0
98196795 200 0 1 0
98196801 268 0 0 0
98196826 278 1 0 1
98196841 212 0 0 0
98218333 157 0 3 0
98235551 167 0 2 0
98235565 187 0 1 0
98235617 235 0 0 0
98235721 211 0 1 0
98235822 218 4 1 0
98235830 217 4 0 1
98235836 160 0 0 0
98235844 210 0 1 0
98235850 206 0 3 0
98235880 159 1 1 0
98241798 224 6 4 0
98241843 138 0 1 0
98241875 188 0 3 0
98241936 189 0 1 0
98245799 179 0 1 0
98245825 229 0 0 0
98245827 190 0 1 0
98260574 156 0 0 0
98260607 161 0 3 0
98260667 257 15 5 0
98260697 240 0 2 0
98260704 210 1 1 0
98260715 194 0 1 0
98332707 127 0 2 0
98332755 138 0 2 0
98332782 126 2 2 0
98332803 142 1 1 0
98332806 164 1 0 0
98333081 174 1 1 0
98333082 131 13 0 0
98340247 283 0 2 0
98350809 169 0 20 0
98350845 192 0 1 0
98350859 253 0 2 0
98350892 193 1 0 0
98350934 206 1 2 0
98368540 172 0 1 0
f <- (1 * id_frequencies > 0 )
colSums (f)/ nrow (f)
0 1 2 3
1.00000000 0.28832117 0.73722628 0.02737226
0 1 2 3
203.8558394 0.7755474 3.8467153 0.0310219
outlier_colors <- c ("black" , "green" , "orange" ,"pink" )
my_plot <- storage_id_data1 %>%
filter (ID %in% c ("97257312" , "96954301" , "96587437" , "97178318" )) %>% # Filter data for specific IDs
ggplot (aes (x = STAY_IN, y = FEED_INTK, color = factor (olc))) +
geom_point () +
geom_point (size = 0.5 , aes (x = STAY_IN, y = UP), color = "red" ) +
geom_point (size = 0.5 , aes (x = STAY_IN, y = LB), color = "red" ) +
geom_quantile (quantiles = 0.25 , color = "blue" ) +
geom_quantile (quantiles = 0.50 , color = "purple" ) +
geom_quantile (quantiles = 0.75 , color = "cyan4" ) +
scale_color_manual (values = outlier_colors) +
facet_wrap (~ ID) +
theme_light () +
labs (
title = "Quantile regression on data with non-constant variance" ,
subtitle = "Ames, Iowa, October 2023" ,
x = "Stay In time at the feeders" ,
y = "Feed Intake" ,
caption = "Example of phenotypic data performing a quantile regression model"
) +
theme (
axis.title = element_text (size = 10 ),
axis.text = element_text (size = 8 , color = "darkgray" ),
axis.ticks = element_line (size = 3 ),
plot.title = element_text (size = 20 , color = "darkblue" )
)
Warning: The `size` argument of `element_line()` is deprecated as of ggplot2 3.4.0.
i Please use the `linewidth` argument instead.
Smoothing formula not specified. Using: y ~ x
Smoothing formula not specified. Using: y ~ x
Smoothing formula not specified. Using: y ~ x
Smoothing formula not specified. Using: y ~ x
Smoothing formula not specified. Using: y ~ x
Smoothing formula not specified. Using: y ~ x
Smoothing formula not specified. Using: y ~ x
Smoothing formula not specified. Using: y ~ x
Smoothing formula not specified. Using: y ~ x
Smoothing formula not specified. Using: y ~ x
Smoothing formula not specified. Using: y ~ x
Smoothing formula not specified. Using: y ~ x
#Just ONE ID#
outlier_colors <- c ("black" , "green" , "orange" ,"pink" )
my_plot2 <- storage_id_data1 %>%
filter (ID == "97257312" ) %>% # Filter data for the specific ID
ggplot (aes (x = STAY_IN, y = FEED_INTK, color = factor (olc))) +
geom_point () +
geom_point (size = 0.5 , aes (x = STAY_IN, y = UP), color = "red" ) +
geom_point (size = 0.5 , aes (x = STAY_IN, y = LB), color = "red" ) +
geom_quantile (quantiles = 0.25 , color = "blue" ) +
geom_quantile (quantiles = 0.50 , color = "purple" ) +
geom_quantile (quantiles = 0.75 , color = "cyan4" ) +
scale_color_manual (values = outlier_colors) +
facet_wrap (~ ID) +
theme_light () +
labs (
title = "Quantile regression on data with non-constant variance" ,
subtitle = "Ames, Iowa, October 2023" ,
x = "Stay In time at the feeders" ,
y = "Feed Intake" ,
caption = "Example of phenotypic data performing a quantile regression model"
) +
theme (
axis.title = element_text (size = 10 ),
axis.text = element_text (size = 8 , color = "darkgray" ),
axis.ticks = element_line (size = 3 ),
plot.title = element_text (size = 20 , color = "darkblue" )
)
my_plot2
Smoothing formula not specified. Using: y ~ x
Smoothing formula not specified. Using: y ~ x
Smoothing formula not specified. Using: y ~ x
outlier_colors <- c ("black" , "green" , "orange" , "pink" )
my_plot3 <- storage_id_data1 %>%
filter (ID == "96954301" ) %>% # Filter data for the specific ID
ggplot (aes (x = STAY_IN, y = FEED_INTK, color = factor (olc))) +
geom_point () +
geom_point (size = 0.5 , aes (x = STAY_IN, y = UP), color = "red" ) +
geom_point (size = 0.5 , aes (x = STAY_IN, y = LB), color = "red" ) +
geom_quantile (quantiles = 0.25 , color = "blue" ) +
geom_quantile (quantiles = 0.50 , color = "purple" ) +
geom_quantile (quantiles = 0.75 , color = "cyan4" ) +
scale_color_manual (values = outlier_colors) +
facet_wrap (~ ID) +
theme_light () +
labs (
title = "Quantile regression on data with non-constant variance" ,
subtitle = "Ames, Iowa, October 2023" ,
x = "Stay In time at the feeders" ,
y = "Feed Intake" ,
caption = "Example of phenotypic data performing a quantile regression model"
) +
theme (
axis.title = element_text (size = 10 ),
axis.text = element_text (size = 8 , color = "darkgray" ),
axis.ticks = element_line (size = 3 ),
plot.title = element_text (size = 20 , color = "darkblue" )
)
my_plot3
Smoothing formula not specified. Using: y ~ x
Smoothing formula not specified. Using: y ~ x
Smoothing formula not specified. Using: y ~ x
ggsave ("ggplot_FOUR_ID.png" , plot = my_plot, width = 8 , height = 6 , dpi = 300 )
Smoothing formula not specified. Using: y ~ x
Smoothing formula not specified. Using: y ~ x
Smoothing formula not specified. Using: y ~ x
Smoothing formula not specified. Using: y ~ x
Smoothing formula not specified. Using: y ~ x
Smoothing formula not specified. Using: y ~ x
Smoothing formula not specified. Using: y ~ x
Smoothing formula not specified. Using: y ~ x
Smoothing formula not specified. Using: y ~ x
Smoothing formula not specified. Using: y ~ x
Smoothing formula not specified. Using: y ~ x
Smoothing formula not specified. Using: y ~ x
ggsave ("ggplot_ONE_ID.png" , plot = my_plot3, width = 8 , height = 6 , dpi = 300 )
Smoothing formula not specified. Using: y ~ x
Smoothing formula not specified. Using: y ~ x
Smoothing formula not specified. Using: y ~ x
#| warning: true
#| echo: true
#| label:progressive outlier detection summary_DAYS_IN_FEED
outliers_progressive = list ()
j = 1
data_PIC_partial <- filter (data_PIC
, DAYS_IN_FEED <= 14 )
storage_bygroup <- perform_quantile_regression (data_PIC_partial,
quantiles = quantiles)
storage_id_data1 <- id_data1_outlier (storage_bygroup, quantiles = c (0.25 , 0.75 ))
outliers_progressive[[j]]= storage_id_data1
for (i in 15 : 68 ) {
j = j+ 1
data_PIC_partial <- filter (data_PIC
, DAYS_IN_FEED <= i)
storage_bygroup <- perform_quantile_regression (data_PIC_partial,
quantiles = quantiles)
storage_id_data1 <- id_data1_outlier (storage_bygroup, quantiles = c (0.25 , 0.75 ))
storage_id_data1 <- filter (storage_id_data1, DAYS_IN_FEED == i)
outliers_progressive[[j]]= storage_id_data1
}
storage_id_data1 <- bind_rows (outliers_progressive)
dim (storage_id_data1)
length (storage_id_data1)
# A tibble: 6 x 32
# Groups: ID [3]
ID LINE SIRE DAM LITTER PEN FARM ENTRY_TIME EXIT_TIME STAY_IN
<int> <int> <int> <int> <int> <chr> <int> <chr> <chr> <int>
1 96251326 65 91032775 9.22e7 7.80e7 B0113 774 10/27/202~ 10/27/20~ 649
2 96251327 65 91032775 9.22e7 7.80e7 B0113 774 10/27/202~ 10/27/20~ 1948
3 96251327 65 91032775 9.22e7 7.80e7 B0113 774 10/27/202~ 10/27/20~ 169
4 96284921 65 90218081 9.02e7 7.81e7 B0113 774 10/27/202~ 10/27/20~ 627
5 96284921 65 90218081 9.02e7 7.81e7 B0113 774 10/27/202~ 10/27/20~ 768
6 96284921 65 90218081 9.02e7 7.81e7 B0113 774 10/27/202~ 10/27/20~ 413
# i 22 more variables: FEED_INTK <int>, ENTRY_WT <int>, EXIT_WT <int>,
# FEEDER_NO <int>, START_DAY <chr>, OFFTEST_DAY <chr>, day_0 <date>,
# ENTRY_DATE <date>, DAYS_IN_FEED <dbl>, Q1 <dbl>, Q2 <dbl>, Q3 <dbl>,
# IQR <dbl>, LB <dbl>, UP <dbl>, ol <lgl>, Q1U <dbl>, Q3U <dbl>, IQRU <dbl>,
# UBU <dbl>, LBU <dbl>, ol2 <lgl>
# A tibble: 6 x 32
# Groups: ID [4]
ID LINE SIRE DAM LITTER PEN FARM ENTRY_TIME EXIT_TIME STAY_IN
<int> <int> <int> <int> <int> <chr> <int> <chr> <chr> <int>
1 96587429 65 87591163 8.92e7 7.82e7 B0506 774 1/30/2023~ 1/30/202~ 1152
2 96587429 65 87591163 8.92e7 7.82e7 B0506 774 1/30/2023~ 1/30/202~ 360
3 96600204 65 92013924 8.94e7 7.82e7 B0506 774 1/30/2023~ 1/30/202~ 465
4 96600204 65 92013924 8.94e7 7.82e7 B0506 774 1/30/2023~ 1/30/202~ 26
5 96601076 65 92013924 9.11e7 7.82e7 B0506 774 1/30/2023~ 1/30/202~ 1529
6 96601065 65 92013924 8.82e7 7.82e7 B0506 774 1/30/2023~ 1/30/202~ 70
# i 22 more variables: FEED_INTK <int>, ENTRY_WT <int>, EXIT_WT <int>,
# FEEDER_NO <int>, START_DAY <chr>, OFFTEST_DAY <chr>, day_0 <date>,
# ENTRY_DATE <date>, DAYS_IN_FEED <dbl>, Q1 <dbl>, Q2 <dbl>, Q3 <dbl>,
# IQR <dbl>, LB <dbl>, UP <dbl>, ol <lgl>, Q1U <dbl>, Q3U <dbl>, IQRU <dbl>,
# UBU <dbl>, LBU <dbl>, ol2 <lgl>
(t (sapply (outliers_progressive, dim)))
[,1] [,2]
[1,] 28825 32
[2,] 2069 32
[3,] 1896 32
[4,] 2012 32
[5,] 1905 32
[6,] 1899 32
[7,] 1928 32
[8,] 1831 32
[9,] 1672 32
[10,] 1673 32
[11,] 1597 32
[12,] 1636 32
[13,] 1646 32
[14,] 1593 32
[15,] 1673 32
[16,] 1601 32
[17,] 1640 32
[18,] 1603 32
[19,] 1650 32
[20,] 1691 32
[21,] 1720 32
[22,] 1773 32
[23,] 1576 32
[24,] 1661 32
[25,] 1617 32
[26,] 1587 32
[27,] 1612 32
[28,] 1548 32
[29,] 1648 32
[30,] 1626 32
[31,] 1656 32
[32,] 1609 32
[33,] 1619 32
[34,] 1678 32
[35,] 1651 32
[36,] 1717 32
[37,] 1686 32
[38,] 1658 32
[39,] 1750 32
[40,] 1808 32
[41,] 1708 32
[42,] 1773 32
[43,] 1724 32
[44,] 1735 32
[45,] 1664 32
[46,] 1681 32
[47,] 1516 32
[48,] 1208 32
[49,] 1101 32
[50,] 1100 32
[51,] 1120 32
[52,] 1120 32
[53,] 1114 32
[54,] 425 32
[55,] 9 32
table (data_PIC$ DAYS_IN_FEED)
-364 -1 0 1 2 3 4 5 6 7 8 9 10 11 12 13
6 562 1688 1603 1667 1788 1823 1852 1779 1975 1933 2151 2061 1964 2103 1899
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
1971 2069 1896 2012 1905 1899 1928 1831 1672 1673 1597 1636 1646 1593 1673 1601
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
1640 1603 1650 1691 1720 1773 1576 1661 1617 1587 1612 1548 1648 1626 1656 1609
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
1619 1678 1651 1717 1686 1658 1750 1808 1708 1773 1724 1735 1664 1681 1516 1208
62 63 64 65 66 67 68
1101 1100 1120 1120 1114 425 9
#| warning: true
#| echo: true
#| label:progressive outlier summary
storage_id_data1= mutate (storage_id_data1, olf= ol| ol2, olc = ol* 2 + ol2 )
table (storage_id_data1$ olc)
0 1 2 3
106685 894 6616 43
# A tibble: 6 x 34
# Groups: ID [3]
ID LINE SIRE DAM LITTER PEN FARM ENTRY_TIME EXIT_TIME STAY_IN
<int> <int> <int> <int> <int> <chr> <int> <chr> <chr> <int>
1 96251326 65 91032775 9.22e7 7.80e7 B0113 774 10/27/202~ 10/27/20~ 649
2 96251327 65 91032775 9.22e7 7.80e7 B0113 774 10/27/202~ 10/27/20~ 1948
3 96251327 65 91032775 9.22e7 7.80e7 B0113 774 10/27/202~ 10/27/20~ 169
4 96284921 65 90218081 9.02e7 7.81e7 B0113 774 10/27/202~ 10/27/20~ 627
5 96284921 65 90218081 9.02e7 7.81e7 B0113 774 10/27/202~ 10/27/20~ 768
6 96284921 65 90218081 9.02e7 7.81e7 B0113 774 10/27/202~ 10/27/20~ 413
# i 24 more variables: FEED_INTK <int>, ENTRY_WT <int>, EXIT_WT <int>,
# FEEDER_NO <int>, START_DAY <chr>, OFFTEST_DAY <chr>, day_0 <date>,
# ENTRY_DATE <date>, DAYS_IN_FEED <dbl>, Q1 <dbl>, Q2 <dbl>, Q3 <dbl>,
# IQR <dbl>, LB <dbl>, UP <dbl>, ol <lgl>, Q1U <dbl>, Q3U <dbl>, IQRU <dbl>,
# UBU <dbl>, LBU <dbl>, ol2 <lgl>, olf <lgl>, olc <dbl>
full_outliers <- storage_id_data1
table (storage_id_data1$ olc)
0 1 2 3
106685 894 6616 43
outlier_frequencies <- table (storage_id_data1$ olc)
outlier_percentages <- (outlier_frequencies / nrow (storage_id_data1)) * 100
outlier_summary <- data.frame (Frequencies = outlier_frequencies, Percentages = outlier_percentages)
print (outlier_summary)
Frequencies.Var1 Frequencies.Freq Percentages.Var1 Percentages.Freq
1 0 106685 0 93.38836464
2 1 894 1 0.78257673
3 2 6616 2 5.79141792
4 3 43 3 0.03764071
#Per ID##
id_frequencies <- table (storage_id_data1$ ID, storage_id_data1$ olc)
id_frequencies
0 1 2 3
96251326 170 0 23 0
96251327 135 0 1 0
96251328 124 1 96 0
96251346 193 0 1 0
96263569 136 0 64 0
96263570 203 0 5 0
96263592 249 0 66 0
96263593 249 0 4 0
96263594 170 0 7 0
96263848 244 0 0 0
96263849 248 0 2 0
96284921 202 0 1 0
96284922 215 0 1 0
96284923 211 0 1 0
96284927 149 0 10 0
96329097 179 0 2 0
96329098 217 0 1 0
96329099 219 0 5 0
96329100 172 0 49 0
96329103 184 0 0 0
96329105 340 7 42 1
96329106 188 1 3 0
96329107 219 0 6 0
96329111 147 0 6 0
96329112 283 0 13 0
96329113 201 0 23 0
96329115 212 0 19 0
96336569 175 0 4 0
96336570 224 0 1 0
96336578 257 0 2 0
96336579 208 0 0 0
96336591 237 0 1 0
96336596 189 0 0 0
96336598 199 0 5 0
96336601 216 0 1 0
96351936 71 0 54 0
96352145 177 0 1 0
96352149 176 0 8 0
96352158 103 1 1 0
96354524 199 0 1 0
96354533 212 0 7 0
96354534 236 0 3 0
96378634 227 0 2 0
96388718 183 0 0 0
96388719 246 0 3 0
96388720 201 1 3 0
96388721 194 0 2 0
96388725 253 7 10 0
96388736 163 0 0 0
96388745 181 0 2 0
96388746 214 4 2 0
96388747 224 0 0 0
96388748 37 0 107 0
96411292 173 0 0 0
96411293 250 0 1 0
96411302 168 0 1 0
96426059 232 0 1 0
96426080 276 1 0 0
96426245 191 0 0 0
96426258 240 0 1 0
96426261 292 0 1 0
96426262 200 0 3 0
96426373 250 0 4 0
96426375 186 1 5 0
96426378 206 1 2 0
96426379 221 0 3 0
96437502 211 0 6 0
96437546 335 1 8 1
96437558 201 0 6 0
96437643 152 0 4 0
96437644 158 1 27 0
96437706 187 0 5 0
96437722 174 0 2 0
96437726 205 0 3 0
96437729 192 1 6 0
96437730 262 0 3 0
96437743 174 0 1 0
96437917 204 0 0 0
96449413 189 0 0 0
96449421 153 6 49 0
96449432 143 0 9 0
96449435 189 0 8 0
96449448 146 9 13 0
96449461 235 0 4 0
96449466 185 0 1 0
96466410 149 16 8 1
96466411 124 0 42 0
96466413 139 1 16 1
96466420 120 0 1 0
96479452 171 5 74 0
96479456 147 0 6 0
96479471 206 1 13 0
96500686 183 7 2 0
96508440 260 0 9 0
96508442 233 0 4 0
96508443 304 0 14 0
96515289 203 0 38 0
96515292 376 0 4 0
96515296 148 0 1 0
96515302 257 1 3 0
96515303 224 0 1 0
96515304 194 0 7 0
96515305 189 0 9 0
96525556 217 1 2 0
96525594 213 0 1 0
96525840 306 0 9 0
96525846 207 1 11 0
96525847 241 0 57 0
96526087 288 0 14 0
96526101 269 18 14 0
96526102 319 0 8 0
96535149 331 0 5 0
96535150 223 0 16 0
96535151 194 0 0 0
96535152 216 0 19 0
96554667 178 0 15 0
96554668 179 0 58 0
96554669 286 49 4 1
96554670 173 0 22 0
96554676 159 0 9 0
96554678 142 0 27 0
96554679 193 0 7 0
96573973 122 4 139 0
96587411 179 0 1 0
96587424 145 2 2 0
96587426 119 0 6 0
96587427 99 0 2 0
96587428 130 0 0 0
96587429 184 0 0 0
96587437 120 1 1 0
96587439 99 0 55 0
96600078 185 0 1 0
96600199 164 0 3 0
96600204 139 0 12 0
96601065 162 0 0 0
96601075 222 0 10 0
96601076 221 0 2 0
96700367 145 0 100 0
96700401 230 0 3 0
96718260 216 3 3 0
96718263 193 0 3 0
96718330 184 0 9 0
96718348 202 1 5 0
96718394 189 0 1 0
96718395 418 1 1 0
96718397 221 2 47 0
96740219 260 0 3 0
96751302 229 0 23 0
96751350 276 2 9 0
96751368 310 0 4 0
96751370 240 2 7 0
96751392 196 2 5 0
96767514 212 0 5 0
96767872 262 2 11 0
96789743 190 0 4 0
96789838 155 0 46 0
96804877 246 0 12 0
96804883 217 0 1 0
96804896 176 0 2 0
96804950 152 0 43 1
96804972 315 0 4 0
96814444 151 0 111 0
96814452 197 49 9 0
96814455 256 0 1 0
96814487 203 3 5 0
96814490 303 0 1 0
96814494 241 0 7 0
96814510 198 0 3 0
96920449 192 17 27 1
96920460 130 0 54 0
96935899 201 7 9 0
96935906 176 0 12 0
96935908 177 0 4 0
96935923 146 0 33 0
96954301 193 5 7 1
96954425 215 0 8 0
96954427 194 14 26 1
96954436 172 17 25 2
96954450 144 0 5 0
96954479 167 0 16 0
96967605 100 6 6 0
96967675 150 29 23 1
97018983 138 0 20 0
97018985 155 0 34 0
97018989 138 0 4 0
97018990 195 0 2 0
97019116 152 0 0 0
97019137 224 1 11 0
97019138 184 0 2 0
97019271 204 0 5 0
97019275 177 0 1 0
97040416 106 1 105 1
97040422 222 0 0 0
97040428 169 0 2 0
97040431 145 1 0 0
97040432 121 0 0 0
97040443 215 0 2 0
97056774 118 3 0 1
97091383 223 0 2 0
97091386 156 0 6 0
97091421 142 0 5 0
97091422 203 0 0 0
97091428 225 0 2 0
97091438 150 0 63 0
97091491 98 0 66 0
97091492 152 7 12 0
97091524 244 0 0 0
97107441 235 4 5 0
97107501 214 0 1 0
97107553 186 0 4 0
97107574 216 2 3 0
97107584 164 0 0 0
97107587 219 0 1 0
97107601 187 0 19 0
97107627 230 0 1 0
97107668 187 1 4 0
97107674 306 2 3 0
97107675 191 0 3 0
97107692 193 3 3 0
97107709 181 0 2 0
97107715 163 0 3 0
97107719 217 2 3 0
97107830 128 0 113 0
97107840 183 0 0 0
97107874 214 2 4 0
97124745 112 0 72 0
97124774 146 0 3 0
97124782 190 0 3 0
97124789 186 1 1 0
97166077 229 0 2 0
97166129 197 0 0 0
97166163 207 1 4 0
97177930 220 3 9 0
97177935 127 0 4 0
97177969 226 0 2 0
97177973 217 0 6 0
97177992 152 3 5 0
97177995 245 1 1 0
97178017 183 0 16 0
97178035 155 1 3 0
97178041 190 0 7 0
97178057 198 9 0 0
97178062 212 0 1 0
97178069 251 1 2 0
97178075 173 1 15 0
97178081 182 0 7 0
97178088 123 1 2 0
97178097 164 0 1 1
97178100 208 0 11 0
97178138 252 0 2 0
97178224 234 2 36 0
97178318 174 4 7 0
97178346 188 1 1 0
97178347 197 0 8 0
97191094 234 1 2 0
97191138 165 23 15 0
97191147 168 5 5 0
97191193 107 1 1 0
97191206 127 0 2 0
97246325 142 0 4 0
97257249 102 0 6 0
97257312 119 1 2 0
97257313 133 7 17 2
97257314 174 1 7 0
97257315 175 0 5 0
97257316 155 3 21 0
97257596 147 0 15 0
97257713 230 0 5 0
97257714 145 1 19 0
97257715 142 0 12 0
97257716 164 0 6 0
97257717 158 0 4 0
97257718 147 0 5 1
97257742 160 4 4 0
97257747 160 0 1 0
97257792 171 0 5 0
97257832 193 12 7 0
97257833 160 4 17 0
97257834 302 2 5 0
97257835 175 0 5 0
97274848 212 0 6 0
97274851 181 0 1 0
97274881 101 0 3 0
97274908 342 18 3 0
97274913 201 15 6 0
97274924 243 14 7 0
97274932 132 0 12 0
97274940 110 0 0 0
97274970 129 1 7 0
97274971 185 15 8 0
97274982 170 14 5 0
97331515 208 0 4 0
97331519 256 0 2 0
97331606 318 0 4 0
97331609 222 1 73 0
97331612 245 0 5 0
97331618 205 1 6 0
97331621 201 0 37 0
97331622 226 8 7 0
97331623 202 0 1 0
97331761 218 1 0 0
97331764 198 2 3 0
97331765 249 1 3 0
97331772 215 0 5 0
97331779 184 0 5 0
97348833 290 10 7 0
97348839 229 0 11 0
97369612 189 3 3 0
97369627 209 0 39 0
97369644 173 0 7 0
97369649 273 39 20 1
97369651 282 52 8 2
97369662 166 0 6 0
97369670 224 2 14 0
97386249 165 13 25 1
97386251 254 1 5 0
97386254 179 0 7 0
97386262 256 22 24 4
97386280 182 0 50 0
97386307 182 4 12 0
97386339 191 10 40 1
97395107 193 0 10 0
97395168 192 0 11 0
97413579 261 0 0 0
97413762 213 0 51 0
97413776 254 0 3 0
97413835 265 0 0 0
97413841 194 1 0 0
97413847 309 0 2 0
97413873 340 0 4 0
97430939 199 0 1 0
97430948 200 0 23 0
97447271 213 3 0 1
97447356 168 0 3 0
97503205 215 0 19 0
97503220 259 22 16 1
97503247 156 0 60 0
97503250 160 0 12 2
97503252 158 0 1 1
97503364 275 1 2 0
97503498 273 7 10 0
97503536 219 14 19 1
97503662 191 0 15 0
97503754 229 0 8 1
97503777 265 0 64 1
97503779 178 0 7 0
97527871 198 0 37 2
97527886 172 1 92 3
97527915 267 1 55 0
97527961 128 0 9 1
97573957 212 0 0 0
97573975 213 0 1 0
97573995 270 1 3 0
97574068 196 0 3 0
97574075 176 0 2 0
97574310 209 2 11 0
97574347 283 1 2 0
97574411 116 0 12 0
97595610 105 3 69 0
97595693 100 0 103 0
97595710 218 0 3 0
97595737 225 1 0 0
97595828 332 3 1 0
97595847 186 0 2 0
97595852 186 0 78 0
97687408 136 0 23 0
97725548 179 2 5 0
97725549 176 0 10 0
97725550 170 0 17 0
97725552 214 0 17 0
97734349 211 0 6 0
97734519 245 1 16 0
97734521 173 0 9 0
97734522 212 0 12 0
97745649 283 0 25 0
97745656 158 0 23 0
97745675 172 0 5 0
97745676 184 4 7 0
97756377 225 3 11 0
97756378 113 1 26 0
97756384 171 0 7 0
97805156 139 0 2 0
97805268 225 0 2 0
97805279 232 0 3 0
97818325 170 0 0 0
97818352 138 2 6 0
97818574 193 0 1 0
97818587 197 0 4 0
97818598 131 0 1 0
97818683 152 3 5 0
97818686 154 0 1 0
97818711 162 0 6 0
97828750 182 0 3 0
97877787 252 0 0 0
97877789 252 1 1 0
97877791 118 3 46 0
97877792 219 0 29 0
97887754 131 0 0 0
97887755 138 0 1 0
97887808 361 0 1 0
97887841 160 0 5 0
97887845 265 0 2 0
97887847 226 0 42 0
97887848 252 0 1 0
97887849 158 0 24 0
97887850 265 0 0 0
97887851 127 0 27 0
97900208 267 0 1 0
97900222 150 0 13 0
97900231 189 0 2 0
97900275 196 0 1 0
97900390 203 0 4 0
97900438 213 0 24 0
97900463 51 1 82 0
97900486 271 2 37 0
97900489 208 0 1 0
97900500 164 0 4 0
97900523 133 0 75 0
97900559 246 1 6 0
97900577 165 0 6 0
97900590 168 0 1 0
97900594 177 0 0 0
97900600 231 0 23 0
97916803 173 0 1 0
97916804 187 0 4 0
97916874 249 4 0 0
97916929 146 0 77 0
97916940 222 0 0 1
97916970 247 3 5 0
97975754 147 1 6 0
97975836 86 0 99 0
97989023 221 0 0 0
97989292 266 0 1 0
97989303 182 0 1 0
97989366 118 0 96 0
97989418 236 1 0 0
97989419 188 0 17 0
97989456 239 0 5 0
98009706 197 0 2 0
98009744 205 0 2 0
98028673 255 0 0 0
98028708 179 1 1 0
98028761 135 0 28 0
98028775 224 0 1 0
98028797 163 0 1 0
98046350 36 0 87 0
98046360 109 0 50 0
98046376 211 1 7 0
98046404 81 0 167 0
98046423 203 0 1 0
98046426 279 58 10 0
98046504 254 0 3 0
98046505 187 0 5 0
98060602 206 0 8 0
98060624 211 0 3 0
98060651 270 0 3 0
98064866 246 0 7 0
98064867 112 0 13 0
98064919 148 0 4 0
98064944 208 0 1 0
98064952 125 5 1 0
98064957 163 1 5 0
98064963 178 0 1 0
98064975 131 0 31 0
98077938 168 0 0 0
98077955 262 0 2 0
98078010 148 0 1 0
98078013 169 0 2 0
98078039 204 1 4 0
98078056 171 0 3 0
98078063 153 0 1 0
98078066 103 3 1 0
98078086 209 1 0 0
98078091 189 0 0 0
98078270 207 0 0 0
98078287 176 0 3 0
98078326 193 0 2 0
98078331 174 0 3 0
98078354 137 0 19 0
98078358 118 0 71 0
98078360 130 1 1 0
98078402 246 1 0 0
98078405 180 1 3 0
98078406 202 0 12 0
98078425 200 12 10 0
98078428 185 13 12 0
98101510 226 0 7 0
98101593 303 0 3 0
98158010 193 0 4 0
98158069 165 0 1 0
98158087 275 0 1 0
98158105 188 0 1 0
98158108 162 0 1 0
98165337 159 0 0 0
98165366 132 0 23 0
98165370 145 0 0 0
98165378 185 0 0 0
98165415 200 0 0 0
98165419 169 0 15 0
98165465 154 0 1 0
98165482 160 0 1 0
98185065 222 0 4 0
98185106 177 0 50 0
98196730 194 0 2 0
98196770 244 1 1 0
98196775 188 0 14 0
98196795 200 0 1 0
98196801 268 0 0 0
98196826 278 0 2 0
98196841 212 0 0 0
98218333 157 0 3 0
98235551 166 0 3 0
98235565 186 0 2 0
98235617 235 0 0 0
98235721 210 0 2 0
98235822 221 0 2 0
98235830 217 0 5 0
98235836 156 0 4 0
98235844 200 0 11 0
98235850 202 0 7 0
98235880 160 0 1 0
98241798 228 0 6 0
98241843 131 0 8 0
98241875 185 0 6 0
98241936 188 0 2 0
98245799 177 0 3 0
98245825 226 0 3 0
98245827 188 0 3 0
98260574 150 0 6 0
98260607 150 0 14 0
98260667 250 0 27 0
98260697 233 2 7 0
98260704 207 1 4 0
98260715 191 0 4 0
98332707 127 0 2 0
98332755 137 0 3 0
98332782 124 4 2 0
98332803 126 1 17 0
98332806 164 0 1 0
98333081 174 0 2 0
98333082 132 10 1 1
98340247 283 0 2 0
98350809 126 0 63 0
98350845 192 0 1 0
98350859 252 0 3 0
98350892 194 0 0 0
98350934 206 0 3 0
98368540 172 0 1 0
f <- (1 * id_frequencies > 0 )
colSums (f)/ nrow (f)
0 1 2 3
1.00000000 0.28102190 0.89416058 0.06021898
0 1 2 3
194.68065693 1.63138686 12.07299270 0.07846715
#| warning: true
#| echo: true
#| label:progressive outlier summary_DAYS_IN_FEED
id_frequencies1 <- table (storage_id_data1$ DAYS_IN_FEED, storage_id_data1$ olc)
id_frequencies1
0 1 2 3
-364 6 0 0 0
-1 547 0 13 2
0 1648 7 31 2
1 1533 16 53 1
2 1599 11 55 2
3 1684 17 87 0
4 1719 20 84 0
5 1754 25 73 0
6 1685 26 65 3
7 1875 32 68 0
8 1825 27 79 2
9 2028 34 89 0
10 1907 35 119 0
11 1820 45 98 1
12 1932 40 129 2
13 1751 44 102 2
14 1819 42 110 0
15 1892 40 136 1
16 1752 40 102 2
17 1867 29 111 5
18 1753 38 112 2
19 1754 30 115 0
20 1777 33 117 1
21 1710 27 93 1
22 1561 18 93 0
23 1567 19 86 1
24 1501 24 71 1
25 1540 12 83 1
26 1553 11 81 1
27 1515 11 67 0
28 1581 13 79 0
29 1493 11 97 0
30 1530 10 100 0
31 1509 9 85 0
32 1572 3 75 0
33 1593 6 91 1
34 1621 3 96 0
35 1689 6 78 0
36 1489 5 82 0
37 1557 4 100 0
38 1521 5 91 0
39 1504 7 76 0
40 1506 3 103 0
41 1430 4 114 0
42 1536 1 111 0
43 1531 4 91 0
44 1545 5 106 0
45 1499 6 104 0
46 1499 1 119 0
47 1564 1 113 0
48 1506 1 144 0
49 1591 5 121 0
50 1560 1 125 0
51 1545 1 112 0
52 1626 3 119 2
53 1673 7 127 1
54 1557 1 150 0
55 1624 1 148 0
56 1607 2 115 0
57 1608 2 125 0
58 1545 1 118 0
59 1567 1 113 0
60 1425 2 89 0
61 1118 1 89 0
62 1026 0 75 0
63 1010 0 88 2
64 1025 1 93 1
65 1025 1 94 0
66 1005 1 106 2
67 391 2 31 1
68 8 0 1 0
df_id_frequencies1 <- data.frame (
Days = rownames (id_frequencies1),
No_Outlier = id_frequencies1[, 1 ],
IR = id_frequencies1[, 2 ],
VL = id_frequencies1[, 3 ],
Both = id_frequencies1[, 4 ]
)
df_id_frequencies1
Days No_Outlier IR VL Both
-364 -364 6 0 0 0
-1 -1 547 0 13 2
0 0 1648 7 31 2
1 1 1533 16 53 1
2 2 1599 11 55 2
3 3 1684 17 87 0
4 4 1719 20 84 0
5 5 1754 25 73 0
6 6 1685 26 65 3
7 7 1875 32 68 0
8 8 1825 27 79 2
9 9 2028 34 89 0
10 10 1907 35 119 0
11 11 1820 45 98 1
12 12 1932 40 129 2
13 13 1751 44 102 2
14 14 1819 42 110 0
15 15 1892 40 136 1
16 16 1752 40 102 2
17 17 1867 29 111 5
18 18 1753 38 112 2
19 19 1754 30 115 0
20 20 1777 33 117 1
21 21 1710 27 93 1
22 22 1561 18 93 0
23 23 1567 19 86 1
24 24 1501 24 71 1
25 25 1540 12 83 1
26 26 1553 11 81 1
27 27 1515 11 67 0
28 28 1581 13 79 0
29 29 1493 11 97 0
30 30 1530 10 100 0
31 31 1509 9 85 0
32 32 1572 3 75 0
33 33 1593 6 91 1
34 34 1621 3 96 0
35 35 1689 6 78 0
36 36 1489 5 82 0
37 37 1557 4 100 0
38 38 1521 5 91 0
39 39 1504 7 76 0
40 40 1506 3 103 0
41 41 1430 4 114 0
42 42 1536 1 111 0
43 43 1531 4 91 0
44 44 1545 5 106 0
45 45 1499 6 104 0
46 46 1499 1 119 0
47 47 1564 1 113 0
48 48 1506 1 144 0
49 49 1591 5 121 0
50 50 1560 1 125 0
51 51 1545 1 112 0
52 52 1626 3 119 2
53 53 1673 7 127 1
54 54 1557 1 150 0
55 55 1624 1 148 0
56 56 1607 2 115 0
57 57 1608 2 125 0
58 58 1545 1 118 0
59 59 1567 1 113 0
60 60 1425 2 89 0
61 61 1118 1 89 0
62 62 1026 0 75 0
63 63 1010 0 88 2
64 64 1025 1 93 1
65 65 1025 1 94 0
66 66 1005 1 106 2
67 67 391 2 31 1
68 68 8 0 1 0
# Filter data to exclude negative "Days" and limit to values from 1 to 68
filtered_df <- df_id_frequencies1 %>%
filter (Days >= 1 , Days <= 68 )
# Convert "Days" to a continuous variable
filtered_df$ Days <- as.numeric (filtered_df$ Days)
# Create the scatter plot with the filtered data
library (ggplot2)
ggplot (filtered_df, aes (x = Days, y = IR, size = No_Outlier)) +
geom_point (aes (color = "IR" ), shape = 16 , alpha = 0.5 ) +
geom_point (aes (x = Days, y = VL, size = No_Outlier, color = "VL" ), shape = 16 , alpha = 0.5 ) +
geom_point (aes (x = Days, y = Both, size = No_Outlier, color = "Both" ), shape = 16 , alpha = 0.5 ) +
labs (title = "Scatter Plot of Data Points by DAYS_IN_FEED and olc" ,
x = "Days" ,
y = "Value" ,
size = "No_Outlier" ) +
scale_color_manual (values = c ("IR" = "red" , "VL" = "green" , "Both" = "blue" )) +
theme_light ()
##checking that both outlier table are matching
full_outliers_olc <- table (full_outliers$ DAYS_IN_FEED, full_outliers$ olc)
full_outliers_olc
0 1 2 3
-364 6 0 0 0
-1 547 0 13 2
0 1648 7 31 2
1 1533 16 53 1
2 1599 11 55 2
3 1684 17 87 0
4 1719 20 84 0
5 1754 25 73 0
6 1685 26 65 3
7 1875 32 68 0
8 1825 27 79 2
9 2028 34 89 0
10 1907 35 119 0
11 1820 45 98 1
12 1932 40 129 2
13 1751 44 102 2
14 1819 42 110 0
15 1892 40 136 1
16 1752 40 102 2
17 1867 29 111 5
18 1753 38 112 2
19 1754 30 115 0
20 1777 33 117 1
21 1710 27 93 1
22 1561 18 93 0
23 1567 19 86 1
24 1501 24 71 1
25 1540 12 83 1
26 1553 11 81 1
27 1515 11 67 0
28 1581 13 79 0
29 1493 11 97 0
30 1530 10 100 0
31 1509 9 85 0
32 1572 3 75 0
33 1593 6 91 1
34 1621 3 96 0
35 1689 6 78 0
36 1489 5 82 0
37 1557 4 100 0
38 1521 5 91 0
39 1504 7 76 0
40 1506 3 103 0
41 1430 4 114 0
42 1536 1 111 0
43 1531 4 91 0
44 1545 5 106 0
45 1499 6 104 0
46 1499 1 119 0
47 1564 1 113 0
48 1506 1 144 0
49 1591 5 121 0
50 1560 1 125 0
51 1545 1 112 0
52 1626 3 119 2
53 1673 7 127 1
54 1557 1 150 0
55 1624 1 148 0
56 1607 2 115 0
57 1608 2 125 0
58 1545 1 118 0
59 1567 1 113 0
60 1425 2 89 0
61 1118 1 89 0
62 1026 0 75 0
63 1010 0 88 2
64 1025 1 93 1
65 1025 1 94 0
66 1005 1 106 2
67 391 2 31 1
68 8 0 1 0
id_frequencies1 <- table (storage_id_data1$ DAYS_IN_FEED, storage_id_data1$ olc)
full_outliers_olc <- table (full_outliers$ DAYS_IN_FEED, full_outliers$ olc)
merged_table <- rbind (id_frequencies1, full_outliers_olc)
merged_table
0 1 2 3
-364 6 0 0 0
-1 547 0 13 2
0 1648 7 31 2
1 1533 16 53 1
2 1599 11 55 2
3 1684 17 87 0
4 1719 20 84 0
5 1754 25 73 0
6 1685 26 65 3
7 1875 32 68 0
8 1825 27 79 2
9 2028 34 89 0
10 1907 35 119 0
11 1820 45 98 1
12 1932 40 129 2
13 1751 44 102 2
14 1819 42 110 0
15 1892 40 136 1
16 1752 40 102 2
17 1867 29 111 5
18 1753 38 112 2
19 1754 30 115 0
20 1777 33 117 1
21 1710 27 93 1
22 1561 18 93 0
23 1567 19 86 1
24 1501 24 71 1
25 1540 12 83 1
26 1553 11 81 1
27 1515 11 67 0
28 1581 13 79 0
29 1493 11 97 0
30 1530 10 100 0
31 1509 9 85 0
32 1572 3 75 0
33 1593 6 91 1
34 1621 3 96 0
35 1689 6 78 0
36 1489 5 82 0
37 1557 4 100 0
38 1521 5 91 0
39 1504 7 76 0
40 1506 3 103 0
41 1430 4 114 0
42 1536 1 111 0
43 1531 4 91 0
44 1545 5 106 0
45 1499 6 104 0
46 1499 1 119 0
47 1564 1 113 0
48 1506 1 144 0
49 1591 5 121 0
50 1560 1 125 0
51 1545 1 112 0
52 1626 3 119 2
53 1673 7 127 1
54 1557 1 150 0
55 1624 1 148 0
56 1607 2 115 0
57 1608 2 125 0
58 1545 1 118 0
59 1567 1 113 0
60 1425 2 89 0
61 1118 1 89 0
62 1026 0 75 0
63 1010 0 88 2
64 1025 1 93 1
65 1025 1 94 0
66 1005 1 106 2
67 391 2 31 1
68 8 0 1 0
-364 6 0 0 0
-1 547 0 13 2
0 1648 7 31 2
1 1533 16 53 1
2 1599 11 55 2
3 1684 17 87 0
4 1719 20 84 0
5 1754 25 73 0
6 1685 26 65 3
7 1875 32 68 0
8 1825 27 79 2
9 2028 34 89 0
10 1907 35 119 0
11 1820 45 98 1
12 1932 40 129 2
13 1751 44 102 2
14 1819 42 110 0
15 1892 40 136 1
16 1752 40 102 2
17 1867 29 111 5
18 1753 38 112 2
19 1754 30 115 0
20 1777 33 117 1
21 1710 27 93 1
22 1561 18 93 0
23 1567 19 86 1
24 1501 24 71 1
25 1540 12 83 1
26 1553 11 81 1
27 1515 11 67 0
28 1581 13 79 0
29 1493 11 97 0
30 1530 10 100 0
31 1509 9 85 0
32 1572 3 75 0
33 1593 6 91 1
34 1621 3 96 0
35 1689 6 78 0
36 1489 5 82 0
37 1557 4 100 0
38 1521 5 91 0
39 1504 7 76 0
40 1506 3 103 0
41 1430 4 114 0
42 1536 1 111 0
43 1531 4 91 0
44 1545 5 106 0
45 1499 6 104 0
46 1499 1 119 0
47 1564 1 113 0
48 1506 1 144 0
49 1591 5 121 0
50 1560 1 125 0
51 1545 1 112 0
52 1626 3 119 2
53 1673 7 127 1
54 1557 1 150 0
55 1624 1 148 0
56 1607 2 115 0
57 1608 2 125 0
58 1545 1 118 0
59 1567 1 113 0
60 1425 2 89 0
61 1118 1 89 0
62 1026 0 75 0
63 1010 0 88 2
64 1025 1 93 1
65 1025 1 94 0
66 1005 1 106 2
67 391 2 31 1
68 8 0 1 0
is_identical <- identical (id_frequencies1, full_outliers_olc)
is_identical
if (is_identical) {
cat ("The two tables are identical." )
} else {
cat ("The two tables are not identical." )
}
The two tables are identical.
if (identical (id_frequencies1, full_outliers_olc)) {
# Merge the tables if they are identical
merged_table1 <- full_outliers_olc
} else {
cat ("The two tables are not identical and cannot be merged." )
}
merged_table1
0 1 2 3
-364 6 0 0 0
-1 547 0 13 2
0 1648 7 31 2
1 1533 16 53 1
2 1599 11 55 2
3 1684 17 87 0
4 1719 20 84 0
5 1754 25 73 0
6 1685 26 65 3
7 1875 32 68 0
8 1825 27 79 2
9 2028 34 89 0
10 1907 35 119 0
11 1820 45 98 1
12 1932 40 129 2
13 1751 44 102 2
14 1819 42 110 0
15 1892 40 136 1
16 1752 40 102 2
17 1867 29 111 5
18 1753 38 112 2
19 1754 30 115 0
20 1777 33 117 1
21 1710 27 93 1
22 1561 18 93 0
23 1567 19 86 1
24 1501 24 71 1
25 1540 12 83 1
26 1553 11 81 1
27 1515 11 67 0
28 1581 13 79 0
29 1493 11 97 0
30 1530 10 100 0
31 1509 9 85 0
32 1572 3 75 0
33 1593 6 91 1
34 1621 3 96 0
35 1689 6 78 0
36 1489 5 82 0
37 1557 4 100 0
38 1521 5 91 0
39 1504 7 76 0
40 1506 3 103 0
41 1430 4 114 0
42 1536 1 111 0
43 1531 4 91 0
44 1545 5 106 0
45 1499 6 104 0
46 1499 1 119 0
47 1564 1 113 0
48 1506 1 144 0
49 1591 5 121 0
50 1560 1 125 0
51 1545 1 112 0
52 1626 3 119 2
53 1673 7 127 1
54 1557 1 150 0
55 1624 1 148 0
56 1607 2 115 0
57 1608 2 125 0
58 1545 1 118 0
59 1567 1 113 0
60 1425 2 89 0
61 1118 1 89 0
62 1026 0 75 0
63 1010 0 88 2
64 1025 1 93 1
65 1025 1 94 0
66 1005 1 106 2
67 391 2 31 1
68 8 0 1 0
outlier_colors <- c ("black" , "green" , "orange" ,"pink" )
my_plot4 <- storage_id_data1 %>%
filter (ID %in% c ("97257312" , "96954301" , "96587437" , "97178318" )) %>% # Filter data for specific IDs
ggplot (aes (x = STAY_IN, y = FEED_INTK, color = factor (olc))) +
geom_point () +
geom_point (size = 0.5 , aes (x = STAY_IN, y = UP), color = "red" ) +
geom_point (size = 0.5 , aes (x = STAY_IN, y = LB), color = "red" ) +
#geom_quantile(quantiles = 0.25, color = "blue") +
#geom_quantile(quantiles = 0.50, color = "purple") +
#geom_quantile(quantiles = 0.75, color = "cyan4") +
scale_color_manual (values = outlier_colors) +
facet_wrap (~ ID) +
theme_light () +
labs (
title = "Progressive outlier detection" ,
subtitle = "Ames, Iowa, October 2023" ,
x = "Stay In time at the feeders" ,
y = "Feed Intake" ,
caption = "Example of phenotypic data performing a outlier detection from 14 to 68 days in feed"
) +
theme (
axis.title = element_text (size = 10 ),
axis.text = element_text (size = 8 , color = "darkgray" ),
axis.ticks = element_line (size = 3 ),
plot.title = element_text (size = 20 , color = "darkblue" )
)
my_plot4
#Just ONE ID#
outlier_colors <- c ("black" , "green" , "orange" ,"pink" )
my_plot5 <- storage_id_data1 %>%
filter (ID == "97257312" ) %>% # Filter data for the specific ID
ggplot (aes (x = STAY_IN, y = FEED_INTK, color = factor (olc))) +
geom_point () +
geom_point (size = 0.5 , aes (x = STAY_IN, y = UP), color = "red" ) +
geom_point (size = 0.5 , aes (x = STAY_IN, y = LB), color = "red" ) +
#geom_quantile(quantiles = 0.25, color = "blue") +
#geom_quantile(quantiles = 0.50, color = "purple") +
#geom_quantile(quantiles = 0.75, color = "cyan4") +
scale_color_manual (values = outlier_colors) +
#facet_wrap(~ID) +
theme_light () +
labs (
title = "Progressive outlier detection" ,
subtitle = "Ames, Iowa, October 2023" ,
x = "Stay In time at the feeders" ,
y = "Feed Intake" ,
caption = "Example of phenotypic data performing a outlier detection from 14 to 68 days in feed"
) +
theme (
axis.title = element_text (size = 10 ),
axis.text = element_text (size = 8 , color = "darkgray" ),
axis.ticks = element_line (size = 3 ),
plot.title = element_text (size = 20 , color = "darkblue" )
)
my_plot5
outlier_colors <- c ("black" , "green" , "orange" , "pink" )
my_plot6 <- storage_id_data1 %>%
filter (ID == "96954301" ) %>% # Filter data for the specific ID
ggplot (aes (x = STAY_IN, y = FEED_INTK, color = factor (olc))) +
geom_point () +
geom_point (size = 0.5 , aes (x = STAY_IN, y = UP), color = "red" ) +
geom_point (size = 0.5 , aes (x = STAY_IN, y = LB), color = "red" ) +
#geom_quantile(quantiles = 0.25, color = "blue") +
#geom_quantile(quantiles = 0.50, color = "purple") +
#geom_quantile(quantiles = 0.75, color = "cyan4") +
scale_color_manual (values = outlier_colors) +
#facet_wrap(~ID) +
theme_light () +
labs (
title = "Progressive outlier detection" ,
subtitle = "Ames, Iowa, October 2023" ,
x = "Stay In time at the feeders" ,
y = "Feed Intake" ,
caption = "Example of phenotypic data performing a outlier detection from 14 to 68 days in feed"
) +
theme (
axis.title = element_text (size = 10 ),
axis.text = element_text (size = 8 , color = "darkgray" ),
axis.ticks = element_line (size = 3 ),
plot.title = element_text (size = 20 , color = "darkblue" )
)
my_plot6