Last Ran: 2022-10-03

 

0.1 Bullet

BULL.DF<-read_csv("/Volumes/IGNITE_Imaging/QC_Output/R_IGNITE/Phantom/BULET.csv")
BULL.DF<-BULL.DF[!duplicated(BULL.DF),]
BULL.DF<-BULL.DF %>% select(-SpikeCount, -Year, -Timepts)
names(BULL.DF)<-c("Site"  ,  "Date", "Scanner"    ,"Mean"    , "Pk-to-Pk", "BULL.SNR","RMS"   ,   "RDC"   ,   "Rqq"   )
BULL.DF$SubID<-"BULL"
BULL.DF$ID<-paste0(BULL.DF$SubID,"_", seq(1:nrow(BULL.DF)))
m.BULL.DF<-reshape2::melt(BULL.DF, id.vars=c("Scanner","Date", "Site", "SubID", "ID" ))
m.BULL.DF$Scanner<-as.factor(m.BULL.DF$Scanner)
m.BULL.DF<-m.BULL.DF %>%
  group_by(Scanner, variable ) %>% 
  mutate(Quarter = paste0(lubridate::year(Date),"/Q",lubridate::quarter(Date)),
                          year=format(Date, "%Y"),
                          Z=scale(value ),
                          MC=scale(value , scale=F))

0.1.1 Outlier Report(s):

m.BULL.DF.out.date<-m.BULL.DF%>% filter(Z>3 |Z<(-3)) %>% select(Scanner,year,Date, variable,value, Z, ID ) %>% group_by(Scanner, Date)%>% summarise(N_Outliers=n())
TMP<-m.BULL.DF%>% group_by(Scanner, Date ) %>% filter(Z>3 |Z<(-3))%>% select(Date, variable, value, Z, ID) 
TMP2<-TMP %>% group_by(Scanner,Date ) %>% summarise(variable=variable,
                                                    value=value,
                                                   ID=ID,
                                                   Z=Z,
                                              NOUT=n()) 

0.1.1.1 Outlier Deffinition: BULL.SNR >|< 3SD

0.1.1.2 Northeastern:

TMP2 %>% group_by( Date ) %>% filter(  variable=="BULL.SNR" &Scanner=="NUBIC") %>% select(variable, value, Z) 
tmpn<-TMP2 %>% group_by( Date ) %>% filter( variable=="BULL.SNR"&Scanner=="NUBIC") %>% select(Scanner, variable, value, Z, ID) 
0.1.1.2.1 Kansas:
TMP2 %>% group_by( Date ) %>% filter(  variable=="BULL.SNR"& Scanner=="SKYRA") %>% select(variable, value, Z) 
tmpk<-TMP2 %>% group_by( Date ) %>% filter( variable=="BULL.SNR"& Scanner=="SKYRA") %>% select(Scanner,variable, value, Z,ID) 
0.1.1.2.2 Prisma 1:
TMP2 %>% group_by( Date ) %>% filter( variable=="BULL.SNR" & Scanner=="PRISMA 1")%>% select(variable,variable, value, Z)
tmpp1<-TMP2 %>% group_by( Date ) %>% filter( variable=="BULL.SNR" & Scanner=="PRISMA 1") %>% select(Scanner,variable, value, Z, ID) 
0.1.1.2.3 Prisma 2:
TMP2 %>% group_by( Date ) %>% filter( variable=="BULL.SNR"& Scanner=="PRISMA 2") %>% select(variable)
tmpp2<-TMP2 %>% group_by( Date ) %>% filter( variable=="BULL.SNR"& Scanner=="PRISMA 2") %>% select(Scanner,variable, value, Z, ID) 
0.1.1.2.3.1 Z table & Removal of Dates with outliers
TMP3<-rbind(tmpn, tmpk, tmpp1, tmpp2)
TMP3$ID<-paste0( TMP3$Date, " ",TMP3$Scanner, " ",TMP3$ID)

m.BULL.DF$Z<-as.numeric(m.BULL.DF$Z)
m.BULL.DF$OID<-paste0( m.BULL.DF$Date, " ",m.BULL.DF$Scanner, " ",m.BULL.DF$ID)
m.BULL.DF$OUTLIER_DATE.factor<-if_else(m.BULL.DF$OID %in% TMP3$ID, 1,0)
m.BULL.DF<-m.BULL.DF %>% select(-OID)
BULLZ<-reshape2::dcast(m.BULL.DF, Scanner+Date+Site+year+Quarter+SubID+ID+OUTLIER_DATE.factor~variable, value.var = "Z")

BULL.DF<-reshape2::dcast(m.BULL.DF, Scanner+Date+Site+year+Quarter+SubID+ID+OUTLIER_DATE.factor~variable, value.var = "value")

BULL.DF_NOOUT<-BULL.DF %>% filter(OUTLIER_DATE.factor!=1)
m.BULL.DF_NOOUT<-m.BULL.DF %>%filter(OUTLIER_DATE.factor!=1)
prisma1_bullSNR_NOUT<-BULL.DF_NOOUT %>% filter(Scanner=="PRISMA 1")%>% drop_na(BULL.SNR) %>% select(Date,Scanner , BULL.SNR, Mean, `Pk-to-Pk` ,RMS,RDC,Rqq)  %>% arrange(Date) %>% mutate()
class(prisma1_bullSNR_NOUT$BULL.SNR)<-"numeric"

x <- data.frame('Mean'= prisma1_bullSNR_NOUT$Mean,
                'SNR'= prisma1_bullSNR_NOUT$BULL.SNR,
                'Pk-to-Pk'=prisma1_bullSNR_NOUT$`Pk-to-Pk`,
                'RDC'= prisma1_bullSNR_NOUT$RDC ,
                'RMS'= prisma1_bullSNR_NOUT$RMS,
                'Rqq'=prisma1_bullSNR_NOUT$Rqq )
i <- prisma1_bullSNR_NOUT$Date
ts.prisma1_bullSNR_NOUT<-zoo::zoo(x = x, order.by = i)

zoo::plot.zoo(ts.prisma1_bullSNR_NOUT)
dygraph(ts.prisma1_bullSNR_NOUT) %>% dyRangeSelector()
zoo::plot.zoo(ts.prisma1_bullSNR_NOUT)

0.1.2 Prisma 1

prisma1_bullSNR<-BULL.DF %>% filter(Scanner=="PRISMA 1")%>% drop_na(BULL.SNR) %>% select(Date,Scanner , BULL.SNR, Mean, `Pk-to-Pk` ,RMS,RDC,Rqq)  %>% arrange(Date) %>% mutate()

x <- data.frame('Mean'= prisma1_bullSNR$Mean,
                'SNR'= prisma1_bullSNR$BULL.SNR,
                'Pk-to-Pk'=prisma1_bullSNR$`Pk-to-Pk`,
                'RDC'= prisma1_bullSNR$RDC ,
                'RMS'= prisma1_bullSNR$RMS,
                'Rqq'=prisma1_bullSNR$Rqq )
i <- prisma1_bullSNR$Date
ts.prisma1_bullSNR<-zoo::zoo(x = x, order.by = i)

zoo::plot.zoo(ts.prisma1_bullSNR)
dygraph(ts.prisma1_bullSNR) %>% dyRangeSelector()
zoo::plot.zoo(ts.prisma1_bullSNR)

0.1.2.1 Mean

0.1.2.1.1 With Outlier Dates
tseries::adf.test(ts.prisma1_bullSNR$Mean)
## 
##  Augmented Dickey-Fuller Test
## 
## data:  ts.prisma1_bullSNR$Mean
## Dickey-Fuller = -4.2008, Lag order = 4, p-value = 0.01
## alternative hypothesis: stationary
0.1.2.1.2 Without Outlier Dates
tseries::adf.test(ts.prisma1_bullSNR_NOUT$Mean)
## 
##  Augmented Dickey-Fuller Test
## 
## data:  ts.prisma1_bullSNR_NOUT$Mean
## Dickey-Fuller = -4.2008, Lag order = 4, p-value = 0.01
## alternative hypothesis: stationary

0.1.2.2 SNR

0.1.2.2.1 With Outlier Dates
tseries::adf.test(ts.prisma1_bullSNR$SNR)
## 
##  Augmented Dickey-Fuller Test
## 
## data:  ts.prisma1_bullSNR$SNR
## Dickey-Fuller = -4.283, Lag order = 4, p-value = 0.01
## alternative hypothesis: stationary
0.1.2.2.2 Without Outlier Dates
tseries::adf.test(ts.prisma1_bullSNR_NOUT$SNR)
## 
##  Augmented Dickey-Fuller Test
## 
## data:  ts.prisma1_bullSNR_NOUT$SNR
## Dickey-Fuller = -4.283, Lag order = 4, p-value = 0.01
## alternative hypothesis: stationary

0.1.2.3 RDC

0.1.2.3.1 With Outlier Dates
tseries::adf.test(ts.prisma1_bullSNR$RDC)
## 
##  Augmented Dickey-Fuller Test
## 
## data:  ts.prisma1_bullSNR$RDC
## Dickey-Fuller = -4.6731, Lag order = 4, p-value = 0.01
## alternative hypothesis: stationary
0.1.2.3.2 Without Outlier Dates
tseries::adf.test(ts.prisma1_bullSNR_NOUT$RDC)
## 
##  Augmented Dickey-Fuller Test
## 
## data:  ts.prisma1_bullSNR_NOUT$RDC
## Dickey-Fuller = -4.6731, Lag order = 4, p-value = 0.01
## alternative hypothesis: stationary

0.1.2.4 RMS

0.1.2.4.1 With Outlier Dates
tseries::adf.test(ts.prisma1_bullSNR$RMS)
## 
##  Augmented Dickey-Fuller Test
## 
## data:  ts.prisma1_bullSNR$RMS
## Dickey-Fuller = -4.244, Lag order = 4, p-value = 0.01
## alternative hypothesis: stationary
0.1.2.4.2 Without Outlier Dates
tseries::adf.test(ts.prisma1_bullSNR_NOUT$RMS)
## 
##  Augmented Dickey-Fuller Test
## 
## data:  ts.prisma1_bullSNR_NOUT$RMS
## Dickey-Fuller = -4.244, Lag order = 4, p-value = 0.01
## alternative hypothesis: stationary

0.1.2.5 Rqq

0.1.2.5.1 With Outlier Dates
tseries::adf.test(ts.prisma1_bullSNR$Rqq)
## 
##  Augmented Dickey-Fuller Test
## 
## data:  ts.prisma1_bullSNR$Rqq
## Dickey-Fuller = -3.9173, Lag order = 4, p-value = 0.01603
## alternative hypothesis: stationary
0.1.2.5.2 Without Outlier Dates
tseries::adf.test(ts.prisma1_bullSNR_NOUT$Rqq)
## 
##  Augmented Dickey-Fuller Test
## 
## data:  ts.prisma1_bullSNR_NOUT$Rqq
## Dickey-Fuller = -3.9173, Lag order = 4, p-value = 0.01603
## alternative hypothesis: stationary

0.1.2.6 Pk2pk

0.1.2.6.1 With Outlier Dates
tseries::adf.test(ts.prisma1_bullSNR$Pk.to.Pk)
## 
##  Augmented Dickey-Fuller Test
## 
## data:  ts.prisma1_bullSNR$Pk.to.Pk
## Dickey-Fuller = -3.7682, Lag order = 4, p-value = 0.02322
## alternative hypothesis: stationary
0.1.2.6.2 Without Outlier Dates
tseries::adf.test(ts.prisma1_bullSNR_NOUT$Pk.to.Pk)
## 
##  Augmented Dickey-Fuller Test
## 
## data:  ts.prisma1_bullSNR_NOUT$Pk.to.Pk
## Dickey-Fuller = -3.7682, Lag order = 4, p-value = 0.02322
## alternative hypothesis: stationary

0.1.3 Prisma 2

prisma2_bullSNR<-BULL.DF %>%
  filter(Scanner=="PRISMA 2") %>% drop_na(BULL.SNR) %>% select(Date,Scanner , BULL.SNR, Mean, `Pk-to-Pk` ,RMS,RDC,Rqq)  %>% arrange(Date)

x <- data.frame('Mean'= prisma2_bullSNR$Mean,
                'SNR'= prisma2_bullSNR$BULL.SNR,
                'Pk-to-Pk'=prisma2_bullSNR$`Pk-to-Pk`,
                'RDC'= prisma2_bullSNR$RDC ,
                'RMS'= prisma2_bullSNR$RMS,
                'Rqq'=prisma2_bullSNR$Rqq )
i <- prisma2_bullSNR$Date
ts.prisma2_bullSNR<-zoo::zoo(x = x, order.by = i)

dygraph(ts.prisma2_bullSNR) %>% dyRangeSelector()
zoo::plot.zoo(ts.prisma2_bullSNR)

prisma2_bullSNR_NOUT<-BULL.DF_NOOUT %>%
  filter(Scanner=="PRISMA 2") %>% drop_na(BULL.SNR) %>% select(Date,Scanner , BULL.SNR, Mean, `Pk-to-Pk` ,RMS,RDC,Rqq)  %>% arrange(Date)

x <- data.frame('Mean'= prisma2_bullSNR_NOUT$Mean,
                'SNR'= prisma2_bullSNR_NOUT$BULL.SNR,
                'Pk-to-Pk'=prisma2_bullSNR_NOUT$`Pk-to-Pk`,
                'RDC'= prisma2_bullSNR_NOUT$RDC ,
                'RMS'= prisma2_bullSNR_NOUT$RMS,
                'Rqq'=prisma2_bullSNR_NOUT$Rqq )
i <- prisma2_bullSNR_NOUT$Date
ts.prisma2_bullSNR_NOUT<-zoo::zoo(x = x, order.by = i)

dygraph(ts.prisma2_bullSNR_NOUT) %>% dyRangeSelector()
zoo::plot.zoo(ts.prisma2_bullSNR_NOUT)

0.1.3.0.1 Mean
0.1.3.0.1.1 With Outlier Dates
tseries::adf.test(ts.prisma2_bullSNR$Mean)
## 
##  Augmented Dickey-Fuller Test
## 
## data:  ts.prisma2_bullSNR$Mean
## Dickey-Fuller = -0.80097, Lag order = 3, p-value = 0.9535
## alternative hypothesis: stationary
0.1.3.0.1.2 Without Outlier Dates
tseries::adf.test(ts.prisma2_bullSNR_NOUT$Mean)
## 
##  Augmented Dickey-Fuller Test
## 
## data:  ts.prisma2_bullSNR_NOUT$Mean
## Dickey-Fuller = -0.80097, Lag order = 3, p-value = 0.9535
## alternative hypothesis: stationary
0.1.3.0.2 SNR
0.1.3.0.2.1 With Outlier Dates
tseries::adf.test(ts.prisma2_bullSNR$SNR)
## 
##  Augmented Dickey-Fuller Test
## 
## data:  ts.prisma2_bullSNR$SNR
## Dickey-Fuller = -2.7738, Lag order = 3, p-value = 0.2692
## alternative hypothesis: stationary
0.1.3.0.2.2 Without Outlier Dates
tseries::adf.test(ts.prisma2_bullSNR_NOUT$SNR)
## 
##  Augmented Dickey-Fuller Test
## 
## data:  ts.prisma2_bullSNR_NOUT$SNR
## Dickey-Fuller = -2.7738, Lag order = 3, p-value = 0.2692
## alternative hypothesis: stationary
0.1.3.0.3 RDC
0.1.3.0.3.1 With Outlier Dates
tseries::adf.test(ts.prisma2_bullSNR$RDC)
## 
##  Augmented Dickey-Fuller Test
## 
## data:  ts.prisma2_bullSNR$RDC
## Dickey-Fuller = -2.5915, Lag order = 3, p-value = 0.3409
## alternative hypothesis: stationary
0.1.3.0.3.2 Without Outlier Dates
tseries::adf.test(ts.prisma2_bullSNR_NOUT$RDC)
## 
##  Augmented Dickey-Fuller Test
## 
## data:  ts.prisma2_bullSNR_NOUT$RDC
## Dickey-Fuller = -2.5915, Lag order = 3, p-value = 0.3409
## alternative hypothesis: stationary
0.1.3.0.4 RMS
0.1.3.0.4.1 With Outlier Dates
tseries::adf.test(ts.prisma2_bullSNR$RMS)
## 
##  Augmented Dickey-Fuller Test
## 
## data:  ts.prisma2_bullSNR$RMS
## Dickey-Fuller = -3.7196, Lag order = 3, p-value = 0.03597
## alternative hypothesis: stationary
0.1.3.0.4.2 Without Outlier Dates
tseries::adf.test(ts.prisma2_bullSNR_NOUT$RMS)
## 
##  Augmented Dickey-Fuller Test
## 
## data:  ts.prisma2_bullSNR_NOUT$RMS
## Dickey-Fuller = -3.7196, Lag order = 3, p-value = 0.03597
## alternative hypothesis: stationary
0.1.3.0.5 Rqq
0.1.3.0.5.1 With Outlier Dates
tseries::adf.test(ts.prisma2_bullSNR$Rqq)
## 
##  Augmented Dickey-Fuller Test
## 
## data:  ts.prisma2_bullSNR$Rqq
## Dickey-Fuller = -3.0502, Lag order = 3, p-value = 0.1605
## alternative hypothesis: stationary
0.1.3.0.5.2 Without Outlier Dates
tseries::adf.test(ts.prisma2_bullSNR_NOUT$Rqq)
## 
##  Augmented Dickey-Fuller Test
## 
## data:  ts.prisma2_bullSNR_NOUT$Rqq
## Dickey-Fuller = -3.0502, Lag order = 3, p-value = 0.1605
## alternative hypothesis: stationary
0.1.3.0.6 Pk2pk
0.1.3.0.6.1 With Outlier Dates
tseries::adf.test(ts.prisma2_bullSNR$Pk.to.Pk)
## 
##  Augmented Dickey-Fuller Test
## 
## data:  ts.prisma2_bullSNR$Pk.to.Pk
## Dickey-Fuller = -3.5205, Lag order = 3, p-value = 0.0529
## alternative hypothesis: stationary
0.1.3.0.6.2 Without Outlier Dates
tseries::adf.test(ts.prisma2_bullSNR_NOUT$Pk.to.Pk)
## 
##  Augmented Dickey-Fuller Test
## 
## data:  ts.prisma2_bullSNR_NOUT$Pk.to.Pk
## Dickey-Fuller = -3.5205, Lag order = 3, p-value = 0.0529
## alternative hypothesis: stationary

0.1.4 Northeastern

NUBIC2_bullSNR<-BULL.DF %>%
  filter(Scanner=="NUBIC") %>% drop_na(BULL.SNR) %>% select(Date,Scanner , BULL.SNR, Mean, `Pk-to-Pk` ,RMS,RDC,Rqq)  %>% arrange(Date)

x <- data.frame('Mean'= NUBIC2_bullSNR$Mean,
                'SNR'= NUBIC2_bullSNR$BULL.SNR,
                'Pk-to-Pk'=NUBIC2_bullSNR$`Pk-to-Pk`,
                'RDC'= NUBIC2_bullSNR$RDC ,
                'RMS'= NUBIC2_bullSNR$RMS,
                'Rqq'=NUBIC2_bullSNR$Rqq )
i <- NUBIC2_bullSNR$Date
ts.NUBIC2_bullSNR<-zoo::zoo(x = x, order.by = i)

dygraph(ts.NUBIC2_bullSNR) %>% dyRangeSelector()
zoo::plot.zoo(ts.NUBIC2_bullSNR)

NUBIC2_bullSNR_NOUT<-BULL.DF_NOOUT %>%
  filter(Scanner=="NUBIC") %>% drop_na(BULL.SNR) %>% select(Date,Scanner , BULL.SNR, Mean, `Pk-to-Pk` ,RMS,RDC,Rqq)  %>% arrange(Date)

x <- data.frame('Mean'= NUBIC2_bullSNR_NOUT$Mean,
                'SNR'= NUBIC2_bullSNR_NOUT$BULL.SNR,
                'Pk-to-Pk'=NUBIC2_bullSNR_NOUT$`Pk-to-Pk`,
                'RDC'= NUBIC2_bullSNR_NOUT$RDC ,
                'RMS'= NUBIC2_bullSNR_NOUT$RMS,
                'Rqq'=NUBIC2_bullSNR_NOUT$Rqq )
i <- NUBIC2_bullSNR_NOUT$Date
ts.NUBIC2_bullSNR_NOUT<-zoo::zoo(x = x, order.by = i)

dygraph(ts.NUBIC2_bullSNR_NOUT) %>% dyRangeSelector()
zoo::plot.zoo(ts.NUBIC2_bullSNR_NOUT)

0.1.4.0.1 Mean
0.1.4.0.1.1 With Outlier Dates
tseries::adf.test(ts.NUBIC2_bullSNR$Mean)
## 
##  Augmented Dickey-Fuller Test
## 
## data:  ts.NUBIC2_bullSNR$Mean
## Dickey-Fuller = -3.6178, Lag order = 4, p-value = 0.03486
## alternative hypothesis: stationary
0.1.4.0.1.2 Without Outlier Dates
tseries::adf.test(ts.NUBIC2_bullSNR_NOUT$Mean)
## 
##  Augmented Dickey-Fuller Test
## 
## data:  ts.NUBIC2_bullSNR_NOUT$Mean
## Dickey-Fuller = -2.953, Lag order = 4, p-value = 0.1815
## alternative hypothesis: stationary
0.1.4.0.2 SNR
0.1.4.0.2.1 With Outlier Dates
tseries::adf.test(ts.NUBIC2_bullSNR$SNR)
## 
##  Augmented Dickey-Fuller Test
## 
## data:  ts.NUBIC2_bullSNR$SNR
## Dickey-Fuller = -3.4545, Lag order = 4, p-value = 0.0495
## alternative hypothesis: stationary
0.1.4.0.2.2 Without Outlier Dates
tseries::adf.test(ts.NUBIC2_bullSNR_NOUT$SNR)
## 
##  Augmented Dickey-Fuller Test
## 
## data:  ts.NUBIC2_bullSNR_NOUT$SNR
## Dickey-Fuller = -3.9296, Lag order = 4, p-value = 0.01528
## alternative hypothesis: stationary
0.1.4.0.3 RDC
0.1.4.0.3.1 With Outlier Dates
tseries::adf.test(ts.NUBIC2_bullSNR$RDC)
## 
##  Augmented Dickey-Fuller Test
## 
## data:  ts.NUBIC2_bullSNR$RDC
## Dickey-Fuller = -4.6458, Lag order = 4, p-value = 0.01
## alternative hypothesis: stationary
0.1.4.0.3.2 Without Outlier Dates
tseries::adf.test(ts.NUBIC2_bullSNR_NOUT$RDC)
## 
##  Augmented Dickey-Fuller Test
## 
## data:  ts.NUBIC2_bullSNR_NOUT$RDC
## Dickey-Fuller = -3.6938, Lag order = 4, p-value = 0.02814
## alternative hypothesis: stationary
0.1.4.0.4 RMS
0.1.4.0.4.1 With Outlier Dates
tseries::adf.test(ts.NUBIC2_bullSNR$RMS)
## 
##  Augmented Dickey-Fuller Test
## 
## data:  ts.NUBIC2_bullSNR$RMS
## Dickey-Fuller = -3.8907, Lag order = 4, p-value = 0.01711
## alternative hypothesis: stationary
0.1.4.0.4.2 Without Outlier Dates
tseries::adf.test(ts.NUBIC2_bullSNR_NOUT$RMS)
## 
##  Augmented Dickey-Fuller Test
## 
## data:  ts.NUBIC2_bullSNR_NOUT$RMS
## Dickey-Fuller = -3.7035, Lag order = 4, p-value = 0.02728
## alternative hypothesis: stationary
0.1.4.0.5 Rqq
0.1.4.0.5.1 With Outlier Dates
tseries::adf.test(ts.NUBIC2_bullSNR$Rqq)
## 
##  Augmented Dickey-Fuller Test
## 
## data:  ts.NUBIC2_bullSNR$Rqq
## Dickey-Fuller = -3.6022, Lag order = 4, p-value = 0.03627
## alternative hypothesis: stationary
0.1.4.0.5.2 Without Outlier Dates
tseries::adf.test(ts.NUBIC2_bullSNR_NOUT$Rqq)
## 
##  Augmented Dickey-Fuller Test
## 
## data:  ts.NUBIC2_bullSNR_NOUT$Rqq
## Dickey-Fuller = -3.5174, Lag order = 4, p-value = 0.04392
## alternative hypothesis: stationary
0.1.4.0.6 Pk2pk
0.1.4.0.6.1 With Outlier Dates
tseries::adf.test(ts.NUBIC2_bullSNR$Pk.to.Pk)
## 
##  Augmented Dickey-Fuller Test
## 
## data:  ts.NUBIC2_bullSNR$Pk.to.Pk
## Dickey-Fuller = -3.9875, Lag order = 4, p-value = 0.01242
## alternative hypothesis: stationary
0.1.4.0.6.2 Without Outlier Dates
tseries::adf.test(ts.NUBIC2_bullSNR_NOUT$Pk.to.Pk)
## 
##  Augmented Dickey-Fuller Test
## 
## data:  ts.NUBIC2_bullSNR_NOUT$Pk.to.Pk
## Dickey-Fuller = -3.6893, Lag order = 4, p-value = 0.02855
## alternative hypothesis: stationary

0.1.5 Kansas

skyra2_bullSNR<-BULL.DF %>%
  filter(Scanner=="SKYRA") %>% drop_na(BULL.SNR) %>% select(Date,Scanner , BULL.SNR, Mean, `Pk-to-Pk` ,RMS,RDC,Rqq)  %>% arrange(Date)

x <- data.frame('Mean'= skyra2_bullSNR$Mean,
                'SNR'= skyra2_bullSNR$BULL.SNR,
                'Pk-to-Pk'=skyra2_bullSNR$`Pk-to-Pk`,
                'RDC'= skyra2_bullSNR$RDC ,
                'RMS'= skyra2_bullSNR$RMS,
                'Rqq'=skyra2_bullSNR$Rqq )
i <- skyra2_bullSNR$Date
ts.skyra2_bullSNR<-zoo::zoo(x = x, order.by = i)

dygraph(ts.skyra2_bullSNR) %>% dyRangeSelector()
zoo::plot.zoo(ts.skyra2_bullSNR)

skyra2_bullSNR_NOUT<-BULL.DF_NOOUT %>%
  filter(Scanner=="SKYRA") %>% drop_na(BULL.SNR) %>% select(Date,Scanner , BULL.SNR, Mean, `Pk-to-Pk` ,RMS,RDC,Rqq)  %>% arrange(Date)

x <- data.frame('Mean'= skyra2_bullSNR_NOUT$Mean,
                'SNR'= skyra2_bullSNR_NOUT$BULL.SNR,
                'Pk-to-Pk'=skyra2_bullSNR_NOUT$`Pk-to-Pk`,
                'RDC'= skyra2_bullSNR_NOUT$RDC ,
                'RMS'= skyra2_bullSNR_NOUT$RMS,
                'Rqq'=skyra2_bullSNR_NOUT$Rqq )
i <- skyra2_bullSNR_NOUT$Date
ts.skyra2_bullSNR_NOUT<-zoo::zoo(x = x, order.by = i)

dygraph(ts.skyra2_bullSNR_NOUT) %>% dyRangeSelector()
zoo::plot.zoo(ts.skyra2_bullSNR_NOUT)

0.1.5.0.1 Mean
0.1.5.0.1.1 With Outlier Dates
tseries::adf.test(ts.skyra2_bullSNR$Mean)
## 
##  Augmented Dickey-Fuller Test
## 
## data:  ts.skyra2_bullSNR$Mean
## Dickey-Fuller = -1.7642, Lag order = 4, p-value = 0.6745
## alternative hypothesis: stationary
0.1.5.0.1.2 Without Outlier Dates
tseries::adf.test(ts.skyra2_bullSNR_NOUT$Mean)
## 
##  Augmented Dickey-Fuller Test
## 
## data:  ts.skyra2_bullSNR_NOUT$Mean
## Dickey-Fuller = -1.6506, Lag order = 4, p-value = 0.7217
## alternative hypothesis: stationary
0.1.5.0.2 SNR
0.1.5.0.2.1 With Outlier Dates
tseries::adf.test(ts.skyra2_bullSNR$SNR)
## 
##  Augmented Dickey-Fuller Test
## 
## data:  ts.skyra2_bullSNR$SNR
## Dickey-Fuller = -2.5214, Lag order = 4, p-value = 0.3599
## alternative hypothesis: stationary
0.1.5.0.2.2 Without Outlier Dates
tseries::adf.test(ts.skyra2_bullSNR_NOUT$SNR)
## 
##  Augmented Dickey-Fuller Test
## 
## data:  ts.skyra2_bullSNR_NOUT$SNR
## Dickey-Fuller = -2.2981, Lag order = 4, p-value = 0.4527
## alternative hypothesis: stationary
0.1.5.0.3 RDC
0.1.5.0.3.1 With Outlier Dates
tseries::adf.test(ts.skyra2_bullSNR$RDC)
## 
##  Augmented Dickey-Fuller Test
## 
## data:  ts.skyra2_bullSNR$RDC
## Dickey-Fuller = -3.234, Lag order = 4, p-value = 0.08544
## alternative hypothesis: stationary
0.1.5.0.3.2 Without Outlier Dates
tseries::adf.test(ts.skyra2_bullSNR_NOUT$RDC)
## 
##  Augmented Dickey-Fuller Test
## 
## data:  ts.skyra2_bullSNR_NOUT$RDC
## Dickey-Fuller = -3.2658, Lag order = 4, p-value = 0.0802
## alternative hypothesis: stationary
0.1.5.0.4 RMS
0.1.5.0.4.1 With Outlier Dates
tseries::adf.test(ts.skyra2_bullSNR$RMS)
## 
##  Augmented Dickey-Fuller Test
## 
## data:  ts.skyra2_bullSNR$RMS
## Dickey-Fuller = -3.3421, Lag order = 4, p-value = 0.06743
## alternative hypothesis: stationary
0.1.5.0.4.2 Without Outlier Dates
tseries::adf.test(ts.skyra2_bullSNR_NOUT$RMS)
## 
##  Augmented Dickey-Fuller Test
## 
## data:  ts.skyra2_bullSNR_NOUT$RMS
## Dickey-Fuller = -3.6852, Lag order = 4, p-value = 0.02849
## alternative hypothesis: stationary
0.1.5.0.5 Rqq
0.1.5.0.5.1 With Outlier Dates
tseries::adf.test(ts.skyra2_bullSNR$Rqq)
## 
##  Augmented Dickey-Fuller Test
## 
## data:  ts.skyra2_bullSNR$Rqq
## Dickey-Fuller = -3.9554, Lag order = 4, p-value = 0.01371
## alternative hypothesis: stationary
0.1.5.0.5.2 Without Outlier Dates
tseries::adf.test(ts.skyra2_bullSNR_NOUT$Rqq)
## 
##  Augmented Dickey-Fuller Test
## 
## data:  ts.skyra2_bullSNR_NOUT$Rqq
## Dickey-Fuller = -3.9135, Lag order = 4, p-value = 0.01578
## alternative hypothesis: stationary
0.1.5.0.6 Pk2pk
0.1.5.0.6.1 With Outlier Dates
tseries::adf.test(ts.skyra2_bullSNR$Pk.to.Pk)
## 
##  Augmented Dickey-Fuller Test
## 
## data:  ts.skyra2_bullSNR$Pk.to.Pk
## Dickey-Fuller = -3.2117, Lag order = 4, p-value = 0.08917
## alternative hypothesis: stationary
0.1.5.0.6.2 Without Outlier Dates
tseries::adf.test(ts.skyra2_bullSNR_NOUT$Pk.to.Pk)
## 
##  Augmented Dickey-Fuller Test
## 
## data:  ts.skyra2_bullSNR_NOUT$Pk.to.Pk
## Dickey-Fuller = -3.5168, Lag order = 4, p-value = 0.04369
## alternative hypothesis: stationary

0.2 ADNI

ADNI.DF<-read_csv("/Volumes/IGNITE_Imaging/QC_Output/R_IGNITE/Phantom/ADNI.csv")
ADNI.DF<- ADNI.DF %>% select(-Scanner)
names(ADNI.DF)<-c( "Site"  ,"Date"  ,  "Scanner",  "Tech" ,   "ADNI.SNR" )
ADNI.DF<-ADNI.DF %>% arrange(Date)
ADNI.DF$SubID<-"ADNI"
ADNI.DF$ID<-paste0(ADNI.DF$SubID,"_", seq(1:nrow(ADNI.DF)))
m.ADNI.DF<-reshape2::melt(ADNI.DF, id.vars=c("Scanner","Date", "Site", "SubID", "ID","Tech" ))
m.ADNI.DF$Scanner<-as.factor(m.ADNI.DF$Scanner)
m.ADNI.DF<-m.ADNI.DF %>%
  group_by(Scanner, variable ) %>% 
  mutate(Quarter = paste0(lubridate::year(Date),"/Q",lubridate::quarter(Date)),
                          year=format(Date, "%Y"),
                          Z=scale(value))

0.2.1 Outlier Report(s):

m.ADNI.DF.out.date<-m.ADNI.DF%>% filter(Z>3 |Z<(-3)) %>% select(Scanner,year,Date, variable,value, Z ) %>% group_by(Scanner, Date)%>% summarise(N_Outliers=n())
TMP<-m.ADNI.DF%>% group_by(Scanner, Date ) %>% filter(Z>3 |Z<(-3))%>% select(Date,Quarter, ID, variable,year, value, Z) 

0.2.1.1 Z table & Removal of Dates with outliers

TMP$ID<-paste0( TMP$Date, " ",TMP$Scanner, " ", TMP$ID)
m.ADNI.DF$Z<-as.numeric(m.ADNI.DF$Z)
m.ADNI.DF$OID<-paste0( m.ADNI.DF$Date, " ",m.ADNI.DF$Scanner," ", m.ADNI.DF$ID)
m.ADNI.DF$OUTLIER_DATE.factor<-if_else(m.ADNI.DF$OID %in% TMP$ID, 1,0)
m.ADNI.DF<-m.ADNI.DF %>% select(-OID)
ADNIZ<-reshape2::dcast(m.ADNI.DF, Scanner+Date+Site+Tech+year+Quarter+SubID+ID+OUTLIER_DATE.factor~variable, value.var = "Z")

ADNI.DF<-reshape2::dcast(m.ADNI.DF, Scanner+Date+Site+Tech+year+Quarter+SubID+ID+OUTLIER_DATE.factor~variable, value.var = "value")

ADNI.DF_NOOUT<-ADNI.DF %>% filter(OUTLIER_DATE.factor!=1)
m.ADNI.DF_NOUT<-m.ADNI.DF %>% filter(OUTLIER_DATE.factor!=1)

0.2.2 Northeastern:

0.2.2.1 With Outlier Dates

NUBIC1_adniSNR<-ADNI.DF %>% filter(Scanner=="NUBIC")%>% drop_na(ADNI.SNR) %>% select(Date,Scanner , ADNI.SNR)  %>% arrange(Date) 
class(NUBIC1_adniSNR$ADNI.SNR)<-"numeric"
x <- data.frame('SNR'= NUBIC1_adniSNR$ADNI.SNR )
i <- NUBIC1_adniSNR$Date
ts.NUBIC1_adniSNR<-zoo::zoo(x = x, order.by = i)
tseries::adf.test(ts.NUBIC1_adniSNR$SNR)
## 
##  Augmented Dickey-Fuller Test
## 
## data:  ts.NUBIC1_adniSNR$SNR
## Dickey-Fuller = -2.1118, Lag order = 3, p-value = 0.5295
## alternative hypothesis: stationary

0.2.2.2 Without Outlier Dates

NUBIC2_adniSNR<-ADNI.DF_NOOUT %>% filter(Scanner=="NUBIC")%>% drop_na(ADNI.SNR) %>% select(Date,Scanner , ADNI.SNR)  %>% arrange(Date) 
class(NUBIC2_adniSNR$ADNI.SNR)<-"numeric"
x <- data.frame('SNR'= NUBIC2_adniSNR$ADNI.SNR )
i <- NUBIC2_adniSNR$Date
ts.NUBIC2_adniSNR<-zoo::zoo(x = x, order.by = i)
tseries::adf.test(ts.NUBIC2_adniSNR$SNR)
## 
##  Augmented Dickey-Fuller Test
## 
## data:  ts.NUBIC2_adniSNR$SNR
## Dickey-Fuller = -2.1118, Lag order = 3, p-value = 0.5295
## alternative hypothesis: stationary
ts<-cbind(ts.NUBIC1_adniSNR,ts.NUBIC2_adniSNR)
par(mfrow = c(1,1))
plot(ts, plot.type = "single", col = c(1:2), lwd = 1)
legend("bottomleft", c("With Outliers", "Without Outliers"), lty = c(1,1), col = c(1:2), lwd = 1)

0.2.3 Kansas:

0.2.3.1 With Outlier Dates

sky1_adniSNR<-ADNI.DF %>% filter(Scanner=="SKYRA")%>% drop_na(ADNI.SNR) %>% select(Date,Scanner , ADNI.SNR)  %>% arrange(Date) 
class(sky1_adniSNR$ADNI.SNR)<-"numeric"
x <- data.frame('SNR'= sky1_adniSNR$ADNI.SNR )
i <- sky1_adniSNR$Date
ts.sky1_adniSNR<-zoo::zoo(x = x, order.by = i)
tseries::adf.test(ts.sky1_adniSNR$SNR)
## 
##  Augmented Dickey-Fuller Test
## 
## data:  ts.sky1_adniSNR$SNR
## Dickey-Fuller = -2.7207, Lag order = 3, p-value = 0.2846
## alternative hypothesis: stationary

0.2.3.2 Without Outlier Dates

sky2_adniSNR<-ADNI.DF_NOOUT %>% filter(Scanner=="SKYRA")%>% drop_na(ADNI.SNR) %>% select(Date,Scanner , ADNI.SNR)  %>% arrange(Date) 
class(sky2_adniSNR$ADNI.SNR)<-"numeric"
x <- data.frame('SNR'= sky2_adniSNR$ADNI.SNR )
i <- sky2_adniSNR$Date
ts.sky2_adniSNR<-zoo::zoo(x = x, order.by = i)
tseries::adf.test(ts.sky2_adniSNR$SNR)
## 
##  Augmented Dickey-Fuller Test
## 
## data:  ts.sky2_adniSNR$SNR
## Dickey-Fuller = -3.3454, Lag order = 3, p-value = 0.07516
## alternative hypothesis: stationary
ts<-cbind(ts.sky1_adniSNR,ts.sky2_adniSNR)
par(mfrow = c(1,1))
plot(ts, plot.type = "single", col = c(1:2), lwd = 1)
legend("bottomleft", c("With Outliers", "Without Outliers"), lty = c(1,1), col = c(1:2), lwd = 1)

0.2.4 Prisma 1

0.2.4.1 With Outlier Dates

p1_adniSNR<-ADNI.DF %>% filter(Scanner=="PRISMA 1")%>% drop_na(ADNI.SNR) %>% select(Date,Scanner , ADNI.SNR)  %>% arrange(Date) 
class(p1_adniSNR$ADNI.SNR)<-"numeric"
x <- data.frame('SNR'= p1_adniSNR$ADNI.SNR )
i <- p1_adniSNR$Date
ts.p1_adniSNR<-zoo::zoo(x = x, order.by = i)
tseries::adf.test(ts.p1_adniSNR$SNR)
## 
##  Augmented Dickey-Fuller Test
## 
## data:  ts.p1_adniSNR$SNR
## Dickey-Fuller = -1.2972, Lag order = 3, p-value = 0.85
## alternative hypothesis: stationary

0.2.4.2 Without Outlier Dates

p2_adniSNR<-ADNI.DF_NOOUT %>% filter(Scanner=="PRISMA 1")%>% drop_na(ADNI.SNR) %>% select(Date,Scanner , ADNI.SNR)  %>% arrange(Date) 
class(p2_adniSNR$ADNI.SNR)<-"numeric"
x <- data.frame('SNR'= p2_adniSNR$ADNI.SNR )
i <- p2_adniSNR$Date
ts.p2_adniSNR<-zoo::zoo(x = x, order.by = i)
tseries::adf.test(ts.p2_adniSNR$SNR)
## 
##  Augmented Dickey-Fuller Test
## 
## data:  ts.p2_adniSNR$SNR
## Dickey-Fuller = -1.2972, Lag order = 3, p-value = 0.85
## alternative hypothesis: stationary
ts<-cbind(ts.p1_adniSNR,ts.p2_adniSNR)
par(mfrow = c(1,1))
plot(ts, plot.type = "single", col = c(1:2), lwd = 1)
legend("bottomleft", c("With Outliers", "Without Outliers"), lty = c(1,1), col = c(1:2), lwd = 1)

0.2.5 Prisma 2

0.2.5.1 With Outlier Dates

prisma1_adniSNR<-ADNI.DF%>% filter(Scanner=="PRISMA 2")%>% drop_na(ADNI.SNR) %>% select(Date,Scanner , ADNI.SNR)  %>% arrange(Date) 
class(prisma1_adniSNR$ADNI.SNR)<-"numeric"
x <- data.frame('SNR'= prisma1_adniSNR$ADNI.SNR )
i <- prisma1_adniSNR$Date
ts.prisma1_adniSNR<-zoo::zoo(x = x, order.by = i)
tseries::adf.test(ts.prisma1_adniSNR$SNR)
## 
##  Augmented Dickey-Fuller Test
## 
## data:  ts.prisma1_adniSNR$SNR
## Dickey-Fuller = -2.2727, Lag order = 2, p-value = 0.4685
## alternative hypothesis: stationary

0.2.5.2 Without Outlier Dates

prisma2_adniSNR<-ADNI.DF%>% filter(Scanner=="PRISMA 2")%>% drop_na(ADNI.SNR) %>% select(Date,Scanner , ADNI.SNR)  %>% arrange(Date) 
class(prisma2_adniSNR$ADNI.SNR)<-"numeric"
x <- data.frame('SNR'= prisma2_adniSNR$ADNI.SNR )
i <- prisma2_adniSNR$Date
ts.prisma2_adniSNR<-zoo::zoo(x = x, order.by = i)
tseries::adf.test(ts.prisma2_adniSNR$SNR)
## 
##  Augmented Dickey-Fuller Test
## 
## data:  ts.prisma2_adniSNR$SNR
## Dickey-Fuller = -2.2727, Lag order = 2, p-value = 0.4685
## alternative hypothesis: stationary
ts<-cbind(ts.prisma1_adniSNR,ts.prisma2_adniSNR)
par(mfrow = c(1,1))
plot(ts, plot.type = "single", col = c(1:2), lwd = 1)
legend("bottomleft", c("With Outliers", "Without Outliers"), lty = c(1,1), col = c(1:2), lwd = 1)

0.3 Merge Pantom:

phantom<-plyr::rbind.fill(ADNI.DF, BULL.DF)
phantom<-phantom %>% 
 group_by(Scanner, Date ) %>%
 summarize(across(everything(), ~ first(na.omit(.))))

phantom_NOOUT<-plyr::rbind.fill(ADNI.DF_NOOUT, BULL.DF_NOOUT)
phantom_NOOUT<-phantom_NOOUT %>% 
 group_by(Scanner, Date ) %>%
 summarize(across(everything(), ~ first(na.omit(.))))

m.phantom_NOOUT<-plyr::rbind.fill(m.ADNI.DF_NOUT, m.BULL.DF_NOOUT)
d<-m.phantom_NOOUT %>% 
 group_by(Scanner, Date ) %>%
 summarize(across(everything(), ~ first(na.omit(.))))
phantom$Scanner<-if_else(phantom$Scanner=="NUBIC", "NE Prisma",as.character(phantom$Scanner))
phantom$Scanner<-if_else(phantom$Scanner=="SKYRA", "Skyra",phantom$Scanner)
phantom$Scanner<-if_else(phantom$Scanner=="PRISMA 1", "Prisma 1" ,phantom$Scanner)
phantom$Scanner<-if_else(phantom$Scanner=="PRISMA 2", "Prisma 2" ,phantom$Scanner)
phantom$Scanner_Manufact.factor<-if_else(phantom$Scanner=="Skyra", "SKYRA","PRISMA")
phantom$Scanner_Manufact.factor<-as.factor(phantom$Scanner_Manufact.factor)
phantom$Site<-if_else(phantom$Scanner=="Prisma 2"|phantom$Scanner=="Prisma 1", "UPitt" ,as.character(phantom$Scanner))
phantom$Site<-if_else(phantom$Site=="Skyra", "KU" ,phantom$Site)
phantom$Site<-if_else(phantom$Site=="NE Prisma", "NEU" ,phantom$Site)
phantom$Site<-as.factor(phantom$Site)
phantom$Scanner_Manufact.factor<-if_else(str_detect(phantom$Scanner, "Skyra"), "SKYRA", "PRISMA")
phantom$Scanner_Manufact.factor<-factor(phantom$Scanner_Manufact.factor,levels=c("PRISMA", "SKYRA" ))
phantom$Site<-factor(phantom$Site,levels=c("KU", "NEU", "UPitt"))
phantom$Scanner<-factor(phantom$Scanner, levels=c("NE Prisma","Prisma 1" , "Prisma 2","Skyra"))
phantom <- phantom %>%  mutate(Quarter = paste0(lubridate::year(Date),"/Q",lubridate::quarter(Date))) 
phantom <- phantom %>%  mutate(Year = paste0(lubridate::year(Date))) 
phantom<-phantom %>% select( Date, Scanner, year,Quarter, Site, OUTLIER_DATE.factor, Scanner_Manufact.factor, ADNI.SNR,Mean,`Pk-to-Pk`, RMS,RDC,Rqq,BULL.SNR )
phantom <- phantom %>%  mutate(Year = paste0(lubridate::year(Date))) 
phantom$Year<-as.factor(phantom$Year)

mphantomscale<-reshape2::melt(phantom, id.vars=c("Scanner", "Date","Site", "Quarter", "Year","year", "OUTLIER_DATE.factor", "Scanner_Manufact.factor"))
mphantomscale$value<-as.numeric(mphantomscale$value)
#mphantomscale<-mphantomscale %>% filter(!is.na(value))
mphantomscale<-mphantomscale[!duplicated(mphantomscale),]
mphantomscale<-mphantomscale %>% 
  group_by(variable, Scanner, add=T) %>% 
  mutate(
    Z=scale(value, center=T, scale=T))
phantom_NOOUT$Scanner<-if_else(phantom_NOOUT$Scanner=="NUBIC", "NE Prisma",as.character(phantom_NOOUT$Scanner))
phantom_NOOUT$Scanner<-if_else(phantom_NOOUT$Scanner=="SKYRA", "Skyra",phantom_NOOUT$Scanner)
phantom_NOOUT$Scanner<-if_else(phantom_NOOUT$Scanner=="PRISMA 1", "Prisma 1" ,phantom_NOOUT$Scanner)
phantom_NOOUT$Scanner<-if_else(phantom_NOOUT$Scanner=="PRISMA 2", "Prisma 2" ,phantom_NOOUT$Scanner)
phantom_NOOUT$Site<-if_else(phantom_NOOUT$Scanner=="Prisma 2"|phantom_NOOUT$Scanner=="Prisma 1", "UPitt" ,as.character(phantom_NOOUT$Scanner))
phantom_NOOUT$Site<-if_else(phantom_NOOUT$Site=="Skyra", "KU" ,phantom_NOOUT$Site)
phantom_NOOUT$Site<-if_else(phantom_NOOUT$Site=="NE Prisma", "NEU" ,phantom_NOOUT$Site)
phantom_NOOUT$Site<-as.factor(phantom_NOOUT$Site)
phantom_NOOUT$Scanner_Manufact.factor<-if_else(str_detect(phantom_NOOUT$Scanner, "Skyra"), "SKYRA", "PRISMA")
phantom_NOOUT$Scanner_Manufact.factor<-factor(phantom_NOOUT$Scanner_Manufact.factor,levels=c("SKYRA", "PRISMA"))
phantom_NOOUT$Site<-factor(phantom_NOOUT$Site,levels=c("KU", "NEU", "UPitt"))
phantom_NOOUT$Scanner<-factor(phantom_NOOUT$Scanner,levels=c("Skyra", "NE Prisma", "Prisma 1", "Prisma 2"))
m.phantom_NOOUT$Scanner<-if_else(m.phantom_NOOUT$Scanner=="NUBIC", "NE Prisma",as.character(m.phantom_NOOUT$Scanner))
m.phantom_NOOUT$Scanner<-if_else(m.phantom_NOOUT$Scanner=="SKYRA", "Skyra",m.phantom_NOOUT$Scanner)
m.phantom_NOOUT$Scanner<-if_else(m.phantom_NOOUT$Scanner=="PRISMA 1", "Prisma 1" ,m.phantom_NOOUT$Scanner)
m.phantom_NOOUT$Scanner<-if_else(m.phantom_NOOUT$Scanner=="PRISMA 2", "Prisma 2" ,m.phantom_NOOUT$Scanner)
m.phantom_NOOUT$Site<-if_else(m.phantom_NOOUT$Scanner=="Prisma 2"|m.phantom_NOOUT$Scanner=="Prisma 1", "UPitt" ,as.character(m.phantom_NOOUT$Scanner))
m.phantom_NOOUT$Site<-if_else(m.phantom_NOOUT$Site=="Skyra", "KU" ,m.phantom_NOOUT$Site)
m.phantom_NOOUT$Site<-if_else(m.phantom_NOOUT$Site=="NE Prisma", "NEU" ,m.phantom_NOOUT$Site)
m.phantom_NOOUT$Site<-as.factor(m.phantom_NOOUT$Site)
m.phantom_NOOUT$Scanner_Manufact.factor<-if_else(str_detect(m.phantom_NOOUT$Scanner, "Skyra"), "SKYRA", "PRISMA")

#### LEVELS
m.phantom_NOOUT$Scanner_Manufact.factor<-factor(m.phantom_NOOUT$Scanner_Manufact.factor,levels=c( "PRISMA","SKYRA"))
m.phantom_NOOUT$Site<-factor(m.phantom_NOOUT$Site,levels=c("NEU", "UPitt","KU"))
m.phantom_NOOUT$Scanner<-factor(m.phantom_NOOUT$Scanner,levels=c( "NE Prisma", "Prisma 1", "Prisma 2","Skyra"))

0.3.0.1 Correlations: BULL SNR * Mean

0.3.0.1.1 With Outlier Dates
cor.test(phantom$BULL.SNR, phantom$Mean)
## 
##  Pearson's product-moment correlation
## 
## data:  phantom$BULL.SNR and phantom$Mean
## t = -2.875, df = 352, p-value = 0.004286
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.25173167 -0.04799361
## sample estimates:
##       cor 
## -0.151471
0.3.0.1.2 Without Outlier Dates
cor.test(phantom_NOOUT$BULL.SNR, phantom_NOOUT$Mean)   
## 
##  Pearson's product-moment correlation
## 
## data:  phantom_NOOUT$BULL.SNR and phantom_NOOUT$Mean
## t = -3.4199, df = 347, p-value = 0.0007012
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.28023772 -0.07705038
## sample estimates:
##        cor 
## -0.1805699
0.3.0.1.3 Kansas:
0.3.0.1.3.1 With Outlier Dates
s1<-phantom %>% filter(Scanner=="Skyra")
cor.test(s1$BULL.SNR, s1$Mean)
## 
##  Pearson's product-moment correlation
## 
## data:  s1$BULL.SNR and s1$Mean
## t = 15.053, df = 120, p-value < 2.2e-16
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.7366735 0.8623667
## sample estimates:
##      cor 
## 0.808553
0.3.0.1.3.2 Without Outlier Dates
s1<-phantom_NOOUT %>% filter(Scanner=="Skyra", complete.cases(Mean)|complete.cases(BULL.SNR)) 
cor.test(as.numeric(s1$BULL.SNR), as.numeric(s1$Mean))
## 
##  Pearson's product-moment correlation
## 
## data:  as.numeric(s1$BULL.SNR) and as.numeric(s1$Mean)
## t = 14.442, df = 118, p-value < 2.2e-16
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.7235711 0.8558167
## sample estimates:
##       cor 
## 0.7991656
0.3.0.1.4 Prisma 1:
0.3.0.1.4.1 With Outlier Dates
p1<-phantom %>% filter(Scanner=="Prisma 1")
cor.test(p1$BULL.SNR, p1$Mean)
## 
##  Pearson's product-moment correlation
## 
## data:  p1$BULL.SNR and p1$Mean
## t = -3.1023, df = 89, p-value = 0.002573
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.4870008 -0.1137607
## sample estimates:
##        cor 
## -0.3123869
0.3.0.1.4.2 Without Outlier Dates
p1<-phantom_NOOUT %>% filter(Scanner=="Prisma 1")
cor.test(p1$BULL.SNR, p1$Mean)
## 
##  Pearson's product-moment correlation
## 
## data:  p1$BULL.SNR and p1$Mean
## t = -3.1023, df = 89, p-value = 0.002573
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.4870008 -0.1137607
## sample estimates:
##        cor 
## -0.3123869
0.3.0.1.5 Prisma 2:
0.3.0.1.5.1 With Outlier Dates
p2<-phantom %>% filter(Scanner=="Prisma 2")
cor.test(p2$BULL.SNR, p2$Mean)
## 
##  Pearson's product-moment correlation
## 
## data:  p2$BULL.SNR and p2$Mean
## t = 1.1935, df = 37, p-value = 0.2403
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1309279  0.4789628
## sample estimates:
##       cor 
## 0.1925431
0.3.0.1.5.2 Without Outlier Dates
p2<-phantom_NOOUT %>% filter(Scanner=="Prisma 2")
cor.test(p2$BULL.SNR, p2$Mean)
## 
##  Pearson's product-moment correlation
## 
## data:  p2$BULL.SNR and p2$Mean
## t = 1.1935, df = 37, p-value = 0.2403
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1309279  0.4789628
## sample estimates:
##       cor 
## 0.1925431
0.3.0.1.6 Northeatern:
0.3.0.1.6.1 With Outlier Dates
n1<-phantom %>% filter(Scanner=="NE Prisma")
cor.test(n1$BULL.SNR, n1$Mean)
## 
##  Pearson's product-moment correlation
## 
## data:  n1$BULL.SNR and n1$Mean
## t = -0.29867, df = 100, p-value = 0.7658
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.2230336  0.1655827
## sample estimates:
##         cor 
## -0.02985356
0.3.0.1.6.2 Without Outlier Dates
n1<-phantom_NOOUT %>% filter(Scanner=="NE Prisma")
cor.test(n1$BULL.SNR, n1$Mean)
## 
##  Pearson's product-moment correlation
## 
## data:  n1$BULL.SNR and n1$Mean
## t = 2.8219, df = 97, p-value = 0.005792
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.08250982 0.44846230
## sample estimates:
##       cor 
## 0.2754352

0.3.0.2 Visual:

0.3.0.2.0.1 With Outlier Dates
p<-ggplot(mphantomscale, aes(Date, Z, color=variable, group=variable))+geom_point(aes(label=value))+geom_line()+geom_smooth()+facet_wrap(~Scanner)
plotly::ggplotly(p)
0.3.0.2.0.2 Without Outlier Dates
p<-ggplot(m.phantom_NOOUT, aes(Date, Z, color=variable, group=variable))+geom_point(aes(label=value))+geom_line()+geom_smooth()+facet_wrap(~Scanner)
plotly::ggplotly(p)

0.4 Tests

0.4.1 Between Scanner Models

ggstatsplot::grouped_ggbetweenstats(m.phantom_NOOUT, 
                           Scanner_Manufact.factor, 
                           value,
                           grouping.var=variable,
                           plotgrid.args = list(nrow = 3))

0.4.2 Between Scanner

ggstatsplot::grouped_ggbetweenstats(m.phantom_NOOUT, 
                           Scanner, 
                           value,
                           grouping.var=variable)

0.4.3 Between Site

ggstatsplot::grouped_ggbetweenstats(m.phantom_NOOUT, 
                           Site, 
                           value,
                           grouping.var=variable)