Difference between revisions of "POPs in Baltic herring"
From Testiwiki
m (→Rationale: fixed the resultsall posterior calculation precision to SD) |
m (→Rationale: code updated) |
||
Line 19: | Line 19: | ||
dat <- opbase.data("Op_en3104", subset = "POPs") | dat <- opbase.data("Op_en3104", subset = "POPs") | ||
dat <- dat[dat$Fish_species == "Baltic herring" , ] | dat <- dat[dat$Fish_species == "Baltic herring" , ] | ||
+ | |||
+ | dat <- subset(dat,!(is.na(dat["Result"]))) | ||
+ | dat <- dropall(dat) | ||
congeners <- levels(dat$POP) #names of different congeners in data | congeners <- levels(dat$POP) #names of different congeners in data | ||
Line 24: | Line 27: | ||
Y <- length(congeners) #number of congeners and j's in for loop | Y <- length(congeners) #number of congeners and j's in for loop | ||
− | + | compdat <- dat[dat$POP %in% congeners[1:Y] , ] #data for current congener | |
− | + | Compound <- log10(compdat$Result+1E-2) #+1E-2 because zero concentrations are not allowed | |
− | compdat <- dat[dat$POP %in% congeners[1: | ||
− | Compound <- | ||
mo <- textConnection("model{ | mo <- textConnection("model{ | ||
− | + | for (j in 1 : Y ) { | |
− | + | tau1[j] ~ dunif(0.001, 1000) | |
− | + | muOfCompound[j] ~ dnorm(0, 0.001) | |
− | + | } | |
− | + | for( i in 1 : N ) { | |
− | + | Compound[i] ~ dnorm(muOfCompound[POP[i]], tau2[i]) | |
− | + | tau2[i] <- tau1[POP[i]]*sqrt(n[i]) | |
− | + | } | |
− | + | } | |
− | ") | + | ") |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
dataList = list( | dataList = list( | ||
+ | Y = Y, | ||
Compound = Compound, | Compound = Compound, | ||
POP = as.numeric(compdat$POP), | POP = as.numeric(compdat$POP), | ||
Line 69: | Line 57: | ||
plot(out) | plot(out) | ||
− | + | Meanlogpost = c() | |
− | + | for (j in 1 : Y) { | |
+ | logmean <- mean(out[[4]][,j]) #calculate mean of logmu for posterior (test 4) | ||
+ | Meanlogpost = c(Meanlogpost, logmean) | ||
+ | } | ||
+ | Sdlogpost = c() | ||
+ | for (j in 1 : Y) { | ||
+ | logsd <- sqrt(1/(mean(out[[4]][,j+Y]))) | ||
+ | Sdlogpost = c(Sdlogpost, logsd) | ||
+ | } | ||
+ | |||
+ | Meanpost = c() | ||
+ | for (j in 1 : Y) { | ||
+ | mu = out[[4]][,j] | ||
+ | mean <- mean(10^mu)-1E-2 #calculate mean of mu for posterior (test 4) | ||
+ | Meanpost = c(Meanpost, mean) | ||
+ | } | ||
resultsall <- data.frame( | resultsall <- data.frame( | ||
Line 78: | Line 81: | ||
Meanlog = aggregate(Compound, compdat["POP"], mean)$x, #calculate mean for logdata | Meanlog = aggregate(Compound, compdat["POP"], mean)$x, #calculate mean for logdata | ||
Sdlog = aggregate(Compound, compdat["POP"], sd)$x, #calculate sd for logdata | Sdlog = aggregate(Compound, compdat["POP"], sd)$x, #calculate sd for logdata | ||
− | + | Meanlogpost = Meanlogpost, | |
− | + | Sdlogpost = Sdlogpost, | |
− | + | Meanpost = 10^Meanlogpost-1E-02, | |
− | + | Sdpost = 10^Sdlogpost-1E-02 | |
− | + | ) | |
− | |||
− | |||
− | |||
− | ) | ||
oprint(resultsall) | oprint(resultsall) |
Revision as of 11:23, 8 June 2016
This page is a variable.
The page identifier is Op_en2583 |
---|
Moderator:Nobody (see all) Click here to sign up. |
Give your opinion to the peer rating of the content of this page. |
Upload data
|
Contents
Question
What are the concentrations of persistent organic pollutants (POPs) in Baltic sea fish.
Answer
Rationale
POP concentrations in Baltic sea fish have been measured from samples collected in EU-kalat project.