EU-kalat: Difference between revisions

From Opasnet
Jump to navigation Jump to search
(→‎Bayes model for dioxin concentrations: now works but mixing is still not great)
(→‎Bayes model for dioxin concentrations: length and year in model)
Line 275: Line 275:
# It uses the TEQ sum of PCDD/F (PCDDF) as the total concentration
# It uses the TEQ sum of PCDD/F (PCDDF) as the total concentration
# of dioxin and PCB respectively for PCB in fish.
# of dioxin and PCB respectively for PCB in fish.
# PCDDF depends on age of fish, fish species and catchment area,
# PCDDF depends on size of fish, fish species, catchment time, and catchment area,
# but we only have species now so other variables are omitted.
# but we omit catchment area. In addition, we assume that size of fish has
# cong depends on fish species.
# zero effect for other fish than Baltic herring.
# Catchment year affects all species similarly.  


eu3 <- eu2[eu2$Compound %in% conl & eu2$Fish %in% fisl & eu2$Matrix == "Muscle" , ]
eu2 <- eu2[eu2$Compound %in% conl & eu2$Fish %in% fisl & eu2$Matrix == "Muscle" , ]
eu3 <- reshape( # Gives warning that more than one value and first taken. Why?
eu3 <- reshape(  
   eu3@output,  
   eu2@output,  
   v.names = "euResult",  
   v.names = "euResult",  
   idvar = c("THLcode", "Fish"),
   idvar = c("THLcode", "Fish"),
Line 295: Line 296:
#[6] "euResult.PCDDF" "euResult.PCB"   
#[6] "euResult.PCDDF" "euResult.PCB"   


cong <- data.matrix(eu3[6:ncol(eu3)])
conc <- data.matrix(eu3[6:ncol(eu3)])


if(FALSE){
if(FALSE){
Line 302: Line 303:
   # With TEQ, there are no zeros. So this is useful only if there are congener-specific results.
   # With TEQ, there are no zeros. So this is useful only if there are congener-specific results.
   names(LOQ) <- conl
   names(LOQ) <- conl
 
 
 
 
   cong <- sapply(
   conc <- sapply(
     1:length(LOQ),
     1:length(LOQ),
     FUN = function(x) ifelse(cong[,x]==0, 0.5*LOQ[x], cong[,x])
     FUN = function(x) ifelse(conc[,x]==0, 0.5*LOQ[x], conc[,x])
   )
   )
}
}
# This version of the model looks only at Baltic herring, Large herring, small herring and salmon.
# This version of the model looks only at Baltic herring and salmon.
# It assumes that all fish groups have the same Omega but mu varies.
# It assumes that all fish groups have the same Omega but mu varies.


Line 316: Line 317:
   model{
   model{
   for(i in 1:S) { # S = fish sample
   for(i in 1:S) { # S = fish sample
   #        below.LOQ[i,j] ~ dinterval(-cong[i,j], -LOQ[j])
   #        below.LOQ[i,j] ~ dinterval(-conc[i,j], -LOQ[j])
   cong[i,1:C] ~ dmnorm(muind[i,], Omega[,])
   conc[i,1:C] ~ dmnorm(muind[i,], Omega[fis[i],,])
   muind[i,1:C] <- mu[fis[i],1:C] + lenp[fis[i]]*length[i] # + timep*year[i]
   muind[i,1:C] <- mu[fis[i],1:C] + lenp[fis[i]]*length[i] + timep*year[i]
   }
   }
    
    
   # Priors for parameters
   # Priors for parameters
# timep ~ dnorm(0, 0.0001) # Time trend. We don't want to use it yet
  # Time trend. Assumed a known constant because at the moment there is little time variation in data.
 
  # https://www.evira.fi/elintarvikkeet/ajankohtaista/2018/itameren-silakoissa-yha-vahemman-ymparistomyrkkyja---paastojen-rajoitukset-vaikuttavat/
  # PCDDF/PCB-concentations 2001: 9 pg/g fw, 2016: 3.5 pg/g fw. (3.5/9)^(1/15)-1=-0.06102282
  timep ~ dnorm(-0.0610, 10000)
  lenp[1] ~ dnorm(0.01,0.01) # length parameter for herring
  lenp[2] ~ dnorm(0,10000) # length parameter for salmon: assumed zero
 
   for(i in 1:Fi) { # Fi = fish species
   for(i in 1:Fi) { # Fi = fish species
   lenp[i] ~ dnorm(0,0.0001) # length parameter
   Omega[i,1:C,1:C] ~ dwish(Omega0[1:C,1:C],S)
   pred[i,1:C] ~ dmnorm(mu[i,1:C]+lenp[i]*lenpred[i], Omega[,]) # Model prediction. Not used: +timep*timepred
   pred[i,1:C] ~ dmnorm(mu[i,1:C]+lenp[i]*lenpred+timep*timepred, Omega[i,,]) # Model prediction.
   for(j in 1:C) {  
   for(j in 1:C) {  
    mu[i,j] ~ dnorm(0, 0.0001) # mu1[j], tau1[j]) # Congener-specific mean for fishes
  mu[i,j] ~ dnorm(0, 0.0001) # mu1[j], tau1[j]) # Congener-specific mean for fishes
   }
   }
   }
   }
  Omega[1:C,1:C] ~ dwish(Omega0[1:C,1:C],S)
   }
   }
")
  ")


jags <- jags.model(
jags <- jags.model(
Line 341: Line 346:
     C = C,
     C = C,
     Fi = Fi,
     Fi = Fi,
     cong = log(cong),
     conc = log(conc),
     length = eu3$Length,
     length = eu3$Length-170, # Subtract average herring size
#    year = eu3$Year,
    year = eu3$Year-2009, # Substract baseline year
     fis = match(eu3$Fish, fisl),
     fis = match(eu3$Fish, fisl),
     lenpred = c(170, 860),
     lenpred = 233-170,
#    timepred = 2009,
    timepred = 2009-2009,
     Omega0 = diag(C)/100000
     Omega0 = diag(C)/100000
   ),
   ),
Line 362: Line 367:
     'lenp',# parameters for length
     'lenp',# parameters for length
     'timep', # parameter for Year
     'timep', # parameter for Year
     'pred' # predicted concentration for year 2009 and 17 cm herring, 80 cm salmon
     'pred' # predicted concentration for year 2009 and length 17 cm  
   ),  
   ),  
#  thin=1000,
  #  thin=1000,
   N
   N
)
)
dimnames(samps.j$Omega) <- list(Fish = fisl, Compound = conl, Compound2 = conl, Iter=1:N, Chain=1:4)
dimnames(samps.j$mu) <- list(Fish = fisl, Compound = conl, Iter = 1:N, Chain = 1:4)
dimnames(samps.j$mu) <- list(Fish = fisl, Compound = conl, Iter = 1:N, Chain = 1:4)
dimnames(samps.j$lenp) <- list(Fish = fisl, Iter = 1:N, Chain = 1:4)
dimnames(samps.j$lenp) <- list(Fish = fisl, Iter = 1:N, Chain = 1:4)
dimnames(samps.j$pred) <- list(Fish = fisl, Compound = conl, Iter = 1:N, Chain = 1:4)
dimnames(samps.j$pred) <- list(Fish = fisl, Compound = conl, Iter = 1:N, Chain = 1:4)
dimnames(samps.j$Omega) <- list(Compound = conl, Compound2 = conl, Iter=1:N, Chain=1:4)
dimnames(samps.j$timep) <- list(Param = "time", Iter = 1:N, Chain = 1:4)


##### conc.param contains expected values of the distribution parameters from the model
##### conc.param contains expected values of the distribution parameters from the model
conc.param <- list(
conc.param <- list(
   Omega = apply(samps.j$Omega[,,,1], MARGIN = 1:2, FUN = mean),
   Omega = apply(samps.j$Omega, MARGIN = 1:3, FUN = mean),
   lenp.mean = apply(samps.j$lenp[,,1], MARGIN = 1, FUN = mean),
   lenp.mean = apply(samps.j$lenp, MARGIN = 1, FUN = mean),
   lenp.sd = apply(samps.j$lenp[,,1], MARGIN = 1, FUN = sd),
   lenp.sd = apply(samps.j$lenp, MARGIN = 1, FUN = sd),
   mu = apply(samps.j$mu[,,,1], MARGIN = 1:2, FUN = mean)
   mu = apply(samps.j$mu, MARGIN = 1:2, FUN = mean),
timep.mean = apply(samps.j$lenp[,,1], MARGIN = 1, FUN = mean),
  timep.mean = apply(samps.j$timep, MARGIN = 1, FUN = mean),
timep.sd = apply(samps.j$lenp[,,1], MARGIN = 1, FUN = sd)
  timep.sd = apply(samps.j$timep, MARGIN = 1, FUN = sd)
)
)


if(FALSE){
objects.store(conc.param, samps.j)
objects.store(conc.param, samps.j)
cat("Lists conc.params and samps.j stored.\n")
cat("Lists conc.params and samps.j stored.\n")
Line 397: Line 404:
#))
#))


ggplot(eu2@output[eu2$Fish %in% fisl & eu2$Compound %in% conl,], aes(x = euResult, colour=Compound))+stat_ecdf()+
ggplot(eu2@output, aes(x = euResult, colour=Compound))+stat_ecdf()+
   facet_wrap( ~ Fish)+scale_x_log10()
   facet_wrap( ~ Fish)+scale_x_log10()


ggplot(melt(exp(samps.j$pred[,,,1])), aes(x=value, colour=Compound))+stat_ecdf()+
}
  facet_wrap( ~ Fish)+scale_x_log10()


scatterplotMatrix(t(samps.j$pred[1,,,1]), main = "Predictions for all compounds for Baltic herring")
fislen <- c(233, 170)
scatterplotMatrix(t(samps.j$pred[,1,,1]), main = "Predictions for all fish species for PCDDF")


coda.j <- coda.samples(
jsp <- lapply(1:length(conc.param$mu[, 1]), FUN = function(x) {
   jags,  
  temp <- exp(mvrnorm(
   c('mu', 'pred','lenp'),  
    openv$N,
#  thin=1000,
    conc.param$mu[x, ]+conc.param$lenp.mean*(fislen[x]-170)+conc.param$timep.mean*(2009-2009),
   N
    solve(conc.param$Omega[x, , ])
)
   ))
  dimnames(temp) <- c(list(Iter = 1:openv$N), dimnames(conc.param$mu)[2])
   return(temp)
})
names(jsp) <- dimnames(conc.param$mu)[[1]]
jsp <- melt(jsp, value.name = "Result")
colnames(jsp)[colnames(jsp) == "L1"] <- "Fish"
   
ggplot()+
  stat_ecdf(data=eu2@output, aes(x=euResult, colour="Data"))+
  stat_ecdf(data=melt(exp(samps.j$pred[,,,1])), aes(x=value, colour="Bayes estimate"))+
  stat_ecdf(data=jsp, aes(x=Result, colour="MC estimate"))+
   facet_grid(Compound ~ Fish)+scale_x_log10()


plot(coda.j)  
ggplot(eu2@output,
      aes(x = Length, y = euResult, colour=Compound))+geom_point()+
  facet_grid(Compound ~ Fish, scale="free_x")+scale_y_log10()


coda.o <- coda.samples(
scatterplotMatrix(t(exp(samps.j$pred[1,,,1])), main = "Predictions for all compounds for Baltic herring")
  jags,  
scatterplotMatrix(t(exp(samps.j$pred[,1,,1])), main = "Predictions for all fish species for PCDDF")
  c('Omega'),  
  N
)


plot(coda.o)  
plot(coda.samples(jags, 'Omega', N))
plot(coda.samples(jags, 'mu', N))
plot(coda.samples(jags, 'lenp', N))
plot(coda.samples(jags, 'timep', N))
plot(coda.samples(jags, 'pred', N))
</rcode>
</rcode>



Revision as of 11:07, 24 March 2018


EU-kalat is a study, where concentrations of PCDD/Fs, PCBs, PBDEs and heavy metals have been measured from fish

Question

The scope of EU-kalat study was to measure concentrations of persistent organic pollutants (POPs) including dioxin (PCDD/F), PCB and BDE in fish from Baltic sea and Finnish inland lakes and rivers. [1] [2] [3].

Answer

Dioxin concentrations in Baltic herring.

The original sample results can be acquired from Opasnet base. The study showed that levels of PCDD/Fs and PCBs depends especially on the fish species. Highest levels were on salmon and large sized herring. Levels of PCDD/Fs exceeded maximum level of 4 pg TEQ/g fw multiple times. Levels of PCDD/Fs were correlated positively with age of the fish.

Mean congener concentrations as WHO2005-TEQ in Baltic herring can be printed out with this link or by running the codel below.

+ Show code

Rationale

Data

Data was collected between 2009-2010. The study contains years, tissue type, fish species, and fat content for each concentration measurement. Number of observations is 285.

There is a new study EU-kalat 3, which will produce results in 2016.

Calculations

Preprocess

  • Preprocess model 22.2.2017 [4]
  • Model run 25.1.2017 [5]
  • Model run 22.5.2017 with new ovariables euRaw, euAll, euMain, and euRatio [6]
  • Model run 23.5.2017 with adjusted ovariables euRaw, eu, euRatio [7]
  • Model run 11.10.2017: Small herring and Large herring added as new species [8]
  • Model rerun 15.11.2017 because the previous stored run was lost in update [9]
  • Model run 21.3.2018: Small and large herring replaced by actual fish length [10]

+ Show code

Bayes model for dioxin concentrations

  • Model run 28.2.2017 [11]
  • Model run 28.2.2017 with corrected survey model [12]
  • Model run 28.2.2017 with Mu estimates [13]
  • Model run 1.3.2017 [14]
  • Model run 23.4.2017 [15] produces list conc.param and ovariable concentration
  • Model run 24.4.2017 [16]
  • Model run 19.5.2017 without ovariable concentration [17] ⇤--#: . The model does not mix well, so the results should not be used for final results. --Jouni (talk) 19:37, 19 May 2017 (UTC) (type: truth; paradigms: science: attack)
----#: . Maybe we should just estimate TEQs until the problem is fixed. --Jouni (talk) 19:37, 19 May 2017 (UTC) (type: truth; paradigms: science: comment)
  • Model run 22.5.2017 with TEQdx and TEQpcb as the only Compounds [18]
  • Model run 23.5.2017 debugged [19] [20] [21]
  • Model run 24.5.2017 TEQdx, TECpcb -> PCDDF, PCB [22]
  • Model run 11.10.2017 with small and large herring [23] (removed in update)
  • Model run 12.3.2018: bugs fixed with data used in Bayes. In addition, redundant fish species removed and Omega assumed to be the same for herring and salmon. [24]
  • Model run 22.3.2018 [25] Model does not mix well. Thinning gives little help?

+ Show code

Initiate conc_pcddf

  • Model run 19.5.2017 [26]
  • Model run 23.5.2017 with bugs fixed [27]
  • Model run 12.10.2017: TEQ calculation added [28]
  • Model rerun 15.11.2017 because the previous stored run was lost in update [29]
  • 12.3.2018 adjusted to match the same Omega for all fish species [30]

+ Show code

⇤--#: . These codes should be coherent with POPs in Baltic herring. --Jouni (talk) 12:14, 7 June 2017 (UTC) (type: truth; paradigms: science: attack)

See also

References

  1. A. Hallikainen, H. Kiviranta, P. Isosaari, T. Vartiainen, R. Parmanne, P.J. Vuorinen: Kotimaisen järvi- ja merikalan dioksiinien, furaanien, dioksiinien kaltaisten PCB-yhdisteiden ja polybromattujen difenyylieettereiden pitoisuudet. Elintarvikeviraston julkaisuja 1/2004. [1]
  2. E-R.Venäläinen, A. Hallikainen, R. Parmanne, P.J. Vuorinen: Kotimaisen järvi- ja merikalan raskasmetallipitoisuudet. Elintarvikeviraston julkaisuja 3/2004. [2]
  3. Anja Hallikainen, Riikka Airaksinen, Panu Rantakokko, Jani Koponen, Jaakko Mannio, Pekka J. Vuorinen, Timo Jääskeläinen, Hannu Kiviranta. Itämeren kalan ja muun kotimaisen kalan ympäristömyrkyt: PCDD/F-, PCB-, PBDE-, PFC- ja OT-yhdisteet. Eviran tutkimuksia 2/2011. ISSN 1797-2981 ISBN 978-952-225-083-4 [3]