Difference between revisions of "POPs in Baltic herring"

From Testiwiki
Jump to: navigation, search
(corrections to the model)
(Answer: updated for congener loop, needs still work)
Line 9: Line 9:
  
 
POP concentrations in Baltic sea fish have been measured from samples collected in EU-kalat project.
 
POP concentrations in Baltic sea fish have been measured from samples collected in EU-kalat project.
 
[http://en.opasnet.org/en-opwiki/index.php?title=Special:RTools&id=3f19VvkjoNHloJCn Model run 11.2.2016]
 
  
 
<rcode graphics=1>
 
<rcode graphics=1>
Line 18: Line 16:
  
 
dat <- opbase.data("Op_en3104", subset = "POPs")
 
dat <- opbase.data("Op_en3104", subset = "POPs")
dat <- dat[dat$POP == "2378TCDD" , ]
 
 
dat <- dat[dat$Fish_species == "Baltic herring" , ]
 
dat <- dat[dat$Fish_species == "Baltic herring" , ]
 +
congeners = levels(dat$POP)
 +
Y = length(congeners)
  
#Bayesian test based on http://doingbayesiandataanalysis.blogspot.fi/2013/04/bayesian-estimation-of-log-normal.html
+
for (j in 1 : 3 ) { #only three rounds for testing
 +
  compdat <- dat[dat$POP == congeners[j] , ]
 +
  mo <- textConnection("model{
 +
                    for( i in 1 : N ) {
 +
                    Compound[i] ~ dnorm(muOfLogCompound, tau2[i])
 +
                    tau2[i] <- tau1*sqrt(n[i])
 +
                    }                 
 +
                    tau1 ~ dunif(0.001, 1000)
 +
                    muOfLogCompound ~ dnorm(0, 0.001)
 +
                          }
 +
                    ")
  
mo <- textConnection("model{
+
LogCompound <- log(compdat$result+1) #+1 because of negative log values
                    for( i in 1 : N ) {
 
                    TCDD[i] ~ dlnorm(muOfLogTCDD, tau)#1/sigmaOfLogTCDD^2 )
 
                    }                 
 
                      tau ~ dunif(0.001, 1000)
 
                      #sigmaOfLogTCDD ~ dunif( 0.001, 1000 ) #*sdOfLogTCDD , 1000*sdOfLogTCDD )
 
                    muOfLogTCDD ~ dnorm(0, 0.001) # dnorm(meanOfLogTCDD , (0.001*(1/sdOfLogTCDD^2)))
 
                    #muOfTCDD <- (exp(muOfLogTCDD +sigmaOfLogTCDD^2/2))
 
                    #modeOfTCDD <- (exp(muOfLogTCDD-sigmaOfLogTCDD^2))
 
                    #sigmaOfTCDD <- (sqrt(exp(2*muOfLogTCDD+sigmaOfLogTCDD^2)*(exp(sigmaOfLogTCDD^2)-1)))
 
                    }
 
                    ")
 
#N <- nrow(dat)
 
#LogTCDD <- log(dat$result+1) #+1 because of negative log values
 
#TCDD <- 10^(LogTCDD-1)
 
  TCDD <- dat$Result + 0.0001
 
  N <- length(TCDD)
 
  
 
dataList = list(
 
dataList = list(
  TCDD = dat$Result + 0.0001,
+
    Compound = LogCompound,
  N = length(TCDD)
+
    N = length(LogCompound),
#  meanOfLogTCDD = mean(LogTCDD),
+
    n = compdat$N_individuals
#  sdOfLogTCDD = sd(LogTCDD)
 
 
)
 
)
  
Line 52: Line 44:
 
update(jags, 1000)
 
update(jags, 1000)
  
out <- coda.samples(jags, c('tau', 'muOfLogTCDD'), nrow(dat)) # Stores a posterior sample
+
out <- coda.samples(jags, c('tau1', 'muOfLogCompound'), 500) # Stores a posterior sample
 
plot(out)
 
plot(out)
 +
filename <- paste("out", j, sep="")
 +
assign(filename, out)
 +
 +
}
  
 
ggplot(dat, aes(x = Result, colour = Catch_location))+geom_density()+scale_x_log10()
 
ggplot(dat, aes(x = Result, colour = Catch_location))+geom_density()+scale_x_log10()

Revision as of 10:01, 8 March 2016



Question

What are the concentrations of persistent organic pollutants (POPs) in Baltic sea fish.

Answer

POP concentrations in Baltic sea fish have been measured from samples collected in EU-kalat project.

+ Show code

Rationale

See also

References