I have a dataset that contains triplicate measurements of 16 different PAHs (pollutants) in 23 different samples. I would like to calculate the propagated error for the sum of the mean triplicate concentration of the 16 PAHs for each sample. Is there a function that does this in R? Here is the dataset for one of the samples I have:
Q <- biochar %>% filter(pollutant_class == "PAH", sample_ID == "WT-BC-700") %>% select(sample_ID, pollutant, conc)sample_ID pollutant conc2 WT-BC-700 Acenaphthene 0.50925 WT-BC-700 Acenaphthene 0.43046 WT-BC-700 Acenaphthene 0.4913 WT-BC-700 Acenaphthylene 3.41026 WT-BC-700 Acenaphthylene 2.99042 WT-BC-700 Acenaphthylene 3.50027 WT-BC-700 Anthracene 1.81036 WT-BC-700 Anthracene 2.09040 WT-BC-700 Anthracene 2.02020 WT-BC-700 Benz(a)anthracene 0.08132 WT-BC-700 Benz(a)anthracene 0.08748 WT-BC-700 Benz(a)anthracene 0.0861 WT-BC-700 Benzo(a)pyrene 0.0788 WT-BC-700 Benzo(a)pyrene 0.0899 WT-BC-700 Benzo(a)pyrene 0.0967 WT-BC-700 Benzo(b)fluoranthene 0.05115 WT-BC-700 Benzo(b)fluoranthene 0.05622 WT-BC-700 Benzo(b)fluoranthene 0.05516 WT-BC-700 Benzo(ghi)perylene 0.02224 WT-BC-700 Benzo(ghi)perylene 0.02234 WT-BC-700 Benzo(ghi)perylene 0.0206 WT-BC-700 Benzo(k)fluoranthene 0.06721 WT-BC-700 Benzo(k)fluoranthene 0.07139 WT-BC-700 Benzo(k)fluoranthene 0.0804 WT-BC-700 Chrysene 0.0935 WT-BC-700 Chrysene 0.09723 WT-BC-700 Chrysene 0.08417 WT-BC-700 Dibenz(ah)anthracene 0.00719 WT-BC-700 Dibenz(ah)anthracene 0.00937 WT-BC-700 Dibenz(ah)anthracene 0.00911 WT-BC-700 Fluoranthene 1.59033 WT-BC-700 Fluoranthene 1.44047 WT-BC-700 Fluoranthene 1.62030 WT-BC-700 Fluorene 0.85041 WT-BC-700 Fluorene 0.87745 WT-BC-700 Fluorene 0.78218 WT-BC-700 Indeno(1,2,3-cd)pyrene 0.03029 WT-BC-700 Indeno(1,2,3-cd)pyrene 0.03343 WT-BC-700 Indeno(1,2,3-cd)pyrene 0.02413 WT-BC-700 Naphthalene 5.62014 WT-BC-700 Naphthalene 4.38044 WT-BC-700 Naphthalene 5.73010 WT-BC-700 Phenanthrene 6.64028 WT-BC-700 Phenanthrene 7.08035 WT-BC-700 Phenanthrene 5.93012 WT-BC-700 Pyrene 0.98631 WT-BC-700 Pyrene 1.19038 WT-BC-700 Pyrene 1.110
I have created a summary table with the mean and standard deviation of each pollutant:
means <- Q %>% group_by(sample_ID, pollutant) %>% summarise(mean_conc = mean(conc), sd_conc = sd(conc))`summarise()` has grouped output by 'sample_ID'. You can override using the`.groups` argument.means # A tibble: 16 × 4# Groups: sample_ID [1] sample_ID pollutant mean_conc sd_conc<chr> <chr> <dbl> <dbl> 1 WT-BC-700 Acenaphthene 0.477 0.0414 2 WT-BC-700 Acenaphthylene 3.3 0.272 3 WT-BC-700 Anthracene 1.97 0.146 4 WT-BC-700 Benz(a)anthracene 0.0847 0.00321 5 WT-BC-700 Benzo(a)pyrene 0.0877 0.00907 6 WT-BC-700 Benzo(b)fluoranthene 0.054 0.00265 7 WT-BC-700 Benzo(ghi)perylene 0.0213 0.00115 8 WT-BC-700 Benzo(k)fluoranthene 0.0727 0.00666 9 WT-BC-700 Chrysene 0.0913 0.0066610 WT-BC-700 Dibenz(ah)anthracene 0.00833 0.0011511 WT-BC-700 Fluoranthene 1.55 0.0964 12 WT-BC-700 Fluorene 0.836 0.0490 13 WT-BC-700 Indeno(1,2,3-cd)pyrene 0.029 0.0045814 WT-BC-700 Naphthalene 5.24 0.750 15 WT-BC-700 Phenanthrene 6.55 0.580 16 WT-BC-700 Pyrene 1.10 0.103
And then I created a summary of the total concentration of all the PAHs:
summary <- means %>% group_by(sample_ID) %>% summarise(sum_pollutant = sum(mean_conc))summary# A tibble: 1 × 2 sample_ID sum_pollutant<chr> <dbl>1 WT-BC-700 21.5
So my question is: how can I calculate the propagated error for sum_pollutant
in the summary
data frame?
I tried finding the answer in the propagate() package, but this got a bit too complex for me and I wasn't sure if this was the right place to look. I would like to use the following expression for the propagated error:
σx = sqrt(σa^2 +σb^2 +σc^2)
a, b, and c are measured variables and σa, σb, and σc are the standard deviations of those variables.