Difference between revisions of "Goherr: Fish consumption study"

From Testiwiki
Jump to: navigation, search
(Analyses)
(Analyses: debugged)
Line 431: Line 431:
  
 
objects.latest("Op_en7749", "preprocess2") # [[Goherr: Fish consumption study]]: survey, surv, ...
 
objects.latest("Op_en7749", "preprocess2") # [[Goherr: Fish consumption study]]: survey, surv, ...
 +
 +
# Move this to preprocess. Combine eatherr, eatsalm and eathfish to surv as columns
 +
eatherr <- surv[[12]] %in% 2 & !is.na(rowSums(surv[13:16]))
  
 
cat("Version with multivariate normal.\n")
 
cat("Version with multivariate normal.\n")
Line 495: Line 498:
 
   )
 
   )
 
)
 
)
 +
 +
######## fish.param contains expected values of the distribution parameters from the model
  
 
fish.param <- list(
 
fish.param <- list(
Line 530: Line 535:
 
     )
 
     )
 
     jsp <- melt(jsp, id.vars = c("Iter", "Fish"), variable.name = "Question", value.name = "Result")
 
     jsp <- melt(jsp, id.vars = c("Iter", "Fish"), variable.name = "Question", value.name = "Result")
 +
    jsp <- Ovariable(output=jsp, marginal = colnames(jsp) %in% c("Iter", "Fish", "Question"))
 
     return(jsp)
 
     return(jsp)
 
   }
 
   }
 
)
 
)
  
oftenS <- Ovariable(
+
# Combine modelled survey answers with estimated amounts and frequencies by:
  "oftenS",
+
# Rounding the modelled result and merging that with value in ovariable assump
  dependencies = data.frame(Name="jsp"),
 
  formula = function(...) {
 
    jsp[jsp$Fish == "Salmon" & jsp$Question == "1" , !colnames(jsp@output) %in% c("Fish", "Question")]
 
  }
 
)
 
  
muchS <- Ovariable(
+
often <- Ovariable(
   "muchS",
+
   "often",
   dependencies = data.frame(Name="jsp"),
+
   dependencies = data.frame(Name=c("jsp","assump")),
 
   formula = function(...) {
 
   formula = function(...) {
     jsp[jsp$Fish == "Salmon" & jsp$Question == "2" , !colnames(jsp@output) %in% c("Fish", "Question")]
+
     out <- jsp[jsp$Question == "1" , !colnames(jsp@output) %in% c("Question")]
 +
    out$Value <- round(result(out))
 +
    out <- merge(
 +
      assump@output[assump$Variable == "freq",],
 +
      out@output
 +
    )
 +
    colnames(out)[colnames(out) == "assumpResult"] <- "Result"
 +
    return(out[!colnames(out) %in% c("Value", "Variable")])
 
   }
 
   }
 
)
 
)
  
oftensideS <- Ovariable(
+
much <- Ovariable(
   "oftensideS",
+
   "much",
   dependencies = data.frame(Name="jsp"),
+
   dependencies = data.frame(Name=c("jsp","assump")),
 
   formula = function(...) {
 
   formula = function(...) {
     jsp[jsp$Fish == "Salmon" & jsp$Question == "3" , !colnames(jsp@output) %in% c("Fish", "Question")]
+
     out <- jsp[jsp$Question == "2" , !colnames(jsp@output) %in% c("Question")]
 +
    out$Value <- round(result(out))
 +
    out <- merge(
 +
      assump@output[assump$Variable == "amdish",],
 +
      out@output
 +
    )
 +
    colnames(out)[colnames(out) == "assumpResult"] <- "Result"
 +
    return(out[!colnames(out) %in% c("Value", "Variable")])
 
   }
 
   }
 
)
 
)
  
muchsideS <- Ovariable(
+
oftenside <- Ovariable(
   "muchsideS",
+
   "oftenside",
   dependencies = data.frame(Name="jsp"),
+
   dependencies = data.frame(Name=c("jsp","assump")),
 
   formula = function(...) {
 
   formula = function(...) {
     jsp[jsp$Fish == "Salmon" & jsp$Question == "4" , !colnames(jsp@output) %in% c("Fish", "Question")]
+
     out <- jsp[jsp$Question == "3" , !colnames(jsp@output) %in% c("Question")]
 +
    out$Value <- round(result(out))
 +
    out <- merge(
 +
      assump@output[assump$Variable == "freq",],
 +
      out@output
 +
    )
 +
    colnames(out)[colnames(out) == "assumpResult"] <- "Result"
 +
    return(out[!colnames(out) %in% c("Value", "Variable")])
 
   }
 
   }
 
)
 
)
  
oftenH <- Ovariable(
+
muchside <- Ovariable(
   "oftenH",
+
   "muchside",
   dependencies = data.frame(Name="jsp"),
+
   dependencies = data.frame(Name=c("jsp","assump")),
 
   formula = function(...) {
 
   formula = function(...) {
     jsp[jsp$Fish == "Herring" & jsp$Question == "1" , !colnames(jsp@output) %in% c("Fish", "Question")]
+
     out <- jsp[jsp$Question == "4" , !colnames(jsp@output) %in% c("Question")]
 +
    out$Value <- round(result(out))
 +
    out <- merge(
 +
      assump@output[assump$Variable == "amside",],
 +
      out@output
 +
    )
 +
    colnames(out)[colnames(out) == "assumpResult"] <- "Result"
 +
    return(out[!colnames(out) %in% c("Value", "Variable")])
 
   }
 
   }
 
)
 
)
  
muchH <- Ovariable(
+
assump <- Ovariable(
   "muchH",
+
   "assump",
   dependencies = data.frame(Name="jsp"),
+
   ddata = "Op_en7749", subset = "Assumptions for calculations"
  formula = function(...) {
 
    jsp[jsp$Fish == "Herring" & jsp$Question == "2" , !colnames(jsp@output) %in% c("Fish", "Question")]
 
  }
 
)
 
 
 
oftensideH <- Ovariable(
 
  "oftensideH",
 
  dependencies = data.frame(Name="jsp"),
 
  formula = function(...) {
 
    jsp[jsp$Fish == "Herring" & jsp$Question == "3" , !colnames(jsp@output) %in% c("Fish", "Question")]
 
  }
 
)
 
 
 
muchsideH <- Ovariable(
 
  "muchsideH",
 
  dependencies = data.frame(Name="jsp"),
 
  formula = function(...) {
 
    jsp[jsp$Fish == "Herring" & jsp$Question == "4" , !colnames(jsp@output) %in% c("Fish", "Question")]
 
  }
 
 
)
 
)
  
Line 601: Line 611:
 
   "amount",
 
   "amount",
 
   dependencies = data.frame(Name = c(
 
   dependencies = data.frame(Name = c(
     "oftenS", "muchS",
+
     "often",
     "oftensideS", "muchsideS",
+
    "much",
     "oftenH", "muchH",
+
     "oftenside",
     "oftensideH", "muchsideH"
+
     "muchside",
 +
     "assump"
 
   ))
 
   ))
 
   , formula = function(...) {
 
   , formula = function(...) {
     oftenS * muchS + oftensideS * muchsideS + oftenH * muchH + oftensideH * muchsideH
+
     assump <- assump[assump$Variable == "ingredient", !colnames(assump@output) %in% c("Variable", "Value", "Explanation")]
 +
    out <- often * much + oftenside * muchside * assump
 
   }
 
   }
 
)
 
)
 +
 +
jsp <- EvalOutput(jsp)
 +
often <- EvalOutput(often)
 +
much <- EvalOutput(much)
 +
oftenside <- EvalOutput(oftenside)
 +
muchside <- EvalOutput(muchside)
 +
assump <- EvalOutput(assump)
 +
 
amount <- EvalOutput(amount)
 
amount <- EvalOutput(amount)
 
oprint(head(amount@output))
 
oprint(head(amount@output))
scatterplotMatrix(jsp[[1]])
+
#scatterplotMatrix(jsp[[1]])
scatterplotMatrix(t(js[,,6]))
+
#scatterplotMatrix(t(js[,,6]))
  
head(t(js[,,6]))
+
#ggplot(melt(js), aes(x=value, colour=Var2))+geom_density()
ggplot(melt(js), aes(x=value, colour=Var2))+geom_density()
+
#ggplot(as.data.frame(js), aes(x = anss.pred, y = Sampled))+geom_point()+stat_ellipse()
ggplot(as.data.frame(js), aes(x = anss.pred, y = Sampled))+geom_point()+stat_ellipse()
+
#coda.j <- coda.samples(
coda.j <- coda.samples(
+
jags,  
  jags,  
+
c('mus', 'Omegas', 'anss.pred', 'mu0'),  
  c('mus', 'Omegas', 'anss.pred', 'mu0'),  
+
1000
  1000
+
#)
)
 
  
plot(coda.j)
+
#plot(coda.j)
jh <- array(
+
#jh <- array(
  samps.j$ansh.pred,
+
samps.j$ansh.pred,
  dim = c(4,1000,4),
+
dim = c(4,1000,4),
  dimnames = list(Question = 1:4, Iter = 1:1000, Seed = 1:4)
+
dimnames = list(Question = 1:4, Iter = 1:1000, Seed = 1:4)
)
+
#)
scatterplotMatrix(t(jh[,,1]))
+
#scatterplotMatrix(t(jh[,,1]))
  
 
#objects.store(oftenh, muchh, ofsideh, musideh, oftens, muchs, ofsides, musides)
 
#objects.store(oftenh, muchh, ofsideh, musideh, oftens, muchs, ofsides, musides)
Line 662: Line 681:
 
salmon_ingridient <- Ovariable("salmon_ingridient", data = assumptions[assumptions$Variable == "ingridient", ]["Result"])
 
salmon_ingridient <- Ovariable("salmon_ingridient", data = assumptions[assumptions$Variable == "ingridient", ]["Result"])
  
salmon_sidetimesassump <- Ovariable("salmon_wholetimesassump", data = assumptions[assumptions$Variable == "freq" , c("value", "Result")])
+
salmon_sidetimesassump <- Ovariable("salmon_wholetimesassump", data = assumptions[assumptions$Variable == "freq" , c("Value", "Result")])
  
salmon_sideamountassump <- Ovariable("salmon_wholeamountassump", data = assumptions[assumptions$Variable == "amside" , c("value", "Result")])
+
salmon_sideamountassump <- Ovariable("salmon_wholeamountassump", data = assumptions[assumptions$Variable == "amside" , c("Value", "Result")])
  
 
##Build up the variables to calculate amount of Baltic salmon eating
 
##Build up the variables to calculate amount of Baltic salmon eating
Line 819: Line 838:
  
 
The following assumptions are used:  
 
The following assumptions are used:  
<t2b name="Assumptions for calculations" index="Variable,value,Explanation" obs="Result" unit="-">
+
<t2b name="Assumptions for calculations" index="Variable,Value,Explanation" obs="Result" unit="-">
 
freq|6|times per year|260 - 364
 
freq|6|times per year|260 - 364
 
freq|5|times per year|104 - 208
 
freq|5|times per year|104 - 208
Line 834: Line 853:
 
amdish|5|grams / serving|270 - 300
 
amdish|5|grams / serving|270 - 300
 
amdish|6|grams / serving|450 - 500
 
amdish|6|grams / serving|450 - 500
ingridient||fraction|0.1 - 0.3
+
ingredient||fraction|0.1 - 0.3
 
amside|0|grams / serving|20 - 50
 
amside|0|grams / serving|20 - 50
 
amside|1|grams / serving|70 - 100
 
amside|1|grams / serving|70 - 100

Revision as of 19:16, 20 April 2017


Question

How Baltic herring and salmon are used as human food in Baltic sea countries? Which determinants affect on people’s eating habits of these fish species?

Answer

Survey data will be analysed during winter 2016-2017 and results will be updated here.

+ Show code

Rationale

Survey of eating habits of Baltic herring and salmon in Denmark, Estonia, Finland and Sweden has been done in September 2016 by Taloustutkimus oy. Content of the questionnaire can be accessed in Google drive. The actual data will be uploaded to Opasnet base on Octobere 2016.

The R-code to analyse the survey data will be provided on this page later on.

Data

Original datafile File:Goherr fish consumption.csv

Preprocessing

This code is used to preprocess the original questionnaire data from the above .csv file and to store the data as a usable variable to Opasnet base. The code stores a data.frame named survey.

  • Model run 13.4.2017 [1]
  • Model run 20.4.2017 [2] (contains surv and helping vectors)

+ Show code

Analyses

Error creating thumbnail: Unable to save thumbnail to destination
Correlation matrix of all questions in the survey (answers converted to numbers).

Model must contain predictors such as country, gender, age etc. Maybe we should first study what determinants are important? Model must also contain determinants that would increase or decrease fish consumption. This should be conditional on the current consumption. How? Maybe we should look at principal coordinates analysis with all questions to see how they behave.

Also look at correlation table to see clusters.

Some obvious results:

  • If reports no fish eating, many subsequent answers are NA.
  • No vitamins correlates negatively with vitamin intake.
  • Unknown salmon correlates negatively with the types of salmon eaten.
  • Different age categories correlate with each other.

However, there are also meaningful negative correlations:

  • Country vs allergy
  • Country vs Norwegian salmon and Rainbow trout
  • Country vs not traditional.
  • Country vs recommendation awareness
  • Allergy vs economic wellbeing
  • Baltic salmon use (4 questions) vs Don't like taste and Not used to
  • All questions between Easy to cook ... Traditional dish

Meaningful positive correlations:

  • All questions between Baltic salmon ... Rainbow trout
  • How often Baltic salmon/herring/side salmon/side herring
  • How much Baltic salmon/herring/side salmon/side herring
  • Better availability ... Recommendation
  • All questions between Economic wellbeing...Personal aims
  • Omega3, Vitamin D, and Other vitamins

Study plan:

  • Determinants

+ Show code

Bayes model

  • Model run 3.3.2017. All variables assumed independent. [3]
  • Model run 3.3.2017. p has more dimensions. [4]
  • Model run 25.3.2017. Several model versions: strange binomial+multivarnormal, binomial, fractalised multivarnormal [5]
  • Model run 27.3.2017 [6]
  • Other models except multivariate normal were archived and removed from active code 29.3.2017.
  • Model run 29.3.2017 with raw data graphs [7]
  • Model run 29.3.2017 with salmon and herring ovariables stored [8]
  • Model run 13.4.2017 with first version of coordinate matrix and principal coordinate analysis [9]

+ Show code

Calculations

This code calculates how much (g/day) Baltic herring and salmon are eaten based on an Bayesian model build up based on the questionnaire data.

+ Show code

Assumptions

The following assumptions are used:

Assumptions for calculations(-)
ObsVariableValueExplanationResult
1freq6times per year260 - 364
2freq5times per year104 - 208
3freq4times per year52
4freq3times per year12 - 36
5freq2times per year2 - 5
6freq1times per year0.5 - 0.9
7freq0times per year0
8amdish0grams / serving20 - 50
9amdish1grams / serving70 - 100
10amdish2grams / serving120 - 150
11amdish3grams / serving170 - 200
12amdish4grams / serving220 - 250
13amdish5grams / serving270 - 300
14amdish6grams / serving450 - 500
15ingredientfraction0.1 - 0.3
16amside0grams / serving20 - 50
17amside1grams / serving70 - 100
18amside2grams / serving120 - 150
19amside3grams / serving170 - 200
20amside4grams / serving220 - 250

Questionnaire


Dependencies

The survey data will be used as input in the benefit-risk assessment of Baltic herring and salmon intake, which is part of the WP5 work in Goherr-project.

Formula

See also

Keywords

References


Related files

<mfanonymousfilelist></mfanonymousfilelist>

Goherr: Fish consumption study. Opasnet . [10]. Accessed 17 May 2024.