library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(ggplot2)
library(ggpubr)
library(rstatix)
## 
## Attaching package: 'rstatix'
## The following object is masked from 'package:stats':
## 
##     filter
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ forcats   1.0.0     ✔ stringr   1.5.1
## ✔ lubridate 1.9.3     ✔ tibble    3.2.1
## ✔ purrr     1.0.2     ✔ tidyr     1.3.1
## ✔ readr     2.1.5
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ rstatix::filter() masks dplyr::filter(), stats::filter()
## ✖ dplyr::lag()      masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(ggbeeswarm)
Project_2_Calibration =  read_delim('Project-2-Calibration.csv',
                      delim =",")
## Rows: 78 Columns: 5
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (3): CONC, TYPE, NAME
## dbl (2): AREA, TIME
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
CAP_CHILI_CONC = Project_2_Calibration  %>%
  filter(TYPE == "CAP")

DHC_CHILI_CONC = Project_2_Calibration  %>%
  filter(TYPE == "DHC")
CAP_STANDARD = CAP_CHILI_CONC %>%
  filter(CONC != "x") %>%
  mutate(CONC = as.numeric(CONC))

DHC_STANDARD = DHC_CHILI_CONC %>%
  filter(CONC != "x") %>%
  mutate(CONC = as.numeric(CONC))
CAP_SAMPLE_CONC = CAP_CHILI_CONC %>%
  filter(CONC == "x")

DHC_SAMPLE_CONC = DHC_CHILI_CONC %>%
  filter(CONC == "x")
ggplot(data=CAP_STANDARD, 
       mapping=aes(
         x=CONC, 
         y=AREA)) + 
  geom_smooth(method=lm,
              colour ="black")+
  geom_point(color = "red", 
             size = 2) + 
  ggtitle("Calibration curve for capsaicin standards")+
  theme(plot.title=element_text(
    face='bold', 
    size = 20, 
    hjust = 0.5))+
  theme_bw()+
  stat_regline_equation()+
  #stat_cor(aes(label=..rr.label..), label.x=30, label.y=600)+
  labs(y="Peak Area (mAU)", x="Concentration (ug/ml)")
## `geom_smooth()` using formula = 'y ~ x'

ggplot(data=DHC_STANDARD, 
       mapping=aes(
         x=CONC, 
         y=AREA)) + 
  geom_smooth(method=lm,
              colour ="black")+
  geom_point(color = "green", 
             size = 2) + 
  ggtitle("Calibration curve for dihydrocapsaicin standards")+
  theme(plot.title=element_text(
    face='bold', 
    size = 20, 
    hjust = 0.5))+
  theme_bw()+
  stat_regline_equation()+
  #stat_cor(aes(label=..rr.label..), label.x=30, label.y=600)+
  labs(y="Peak Area (mAU)", x="Concentration (ug/ml)")
## `geom_smooth()` using formula = 'y ~ x'

REG_CAP = lm(AREA ~ CONC, data= CAP_STANDARD)
REG_DHC = lm(AREA ~ CONC, data= DHC_STANDARD)

summary(REG_CAP)
## 
## Call:
## lm(formula = AREA ~ CONC, data = CAP_STANDARD)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -29.302  -5.284   3.258   9.538  23.382 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept) -24.39918    5.04875  -4.833 0.000116 ***
## CONC         11.16605    0.08984 124.287  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 14.05 on 19 degrees of freedom
## Multiple R-squared:  0.9988, Adjusted R-squared:  0.9987 
## F-statistic: 1.545e+04 on 1 and 19 DF,  p-value: < 2.2e-16
summary(REG_DHC)
## 
## Call:
## lm(formula = AREA ~ CONC, data = DHC_STANDARD)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -37.862 -13.267   1.293  17.396  46.495 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) -40.2795     8.5480  -4.712 0.000152 ***
## CONC         24.6420     0.1521 162.002  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 23.79 on 19 degrees of freedom
## Multiple R-squared:  0.9993, Adjusted R-squared:  0.9992 
## F-statistic: 2.624e+04 on 1 and 19 DF,  p-value: < 2.2e-16
CAP_STANDARD = CAP_STANDARD %>%
  mutate(AREA_PREDICT = predict(REG_CAP),
         RESIDUALS = residuals(REG_CAP))

DHC_STANDARD = DHC_STANDARD %>%
  mutate(AREA_PREDICT = predict(REG_DHC),
         RESIDUALS = residuals(REG_DHC))
ggplot(data = CAP_STANDARD, aes(x=CONC, y=RESIDUALS)) +
  geom_point(colour = "red")+
  ggtitle("Residual plot for capsaicin standards") +
  labs(y="Residuals",x="Concentration")+
  theme_bw()+
  geom_hline(yintercept = 0)

ggplot(data = DHC_STANDARD, aes(x=CONC, y=RESIDUALS)) +
  geom_point(colour = "green")+
  ggtitle("Residual plot for dihydrocapsaicin standards") +
  labs(y="Residuals",x="Concentration")+
  theme_bw()+
  geom_hline(yintercept=0)

CAP_SAMPLE_CONC = CAP_SAMPLE_CONC %>%
  mutate(CONC = (AREA-REG_CAP$coefficient[1])/REG_CAP$coefficients[2])
CAP_SAMPLE_CONC
DHC_SAMPLE_CONC = DHC_SAMPLE_CONC %>%
  mutate(CONC = (AREA-REG_DHC$coefficient[1])/REG_DHC$coefficients[2])
DHC_SAMPLE_CONC
JF_CAP_SD = CAP_SAMPLE_CONC %>%
  filter(NAME == "Jing-fruit")

JF_CAP_CONC_SD = sd(JF_CAP_SD$CONC)

JS_CAP_SD = CAP_SAMPLE_CONC %>%
  filter(NAME == "Jing-seed")

JS_CAP_CONC_SD = sd(JS_CAP_SD$CONC)

XF_CAP_SD = CAP_SAMPLE_CONC %>%
  filter(NAME == "Xiao-fruit")

XF_CAP_CONC_SD = sd(XF_CAP_SD$CONC)

XS_CAP_SD = CAP_SAMPLE_CONC %>%
  filter(NAME == "Xiao-5050")

XS_CAP_CONC_SD = sd(XS_CAP_SD$CONC)

FV_CAP_SD = CAP_SAMPLE_CONC %>%
  filter(NAME == "FV - Fruit")

FV_CAP_CONC_SD = sd(FV_CAP_SD$CONC)



JF_CAP_CONC_SD
## [1] 1.468939
JS_CAP_CONC_SD
## [1] 0.4455972
XF_CAP_CONC_SD
## [1] 2.350889
XS_CAP_CONC_SD
## [1] 2.464464
FV_CAP_CONC_SD
## [1] 1.233482
JF_DHC_SD = DHC_SAMPLE_CONC %>%
  filter(NAME == "Jing-fruit")

JF_DHC_CONC_SD = sd(JF_DHC_SD$CONC)

JS_DHC_SD = DHC_SAMPLE_CONC %>%
  filter(NAME == "Jing-seed")

JS_DHC_CONC_SD = sd(JS_DHC_SD$CONC)

XS_DHC_SD = DHC_SAMPLE_CONC %>%
  filter(NAME == "Xiao-5050")

XS_DHC_CONC_SD = sd(XS_DHC_SD$CONC)

XF_DHC_SD = DHC_SAMPLE_CONC %>%
  filter(NAME == "Xiao-fruit")

XF_DHC_CONC_SD = sd(XF_DHC_SD$CONC)



JF_DHC_CONC_SD
## [1] 0.07976667
JS_DHC_CONC_SD
## [1] 0.01549339
XS_DHC_CONC_SD
## [1] 0.7046399
XF_DHC_CONC_SD
## [1] 0.009767125

——————————————— LOD & LOQ ———————————————————

CAP_RES_SD = sd((CAP_STANDARD %>% slice(1:3))$RESIDUALS) # looking at lowest conc
LOD_CAP = 3.3 *CAP_RES_SD / as.numeric(REG_CAP$coefficients[2])
LOQ_CAP = 10 *CAP_RES_SD / as.numeric(REG_CAP$coefficients[2])

LOD_CAP
## [1] 0.1145535
LOQ_CAP
## [1] 0.3471317
DHC_RES_SD = sd((DHC_STANDARD %>% slice(1:3))$RESIDUALS)
LOD_DHC = 3.3 *DHC_RES_SD / as.numeric(REG_DHC$coefficients[2])
LOQ_DHC = 10 *DHC_RES_SD / as.numeric(REG_DHC$coefficients[2])

LOD_DHC
## [1] 0.09148554
LOQ_DHC
## [1] 0.2772289

——————————————– t-test ————————————————————-

QC_CAPSAICINOID = Project_2_Calibration  %>%
  filter(NAME == "Xiao-5050" | NAME == "Xiao-100")

QC_CAPSAICINOID
CAP_QC = QC_CAPSAICINOID  %>%
  filter(TYPE == "CAP")

DHC_QC = QC_CAPSAICINOID  %>%
  filter(TYPE == "DHC")

CAP_QC
DHC_QC
ggplot(data=CAP_QC, 
       aes(x=NAME, 
           y=AREA,
           colour=NAME)) +
  ggtitle("Overlay (Violin, Boxplot, Beeswarm) plot for Capsaicin") +
  theme_bw() +
  labs(y="Peak Area (mAU)")+
  geom_violin(trim = F) +
  geom_boxplot(width = 0.1) +
  geom_beeswarm(cex = 5)+
  theme(legend.position="none",
        plot.title = element_text(hjust = 0.5),
        axis.title.x = element_blank())

ggplot(data=DHC_QC, 
       aes(x=NAME, 
           y=AREA,
           colour=NAME)) +
  ggtitle("Overlay (Violin, Boxplot, Beeswarm) plot for Dihydrocapsaicin") +
  theme_bw() +
  labs(y="Peak Area (mAU)")+
  geom_violin(trim = F) +
  geom_boxplot(width = 0.1) +
  geom_beeswarm(cex = 5)+
  theme(legend.position="none",
        plot.title = element_text(hjust = 0.5),
        axis.title.x = element_blank())

CAP_QC %>% 
  t_test(AREA ~ NAME,
         var.equal=T,
         detailed=TRUE) 
DHC_QC %>% 
  t_test(AREA ~ NAME,
         var.equal=T,
         detailed=TRUE)

——————————————————– SHU ———————————————————–

CAP_SHU = CAP_SAMPLE_CONC %>%
  group_by(NAME) %>%
  filter(NAME == "Jing-fruit" |
           NAME == "Jing-seed" |
           NAME == "Xiao-fruit"|
           NAME == "Xiao-5050") %>%
  summarise(ug_ml_mean = mean(CONC)) %>%
  ungroup() 

print(CAP_SHU)
## # A tibble: 4 × 2
##   NAME       ug_ml_mean
##   <chr>           <dbl>
## 1 Jing-fruit       53.6
## 2 Jing-seed        29.0
## 3 Xiao-5050       102. 
## 4 Xiao-fruit      179.
DHC_SHU = DHC_SAMPLE_CONC %>%
  group_by(NAME) %>%
  filter(NAME == "Jing-fruit" |
           NAME == "Jing-seed" |
           NAME == "Xiao-fruit"|
           NAME == "Xiao-5050") %>%
  summarise(ug_ml_mean = mean(CONC)) %>%
  ungroup()  

print(DHC_SHU)
## # A tibble: 4 × 2
##   NAME       ug_ml_mean
##   <chr>           <dbl>
## 1 Jing-fruit      16.2 
## 2 Jing-seed        9.18
## 3 Xiao-5050       33.4 
## 4 Xiao-fruit      66.1
CAP_SHU = CAP_SHU %>%
  mutate(ppm = (ug_ml_mean*5)/0.5,
         CAP_ug = (ug_ml_mean*5),
         CAP_PERCENT = (((ug_ml_mean*5)*0.000001)/0.5)*100,
         SHU = ppm*16) #from paper by cunha c.t

DHC_SHU = DHC_SHU %>%
  mutate(ppm = (ug_ml_mean*5)/0.5,
         DHC_ug = (ug_ml_mean*5),
         DHC_PERCENT = (((ug_ml_mean*5)*0.000001)/0.5)*100,
         SHU = ppm*15)

CAP_SHU
DHC_SHU

Fruity volcano was dissolved in a different ratio to the above, calculation fro Fruit Volcano fruit is below:

FV_SHU = CAP_SAMPLE_CONC %>%
  group_by(NAME) %>%
  filter(NAME == "FV - Fruit") %>%
  summarise(ug_ml_mean = mean(CONC)) %>%
  ungroup() 

print(FV_SHU)
## # A tibble: 1 × 2
##   NAME       ug_ml_mean
##   <chr>           <dbl>
## 1 FV - Fruit       261.
FV_SHU = FV_SHU %>%
  mutate(ppm = (ug_ml_mean*5)/0.2186, #mass of FV not 0.5 grams
         CAP_ug = (ug_ml_mean*5),
         CAP_PERCENT = (((ug_ml_mean*5)*0.000001)/0.5)*100,
         SHU = ppm*16)

FV_SHU

———————————————————– CI ———————————————————

CAP_TIME_MEAN <- mean(CAP_CHILI_CONC$TIME)
print(CAP_TIME_MEAN)
## [1] 10.25273
DHC_TIME_MEAN <- mean(DHC_CHILI_CONC$TIME)
print(DHC_TIME_MEAN)
## [1] 14.52466
CAP_TIME_N <- length(CAP_CHILI_CONC$TIME)
CAP_TIME_SD <- sd(CAP_CHILI_CONC$TIME)
CAP_TIME_ERROR <- CAP_TIME_SD/sqrt(CAP_TIME_N)
print(CAP_TIME_ERROR)
## [1] 0.1092549
DHC_TIME_N <- length(DHC_CHILI_CONC$TIME)
DHC_TIME_SD <- sd(DHC_CHILI_CONC$TIME)
DHC_TIME_ERROR <- DHC_TIME_SD/sqrt(DHC_TIME_N)
print(DHC_TIME_ERROR)
## [1] 0.1803209
alpha = 0.05
df_CAP = CAP_TIME_N - 1
t.score_CAP = qt(p=alpha/2, df=df_CAP,lower.tail=F)
print(t.score_CAP)
## [1] 2.019541
alpha = 0.05
df_DHC = DHC_TIME_N - 1
t.score_DHC = qt(p=alpha/2, df=df_DHC,lower.tail=F)
print(t.score_DHC)
## [1] 2.030108
CAP_error <- t.score_CAP * CAP_TIME_ERROR
CAP_lower <- CAP_TIME_MEAN - CAP_error
CAP_upper <- CAP_TIME_MEAN + CAP_error
print(c(CAP_lower,CAP_upper))
## [1] 10.03209 10.47338
DHC_error <- t.score_DHC * DHC_TIME_ERROR
DHC_lower <- DHC_TIME_MEAN - DHC_error
DHC_upper <- DHC_TIME_MEAN + DHC_error
print(c(DHC_lower,DHC_upper))
## [1] 14.15858 14.89073

changed from previous code due to change in tubing

—————————————————- t-test OLD/NEW —————————————————

OLD_SAMPLE_CALIBRATION =  read_delim('OLD_SAMPLE_CALIBRATION.csv',
                      delim =",")
## Rows: 51 Columns: 5
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (4): CONC, TYPE, NAME, TIME
## dbl (1): AREA
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
OLD_CAP_CHILI_CONC = OLD_SAMPLE_CALIBRATION  %>%
  filter(TYPE == "CAP")

OLD_DHC_CHILI_CONC = OLD_SAMPLE_CALIBRATION  %>%
  filter(TYPE == "DHC")
OLD_capchiliconc = OLD_CAP_CHILI_CONC %>%
  filter(CONC != "x") %>%
  mutate(CONC = as.numeric(CONC))

OLD_dhcchiliconc = OLD_DHC_CHILI_CONC %>%
  filter(CONC != "x") %>%
  mutate(CONC = as.numeric(CONC))

filter to match up the conc

CAP_STANDARD = CAP_STANDARD %>%
  group_by(CONC) %>%
  filter(CONC == "100" |
           CONC == "80" |
           CONC == "20" |
           CONC == "10") %>%
  arrange(desc(CONC)) %>%
  mutate(NEW = as.character("NEW")) %>%
  ungroup() 
print(CAP_STANDARD)
## # A tibble: 12 × 8
##     CONC   AREA TYPE  NAME      TIME AREA_PREDICT RESIDUALS NEW  
##    <dbl>  <dbl> <chr> <chr>    <dbl>        <dbl>     <dbl> <chr>
##  1   100 1081.  CAP   Standard  9.91       1092.     -11.6  NEW  
##  2   100 1111.  CAP   Standard 10.8        1092.      18.4  NEW  
##  3   100 1116.  CAP   Standard 11.2        1092.      23.4  NEW  
##  4    80  879.  CAP   Standard 11.4         869.       9.97 NEW  
##  5    80  866.  CAP   Standard 10.9         869.      -3.24 NEW  
##  6    80  865.  CAP   Standard 10.8         869.      -4.26 NEW  
##  7    20  202.  CAP   Standard  9.80        199.       3.26 NEW  
##  8    20  202.  CAP   Standard  9.74        199.       2.64 NEW  
##  9    20  208.  CAP   Standard 11.2         199.       9.54 NEW  
## 10    10   82.4 CAP   Standard  9.84         87.3     -4.88 NEW  
## 11    10   82.0 CAP   Standard  9.77         87.3     -5.28 NEW  
## 12    10   80.7 CAP   Standard  9.72         87.3     -6.52 NEW
DHC_STANDARD = DHC_STANDARD %>%
  group_by(CONC) %>%
  filter(CONC == "100" |
           CONC == "80" |
           CONC == "20" |
           CONC == "10") %>%
  arrange(desc(CONC)) %>%
  mutate(NEW = as.character("NEW")) %>%
  ungroup()

print(DHC_STANDARD)
## # A tibble: 12 × 8
##     CONC  AREA TYPE  NAME      TIME AREA_PREDICT RESIDUALS NEW  
##    <dbl> <dbl> <chr> <chr>    <dbl>        <dbl>     <dbl> <chr>
##  1   100 2419. DHC   Standard  14.0        2424.     -4.59 NEW  
##  2   100 2468. DHC   Standard  15.6        2424.     44.3  NEW  
##  3   100 2470. DHC   Standard  16.1        2424.     46.5  NEW  
##  4    80 1939. DHC   Standard  16.2        1931.      7.57 NEW  
##  5    80 1906. DHC   Standard  15.6        1931.    -25.1  NEW  
##  6    80 1902. DHC   Standard  15.4        1931.    -29.4  NEW  
##  7    20  439. DHC   Standard  13.8         453.    -13.2  NEW  
##  8    20  439. DHC   Standard  13.8         453.    -13.3  NEW  
##  9    20  454. DHC   Standard  15.9         453.      1.18 NEW  
## 10    10  225. DHC   Standard  13.9         206.     19.0  NEW  
## 11    10  224. DHC   Standard  13.8         206.     18.3  NEW  
## 12    10  224. DHC   Standard  13.7         206.     17.4  NEW
OLD_capchiliconc = OLD_capchiliconc %>%
  group_by(CONC) %>%
  filter(CONC == "100" |
           CONC == "80" |
           CONC == "20" |
           CONC == "10") %>%
  mutate(OLD = as.character("OLD")) %>%
  ungroup()

print(OLD_capchiliconc)
## # A tibble: 12 × 6
##     CONC  AREA TYPE  NAME     TIME        OLD  
##    <dbl> <dbl> <chr> <chr>    <chr>       <chr>
##  1   100  990. CAP   STANDARD 9.564060211 OLD  
##  2   100  975. CAP   STANDARD 9.574734688 OLD  
##  3   100  972. CAP   STANDARD 9.590581894 OLD  
##  4    80  786. CAP   STANDARD 9.586928368 OLD  
##  5    80  782. CAP   STANDARD 9.582813263 OLD  
##  6    80  783. CAP   STANDARD 9.603900909 OLD  
##  7    20  188. CAP   STANDARD 9.698838234 OLD  
##  8    20  188. CAP   STANDARD 9.697072983 OLD  
##  9    20  187. CAP   STANDARD 9.70687294  OLD  
## 10    10  126. CAP   STANDARD 9.692716599 OLD  
## 11    10  125. CAP   STANDARD 9.699242592 OLD  
## 12    10  125. CAP   STANDARD 9.704848289 OLD
OLD_dhcchiliconc = OLD_dhcchiliconc %>%
  group_by(CONC) %>%
  filter(CONC == "100" |
           CONC == "80" |
           CONC == "20" |
           CONC == "10") %>%
  mutate(OLD = as.character("OLD")) %>%
  ungroup()

print(OLD_dhcchiliconc)
## # A tibble: 12 × 6
##     CONC  AREA TYPE  NAME     TIME        OLD  
##    <dbl> <dbl> <chr> <chr>    <chr>       <chr>
##  1   100 2123. DHC   STANDARD 13.4974041  OLD  
##  2   100 2097. DHC   STANDARD 13.50980759 OLD  
##  3   100 2090. DHC   STANDARD 13.5306778  OLD  
##  4    80 1650. DHC   STANDARD 13.51975441 OLD  
##  5    80 1635. DHC   STANDARD 13.51579189 OLD  
##  6    80 1628. DHC   STANDARD 13.54709148 OLD  
##  7    20  424. DHC   STANDARD 13.67924976 OLD  
##  8    20  422. DHC   STANDARD 13.68560791 OLD  
##  9    20  420. DHC   STANDARD 13.69148445 OLD  
## 10    10  256. DHC   STANDARD 13.68187237 OLD  
## 11    10  256. DHC   STANDARD 13.68991375 OLD  
## 12    10  255. DHC   STANDARD 13.69652271 OLD
#CAPSAICIN - AREA
t.test(CAP_STANDARD$AREA,
       OLD_capchiliconc$AREA,
         paired = T,
         var.equal=T,
         conf.level=0.95, #Computing for 95% confidence interval
         detailed=TRUE)
## 
##  Paired t-test
## 
## data:  CAP_STANDARD$AREA and OLD_capchiliconc$AREA
## t = 2.3104, df = 11, p-value = 0.04127
## alternative hypothesis: true mean difference is not equal to 0
## 95 percent confidence interval:
##   2.158686 88.968701
## sample estimates:
## mean difference 
##        45.56369
#DIHYDROCAPSAICIN - AREA
t.test(DHC_STANDARD$AREA, 
       OLD_dhcchiliconc$AREA,
         paired = T,
         var.equal=T,
         conf.level=0.95,
         detailed=TRUE)
## 
##  Paired t-test
## 
## data:  DHC_STANDARD$AREA and OLD_dhcchiliconc$AREA
## t = 3.1385, df = 11, p-value = 0.009433
## alternative hypothesis: true mean difference is not equal to 0
## 95 percent confidence interval:
##   46.14694 262.81339
## sample estimates:
## mean difference 
##        154.4802

————————%BIAS———————-

TRUE_SHU_XT = tibble (pepper = c("Er Jing Tiao", "Er Jing Tiao", "Xiao Mi La", "Xiao Mi La"), SHU = c(45000,45000, 75000,75000))

TRUE_SHU_FV = tibble (pepper = c("Fruity Volcano"), SHU = c(135000))
percent_bias_xt_cap = ((CAP_SHU$SHU - TRUE_SHU_XT$SHU)/TRUE_SHU_XT$SHU)

percent_bias_xt_dhc = ((DHC_SHU$SHU - TRUE_SHU_XT$SHU)/TRUE_SHU_XT$SHU)

percent_bias_fv = ((FV_SHU$SHU - TRUE_SHU_FV$SHU)/TRUE_SHU_FV$SHU)

(percent_bias_xt_cap)
## [1] -0.8092499 -0.8967754 -0.7826673 -0.6173817
(percent_bias_xt_dhc)
## [1] -0.9460737 -0.9693940 -0.9331534 -0.8678598
(percent_bias_fv)
## [1] -0.2920456

Confidence Interval - Retention Time - Capsaicin

mean_cap = mean(CAP_SAMPLE_CONC$TIME)
sd_cap = sd(CAP_SAMPLE_CONC$TIME)

capsaicin_CI_lower <- mean_cap - qnorm(1-0.05/2)*sd_cap

capsaicin_CI_upper <- mean_cap + qnorm(1-0.05/2)*sd_cap

(capsaicin_CI_lower)
## [1] 8.574619
(capsaicin_CI_upper)
## [1] 11.75661

Confidence Interval - Retention Time - Dihydrocapsaicin

mean_dhc = mean(DHC_SAMPLE_CONC$TIME)
sd_dhc = sd(DHC_SAMPLE_CONC$TIME)

dhcapsaicin_CI_lower <- mean_dhc - qnorm(1-0.05/2)*sd_dhc

dhccapsaicin_CI_upper <- mean_dhc + qnorm(1-0.05/2)*sd_dhc

(dhcapsaicin_CI_lower)
## [1] 11.81915
(dhccapsaicin_CI_upper)
## [1] 16.773