Difference between revisions of "Goherr: Fish consumption study"

From Testiwiki
Jump to: navigation, search
m (Assumptions)
(Initiate ovariables)
 
(44 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{variable|moderator=Arja|stub=Yes}}
+
{{study|moderator=Arja|stub=Yes}}
  
 
== Question ==
 
== Question ==
Line 5: Line 5:
  
 
== Answer ==
 
== Answer ==
Survey data will be analysed during winter 2016-2017 and results will be updated here.
 
  
<rcode label="Show results" embed=0 graphics=1>
+
Original questionnaire analysis results
 
+
*[http://en.opasnet.org/en-opwiki/index.php?title=Special:RTools&id=QaMJZqUX0cPaTfOF 13.3.2017] {{comment|# |These should be presented somewhere|--[[User:Arja|Arja]] ([[User talk:Arja|talk]]) 07:39, 26 April 2017 (UTC)}}
 +
 
 +
Consumption amount estimates
 +
* Model run 21.4.2017 [http://en.opasnet.org/en-opwiki/index.php?title=Special:RTools&id=xc0kaCs8cgzpjwo9] first distribution
 +
* Model run 18.5.2017 [http://en.opasnet.org/en-opwiki/index.php?title=Special:RTools&id=YnuQMDJTQgW1Se5a with modelled data]; [http://en.opasnet.org/en-opwiki/index.php?title=Special:RTools&id=KXXFiP0aj0DYEPdx with direct survey data]
 +
 
 +
<rcode graphics=1 variables="
 +
name:usesurvey|description:Do you want to use directly the survey data rather than modelled data?|type:selection|options:
 +
FALSE;No, use modelled data;TRUE;Yes, use survey data
 +
">
 +
# This is code Op_en7749/ on page [[Goherr: Fish consumption study#Answer]]
 +
 
 
library(OpasnetUtils)
 
library(OpasnetUtils)
 
library(ggplot2)
 
library(ggplot2)
library(reshape2)
 
  
objects.latest("Op_en7749", "preprocess")
+
objects.latest("Op_en7749", code_name="initiate") # [[Goherr: Fish consumption study]] ovariables
  
for(i in c(5:6, 16, 29:30, 46:49, 85:86, 95:98, 135)) {
+
if(usesurvey) {
   temp <- survey[!is.na(survey[[i]]),]
+
   objects.latest("Op_en7749", code_name="surveyjsp") # jsp ovariable directly based on survey data (N=2217)
    p <- ggplot(temp, aes(x = temp[[i]])) + geom_bar() +
+
  openv.setN(nrow(jsp@data))
    theme_gray(base_size = 18) + theme(axis.text.x=element_text(angle=90,hjust=1,vjust=0.4)) +
 
    labs(title = colnames(temp[i])) + xlab("") + facet_wrap(~ Country)
 
  print(p)
 
 
}
 
}
  
temp <- melt(survey, measure.vars = 145:153, variable.name = "Changing.factor", value.name = "Impact")
+
amount <- EvalOutput(amount)
levs <- c("-5 strongly disagree", "-4", "-3", "-2", "-1", "0 Neutral", "1", "2", "3", "4", "5 strongly agree", "I don't know")
 
temp$Impact <- factor(temp$Impact, levels = levs, labels = levs, ordered = TRUE)
 
  
ggplot(temp, aes(x = Impact, fill = Country)) + geom_histogram(position = "dodge") + facet_wrap(~ Changing.factor)+
+
if(usesurvey) {
  theme_gray(base_size = 24) + theme(axis.text.x=element_text(angle=90,hjust=1,vjust=0.4))
+
  oprint(summary(amount, marginals=c("Gender", "Country", "Fish","Ages")))
 +
 
 +
  print(ggplot(amount@output, aes(x=amountResult+0.1, colour=Country))+stat_ecdf()+scale_x_log10()+facet_wrap(~ Fish)+
 +
    labs(x="Fish consumption (g /d)", y="Cumulative frequency")+theme_gray(base_size=24))
 +
  print(ggplot(amount@output, aes(x=amountResult+0.1, colour=Ages))+stat_ecdf()+scale_x_log10()+facet_grid(Country ~ Fish)+
 +
    labs(x="Fish consumption (g /d)", y="Cumulative frequency")+theme_gray(base_size=24))
 +
  print(ggplot(amount@output, aes(x=amountResult+0.1, colour=Gender))+stat_ecdf()+scale_x_log10()+facet_grid(Country ~ Fish)+
 +
    labs(x="Fish consumption (g /d)", y="Cumulative frequency")+theme_gray(base_size=24))
 +
 
 +
  print(ggplot(often@output, aes(x=oftenResult+0.1, colour=Country))+stat_ecdf()+scale_x_log10()+facet_wrap(~ Fish))
 +
  print(ggplot(oftenside@output, aes(x=oftensideResult+0.1, colour=Country))+stat_ecdf()+scale_x_log10()+facet_wrap(~ Fish))
 +
  print(ggplot(much@output, aes(x=muchResult+0.1, colour=Country))+stat_ecdf()+scale_x_log10()+facet_wrap(~ Fish))
 +
  print(ggplot(muchside@output, aes(x=muchsideResult+0.1, colour=Country))+stat_ecdf()+scale_x_log10()+facet_wrap(~ Fish))
 +
 
 +
} else {
 +
  oprint(summary(amount, marginals=c("Fish")))
 +
 
 +
  print(ggplot(amount@output, aes(x=amountResult+0.1, colour=Fish))+stat_ecdf()+scale_x_log10()+
 +
    labs(x="Fish consumption (g /d)", y="Cumulative frequency")+theme_gray(base_size=24))
 +
 
 +
  print(ggplot(often@output, aes(x=oftenResult+0.1, colour=Fish))+stat_ecdf()+scale_x_log10())
 +
  print(ggplot(oftenside@output, aes(x=oftensideResult+0.1, colour=Fish))+stat_ecdf()+scale_x_log10())
 +
  print(ggplot(much@output, aes(x=muchResult+0.1, colour=Fish))+stat_ecdf()+scale_x_log10())
 +
  print(ggplot(muchside@output, aes(x=muchsideResult+0.1, colour=Fish))+stat_ecdf()+scale_x_log10())
 +
}
 +
</rcode>
  
surveytemp <- subset(survey, survey[[31]] == "Yes")
+
== Rationale ==
  
temp <- melt(surveytemp, measure.vars = 38:43, variable.name = "Variable", value.name = "Value")
+
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 [https://docs.google.com/document/d/1IHyQzzdleM7IVY3PaoVImjxKXVWla6ahL62YuXjKe24 Google drive]. The actual data can be found from the link below (see Data).
ggplot(temp, aes(x = Value, fill = Country)) + geom_histogram(position = "dodge") + facet_wrap(~ Variable)+
 
  theme_gray(base_size = 24) + labs(title = "Baltic salmon sources")
 
  
temp <- melt(surveytemp, measure.vars = 50:59, variable.name = "Variable", value.name = "Value")
+
=== Data ===
ggplot(temp, aes(x = Value, fill = Country)) + geom_histogram(position = "dodge") + facet_wrap(~ Variable)+
 
  theme_gray(base_size = 24) + labs(title = "Reasons to eat Baltic salmon")
 
  
temp <- melt(surveytemp, measure.vars = 73:82, variable.name = "Variable", value.name = "Value")
+
==== Questionnaire ====
ggplot(temp, aes(x = Value, fill = Country)) + geom_histogram(position = "dodge") + facet_wrap(~ Variable)+
 
  theme_gray(base_size = 24) + theme(axis.text.x=element_text(angle=90,hjust=1,vjust=0.4)) + labs(title = "Baltic salmon actions")
 
  
surveytemp <- subset(survey, survey[[31]] == "No")
+
Original datafile [[File:Goherr_fish_consumption.csv]].
  
temp <- melt(surveytemp, measure.vars = 62:70, variable.name = "Variable", value.name = "Value")
+
{{hidden|
ggplot(temp, aes(x = Value, fill = Country)) + geom_histogram(position = "dodge") + facet_wrap(~ Variable)+
+
<t2b name="Questions in the Goherr questionnaire" index="Index,Full question" obs="Question" unit="-">
  theme_gray(base_size = 24) + labs(title = "Reasons not to eat Baltic salmon")
+
V1|Country|Country
 +
V2|1. What is the postal code of your residence?|Postal code
 +
V3|2. What is your gender?|Gender
 +
V4|2. How old are you?|Age
 +
V5|3. What is the level of your highest education?|Education
 +
V6|4. How would you rate the purchasing power of your household?|Purchasing power
 +
V7|5. Which of the following food supplements (as a separate product or as a part of some multicompound) do you eat often at least part of the year?:Fatty acids (Omega 3, DHA, EPA etc.)|Omega3
 +
V8|5. Which of the following food supplements (as a separate product or as a part of some multicompound) do you eat often at least part of the year?:D vitamin|Vitamin D
 +
V9|5. Which of the following food supplements (as a separate product or as a part of some multicompound) do you eat often at least part of the year?:Other vitamins|Other vitamins
 +
V10|5. Which of the following food supplements (as a separate product or as a part of some multicompound) do you eat often at least part of the year?:None of the above|No vitamins
 +
V11|5. Which of the following food supplements (as a separate product or as a part of some multicompound) do you eat often at least part of the year?:Don't Know|Unknown vitamins
 +
V12|6. Does someone in your household fish?:No|No fishing
 +
V13|6. Does someone in your household fish?:Yes, for recreational purposes|Recreational
 +
V14|6. Does someone in your household fish?:Yes, for household use|Household use
 +
V15|6. Does someone in your household fish?:Yes, as a professional fisherman|Professional fishing
 +
V16|7. Do you eat fish?|Eat fish
 +
V17|8. Why don't you eat fish?:Allergy|Allergy
 +
V18|8. Why don't you eat fish?:I don't like the taste|Bad taste
 +
V19|8. Why don't you eat fish?:I don't like fish bones|Bones
 +
V20|8. Why don't you eat fish?:Difficult to cook|Cooking difficult
 +
V21|8. Why don't you eat fish?Health risks|Health risks fish
 +
V22|8. Why don't you eat fish?:I'm not used to|Not used to
 +
V23|8. Why don't you eat fish?:I'm concerned about the sustainability of fish stocks|Sustainability fish
 +
V24|8. Why don't you eat fish?:It is ethically wrong to eat animals|Ethically wrong
 +
V25|8. Why don't you eat fish?:I'm a vegetarian|Vegetarian
 +
V26|8.  Why don't you eat fish?:Don't Know|Why not fish unknown
 +
V27|8. Why don't you eat fish?:Other|Why not fish other
 +
V28|8. Why don't you eat fish?:Other open|Why not fish open
 +
V29|9. How often do you eat fish?|How often fish
 +
V30|10. Do you eat salmon or trout at least sometimes?|Eat salmon
 +
V31|11. Which of the following salmonids do you eat at least sometimes?:Wild Baltic salmon|Baltic salmon
 +
V32|11. Which of the following salmonids do you eat at least sometimes?:Wild Atlantic salmon|Atlantic salmon
 +
V33|11. Which of the following salmonids do you eat at least sometimes?:Norwegian cultured salmon|Norwegian salmon
 +
V34|11. Which of the following salmonids do you eat at least sometimes?:Rainbow trout|Rainbow trout
 +
V35|11. Which of the following salmonids do you eat at least sometimes?:I never know which salmon I eat|Unknown salmon
 +
V36|11. Which of the following salmonids do you eat at least sometimes?:Some other salmon, what?|Other salmon
 +
V37|11. Which of the following salmonids do you eat at least sometimes?:Other open|Salmon open
 +
V38|12. Where do you usually get the wild Baltic salmon that you eat?:Someone in our hosehold catches it|Own catch BS
 +
V39|12. Where do you usually get the wild Baltic salmon that you eat?:Buy from a grocery store|Grocery store BS
 +
V40|12. Where do you usually get the wild Baltic salmon that you eat?:Buy from a market place/fishmonger or similar|Market place BS
 +
V41|12. Where do you usually get the wild Baltic salmon that you eat?:Eat in a restaurant/cafe/canteen or similar|Restaurant BS
 +
V42|12. Where do you usually get the wild Baltic salmon that you eat?:Directly from a fisher|Fisher BS
 +
V43|12. Where do you usually get the wild Baltic salmon that you eat?:From a relative, friend, or similar|Friend BS
 +
V44|12. Where do you usually get the wild Baltic salmon that you eat?:Other|Where BS other
 +
V45|12. Where do you usually get the wild Baltic salmon that you eat?:Other open|Where BS open
 +
V46|13. How often do you on average eat wild Baltic salmon as an ingredient in a dish (i.e. as part of a soup, gravy, sushi, casserole etc.)?|How often BS
 +
V47|14. How much on average do you eat of a dish with wild Baltic salmon in it? Think of a medium sized lunch plate and the amount of the whole dish, not just the salmon.|How much BS
 +
V48|15. How often do you on average eat wild Baltic salmon as a side dish (i.e as a separate product such as fish balls, stake, fillets, graved, canned etc.)?|How often side BS
 +
V49|16. What is the average amount of wild Baltic salmon as a side dish? Think of a medium sized lunch plate.|How much side BS
 +
V50|17. Select up to three most important reasons for you to eat wild Baltic salmon?:It tastes good|Tastes good BS
 +
V51|17. Select up to three most important reasons for you to eat wild Baltic salmon?:I caught it|Self caught BS
 +
V52|17. Select up to three most important reasons for you to eat wild Baltic salmon?:It's easy to cook|Easy to cook BS
 +
V53|17. Select up to three most important reasons for you to eat wild Baltic salmon?:It's quick to cook|Quick to cook BS
 +
V54|17. Select up to three most important reasons for you to eat wild Baltic salmon?:It's readily available|Readily available BS
 +
V55|17. Select up to three most important reasons for you to eat wild Baltic salmon?:It's healthy|Healthy BS
 +
V56|17. Select up to three most important reasons for you to eat wild Baltic salmon?:It's inexpensive|Inexpensive BS
 +
V57|17. Select up to three most important reasons for you to eat wild Baltic salmon?:My family likes it|Family likes it BS
 +
V58|17. Select up to three most important reasons for you to eat wild Baltic salmon?:It's environmentally/climate friendly choice|Environmental BS
 +
V59|17. Select up to three most important reasons for you to eat wild Baltic salmon?:It's a traditional dish|Traditional BS
 +
V60|17. Select up to three most important reasons for you to eat wild Baltic salmon?:Some other reasons, what?|Why BS other
 +
V61|17. Select up to three most important reasons for you to eat wild Baltic salmon?:Other open|Why BS open
 +
V62|18. You answered in the previous question that you don't eat wild Baltic salmon. Select up to three most important reasons for why not eating it.:I don't like the taste|Bad taste BS
 +
V63|18. You answered in the previous question that you don't eat wild Baltic salmon. Select up to three most important reasons for why not eating it.:I am not used to eating it / not offered at home|Not used to BS
 +
V64|18. You answered in the previous question that you don't eat wild Baltic salmon. Select up to three most important reasons for why not eating it.:I don't know how to cook it|Cannot cook BS
 +
V65|18. You answered in the previous question that you don't eat wild Baltic salmon. Select up to three most important reasons for why not eating it.:It is not easily available|Not available BS
 +
V66|18. You answered in the previous question that you don't eat wild Baltic salmon. Select up to three most important reasons for why not eating it.:I'm worried about the possible health risks caused by the harmful chemicals in it|Health risks BS
 +
V67|18. You answered in the previous question that you don't eat wild Baltic salmon. Select up to three most important reasons for why not eating it.:I doubt the quality/freshness of the products|Quality issues BS
 +
V68|18. You answered in the previous question that you don't eat wild Baltic salmon. Select up to three most important reasons for why not eating it.:I'm worried about the sustainability of the stocks|Sustainability BS
 +
V69|18. You answered in the previous question that you don't eat wild Baltic salmon. Select up to three most important reasons for why not eating it.:It doesn't belong to traditional dishes of my home area|Not traditional BS
 +
V70|18. You answered in the previous question that you don't eat wild Baltic salmon. Select up to three most important reasons for why not eating it.:It is too expensive|Expensive BS
 +
V71|18. You answered in the previous question that you don't eat wild Baltic salmon. Select up to three most important reasons for why not eating it.:Some other reason, what?|Why not BS other
 +
V72|18. You answered in the previous question that you don't eat wild Baltic salmon. Select up to three most important reasons for why not eating it.:Other open|Why not BS open
 +
V73|19. How would the following factors influence on your consumption of wild Baltic salmon compared to your current use? Select one for each option:Lower price|Lower price BS
 +
V74|19. How would the following factors influence on your consumption of wild Baltic salmon compared to your current use? Select one for each option:Higher price|Higher price BS
 +
V75|19. How would the following factors influence on your consumption of wild Baltic salmon compared to your current use? Select one for each option:Better availability|Better availability BS
 +
V76|19. How would the following factors influence on your consumption of wild Baltic salmon compared to your current use? Select one for each option:Availability of wider variety of ready meals / refined products|Ready meals BS
 +
V77|19. How would the following factors influence on your consumption of wild Baltic salmon compared to your current use? Select one for each option:Cooking suggestions and recipes provided within the store or in the package.|Recipes BS
 +
V78|19. How would the following factors influence on your consumption of wild Baltic salmon compared to your current use? Select one for each option:Better information (e.g. package markings or in the store) on the catch date, area, fisher and/or the refiner|Package markings BS
 +
V79|19. How would the following factors influence on your consumption of wild Baltic salmon compared to your current use? Select one for each option:Improvement of the stocks (eco-labelling)|Eco labelling BS
 +
V80|19. How would the following factors influence on your consumption of wild Baltic salmon compared to your current use? Select one for each option:Lower level of harmful chemicals in the fish|Less chemicals BS
 +
V81|19. How would the following factors influence on your consumption of wild Baltic salmon compared to your current use? Select one for each option:National food safety authorities publish a recommendation to eat it|Recommended BS
 +
V82|19. How would the following factors influence on your consumption of wild Baltic salmon compared to your current use? Select one for each option:National food safety authorities publish a recommendation to limit eating it|Not recommended BS
 +
V83|19. How would the following factors influence on your consumption of wild Baltic salmon compared to your current use? Select one for each option:Some other reason, what?|Change BS other
 +
V84|19. How would the following factors influence on your consumption of wild Baltic salmon compared to your current use? Select one for each option:Other open|Change BS open
 +
V85|20. Do you eat any herring (Baltic or other) at least sometimes?|Eat herring
 +
V86|21. Do you eat Baltic herring? This means herring caught from Baltic sea, not from Atlantic ocean|Eat BH
 +
V87|22. Where do you usually get the wild Baltic herring that you eat?:Someone in our hosehold catches it|Own catch BH
 +
V88|22. Where do you usually get the wild Baltic herring that you eat?:Buy from a grocery store|Grocery store BH
 +
V89|22. Where do you usually get the wild Baltic herring that you eat?:Buy from a market place/fishmonger or similar|Market place BH
 +
V90|22. Where do you usually get the wild Baltic herring that you eat?:Eat in a restaurant/cafe/canteen or similar|Restaurant BH
 +
V91|22. Where do you usually get the wild Baltic herring that you eat?:Directly from a fisher|Fisher BH
 +
V92|22. Where do you usually get the wild Baltic herring that you eat?:From a relative, friend, or similar|Friend BH
 +
V93|22. Where do you usually get the wild Baltic herring that you eat?:Other|Where BH other
 +
V94|22. Where do you usually get the wild Baltic herring that you eat?:Other open|Where BH open
 +
V95|23. How often do you on average eat Baltic herring as ingredient of a dish? (i.e as part of a dish such as in a casserole or some other food including Baltic herring)?|How often BH
 +
V96|24. How much on average do you eat of a dish with Baltic herring in it? Think of a medium sized lunch plate and the amount of the whole dish, not just the amount of Baltic herring|How much BH
 +
V97|25. How often do you on average eat whole Baltic herrings or fillets as a side dish (fried, smoked, rolls, pickled, salted or otherwise prepared)?|How often side BH
 +
V98|26. How much on average of Baltic herring as a side dish (think of a regular sized lunch plate)?|How much side BH
 +
V99|27. Select up to three most important reasons for you to eat Baltic herring?:It tastes good|Tastes good BH
 +
V100|27. Select up to three most important reasons for you to eat Baltic herring?:I caught it|Self caught BH
 +
V101|27. Select up to three most important reasons for you to eat Baltic herring?:It's easy to cook|Easy to cook BH
 +
V102|27. Select up to three most important reasons for you to eat Baltic herring?:It's quick to cook|Quick to cook BH
 +
V103|27. Select up to three most important reasons for you to eat Baltic herring?:It's readily available|Readily available BH
 +
V104|27. Select up to three most important reasons for you to eat Baltic herring?:It's healthy|Healthy BH
 +
V105|27. Select up to three most important reasons for you to eat Baltic herring?:It's inexpensive|Inexpensive BH
 +
V106|27. Select up to three most important reasons for you to eat Baltic herring?:My family likes it|Family likes it BH
 +
V107|27. Select up to three most important reasons for you to eat Baltic herring?:It's environmentally/climate friendly choice|Environmental BH
 +
V108|27. Select up to three most important reasons for you to eat Baltic herring?:It's a traditional dish|Traditional BH
 +
V109|27. Select up to three most important reasons for you to eat Baltic herring?:Some other reasons, what?|Why BH other
 +
V110|27. Select up to three most important reasons for you to eat Baltic herring?:Other open|Why BH open
 +
V111|28. You answered in the previous question that you don't eat Baltic herring. Select up to three most important reasons for why not eating it.:I don't like the taste and/or smell of it|Bad taste BH
 +
V112|28. You answered in the previous question that you don't eat Baltic herring. Select up to three most important reasons for why not eating it.:I am not used to eating it / not offered at home|Not used to BH
 +
V113|28. You answered in the previous question that you don't eat Baltic herring. Select up to three most important reasons for why not eating it.:I don't know how to cook it|Cannot cook BH
 +
V114|28. You answered in the previous question that you don't eat Baltic herring. Select up to three most important reasons for why not eating it.:It is difficult to cook|Difficult to cook BH
 +
V115|28. You answered in the previous question that you don't eat Baltic herring. Select up to three most important reasons for why not eating it.:It is not easily available|Not available BH
 +
V116|28. You answered in the previous question that you don't eat Baltic herring. Select up to three most important reasons for why not eating it.:I'm worried about the possible risks caused by the harmful chemicals in it|Health risks BH
 +
V117|28. You answered in the previous question that you don't eat Baltic herring. Select up to three most important reasons for why not eating it.:It is more suitable for animal feed than human food|Better for feed BH
 +
V118|28. You answered in the previous question that you don't eat Baltic herring. Select up to three most important reasons for why not eating it.:I doubt the quality/freshness of the products|Quality issues BH
 +
V119|28. You answered in the previous question that you don't eat Baltic herring. Select up to three most important reasons for why not eating it.:I'm worried about the sustainability of the stocks|Sustainability BH
 +
V120|28. You answered in the previous question that you don't eat Baltic herring. Select up to three most important reasons for why not eating it.:It doesn't belong to traditional dishes of my home area|Not traditional BH
 +
V121|28. You answered in the previous question that you don't eat Baltic herring. Select up to three most important reasons for why not eating it.:Some other reason, what?|Why not BH other
 +
V122|28. You answered in the previous question that you don't eat Baltic herring. Select up to three most important reasons for why not eating it.:Other open|Why not BH open
 +
V123|29. How would the following factors influence your consumption of Baltic herring compared to your current use? Select one option for each row.:Lower price|Lower price BH
 +
V124|29. How would the following factors influence your consumption of Baltic herring compared to your current use? Select one option for each row.:Higher price|Higher price BH
 +
V125|29. How would the following factors influence your consumption of Baltic herring compared to your current use? Select one option for each row.:Better availability|Better availability BH
 +
V126|29. How would the following factors influence your consumption of Baltic herring compared to your current use? Select one option for each row.:Availability of wider variety of ready meals / processed products|Ready meals BH
 +
V127|29. How would the following factors influence your consumption of Baltic herring compared to your current use? Select one option for each row.:Cooking suggestions and recipes provided in the store or in the package.|Recipes BH
 +
V128|29. How would the following factors influence your consumption of Baltic herring compared to your current use? Select one option for each row.:Better information (e.g. package markings or in the store) on the catch date, area, fisher and/or processing company.|Package markings BH
 +
V129|29. How would the following factors influence your consumption of Baltic herring compared to your current use? Select one option for each row.:Improved stocks (eco-labelling)|Eco labelling BH
 +
V130|29. How would the following factors influence your consumption of Baltic herring compared to your current use? Select one option for each row.:Lower level of harmful chemicals in the fish|Less chemicals BH
 +
V131|29. How would the following factors influence your consumption of Baltic herring compared to your current use? Select one option for each row.:National food safety authorities publish a recommendation to eat it|Recommended BH
 +
V132|29. How would the following factors influence your consumption of Baltic herring compared to your current use? Select one option for each row.:National food safety authorities publish a recommendation to limit eating it|Not recommended BH
 +
V133|29. How would the following factors influence your consumption of Baltic herring compared to your current use? Select one option for each row.:Some other reason, what?|Change BH other
 +
V134|29. How would the following factors influence your consumption of Baltic herring compared to your current use? Select one option for each row.:Other open|Change BH open
 +
V135|30. Are you familiar with the possible eating recommendations of Baltic herring and/or wild Baltic salmon in your country?|Recommendation awareness
 +
V136|31. How strongly do you agree or disagree with the following statements on Baltic salmon? Please indicate your position by selecting a number from -5 (strongly disagree) to 5 (strongly agree).:It contributes to the economic wellbeing of the society|Economic wellbeing BS
 +
V137|31. How strongly do you agree or disagree with the following statements on Baltic salmon? Please indicate your position by selecting a number from -5 (strongly disagree) to 5 (strongly agree).:It is a natural resource for humans to utilize|Natural resource BS
 +
V138|31. How strongly do you agree or disagree with the following statements on Baltic salmon? Please indicate your position by selecting a number from -5 (strongly disagree) to 5 (strongly agree).:It belongs to all Baltic Sea citizens equally|Belongs to all BS
 +
V139|31. How strongly do you agree or disagree with the following statements on Baltic salmon? Please indicate your position by selecting a number from -5 (strongly disagree) to 5 (strongly agree).:It involves long traditions related to fishing and fish eating|Long traditions BS
 +
V140|31. How strongly do you agree or disagree with the following statements on Baltic salmon? Please indicate your position by selecting a number from -5 (strongly disagree) to 5 (strongly agree).:It inspires to search experiences from nature, cultural sites, fish markets or from different dishes|Inspiring experiences BS
 +
V141|31. How strongly do you agree or disagree with the following statements on Baltic salmon? Please indicate your position by selecting a number from -5 (strongly disagree) to 5 (strongly agree).:It is among the most renowned fish species of the Baltic Sea|Renowned species BS
 +
V142|31. How strongly do you agree or disagree with the following statements on Baltic salmon? Please indicate your position by selecting a number from -5 (strongly disagree) to 5 (strongly agree).:It is part of the Baltic Sea ecosystem|Part of ecosystem BS
 +
V143|31. How strongly do you agree or disagree with the following statements on Baltic salmon? Please indicate your position by selecting a number from -5 (strongly disagree) to 5 (strongly agree).:I have an emotional bond to it|Emotional bond BS
 +
V144|31. How strongly do you agree or disagree with the following statements on Baltic salmon? Please indicate your position by selecting a number from -5 (strongly disagree) to 5 (strongly agree).:It helps me to achieve my personal aims|Personal aims
 +
V145|32. How strongly do you agree or disagree with the following statements on Baltic herring? Please indicate your position by selecting a number from -5 (strongly disagree) to 5 (strongly agree).:It contributes to the economic wellbeing of the society|Economic wellbeing BH
 +
V146|32. How strongly do you agree or disagree with the following statements on Baltic herring? Please indicate your position by selecting a number from -5 (strongly disagree) to 5 (strongly agree).:It is a natural resource for humans to utilize|Natural resource BH
 +
V147|32. How strongly do you agree or disagree with the following statements on Baltic herring? Please indicate your position by selecting a number from -5 (strongly disagree) to 5 (strongly agree).:It belongs to all Baltic Sea citizens equally|Belongs to all BH
 +
V148|32. How strongly do you agree or disagree with the following statements on Baltic herring? Please indicate your position by selecting a number from -5 (strongly disagree) to 5 (strongly agree).:It involves long traditions related to fishing and fish eating|Long traditions BH
 +
V149|32. How strongly do you agree or disagree with the following statements on Baltic herring? Please indicate your position by selecting a number from -5 (strongly disagree) to 5 (strongly agree).:It inspires to search experiences from nature, cultural sites, fish markets or from different dishes|Inspiring experiences BH
 +
V150|32. How strongly do you agree or disagree with the following statements on Baltic herring? Please indicate your position by selecting a number from -5 (strongly disagree) to 5 (strongly agree).:It is among the most renowned fish species of the Baltic Sea|Renowned species BH
 +
V151|32. How strongly do you agree or disagree with the following statements on Baltic herring? Please indicate your position by selecting a number from -5 (strongly disagree) to 5 (strongly agree).:It is part of the Baltic Sea ecosystem|Part of ecosystem BH
 +
V152|32. How strongly do you agree or disagree with the following statements on Baltic herring? Please indicate your position by selecting a number from -5 (strongly disagree) to 5 (strongly agree).:I have an emotional bond to it|Emotional bond BH
 +
V153|32. How strongly do you agree or disagree with the following statements on Baltic herring? Please indicate your position by selecting a number from -5 (strongly disagree) to 5 (strongly agree).:It helps me to achieve my personal aims|Personal aims BH
 +
V154|Weighting|Weighting
 +
V155|How old are you? Age category FI|Age category FI
 +
V156|2. How old are you? Age category SWE, DK, EST|Age category other
 +
V157|Row number of respondent|Row
 +
V158|Age category "18-45" or ">45"|Ages
 +
</t2b>
 +
}}
  
 +
==== Assumptions ====
  
surveytemp <- subset(survey, survey[[86]] == "Yes")
+
The following assumptions are used:
 +
<t2b name="Assumptions for calculations" index="Variable,Value,Unit" obs="Result" desc="Description" unit="-">
 +
freq|1|times /a|0|Never
 +
freq|2|times /a|0.5 - 0.9|less than once a year
 +
freq|3|times /a|2 - 5|A few times a year
 +
freq|4|times /a|12 - 36|1 - 3 times per month
 +
freq|5|times /a|52|once a week
 +
freq|6|times /a|104 - 208|2 - 4 times per week
 +
freq|7|times /a|260 - 364|5 or more times per week
 +
amdish|1|g /serving|20 - 70|1/6 plate or below (50 grams)
 +
amdish|2|g /serving|70 - 130|1/3 plate (100 grams)
 +
amdish|3|g /serving|120 - 180|1/2 plate (150 grams)
 +
amdish|4|g /serving|170 - 230|2/3 plate (200 grams)
 +
amdish|5|g /serving|220 - 280|5/6 plate (250 grams)
 +
amdish|6|g /serving|270 - 400|full plate (300 grams)
 +
amdish|7|g /serving|400 - 550|overly full plate (500 grams)
 +
ingredient||fraction|0.1 - 0.3|Fraction of fish in the dish
 +
amside|1|g /serving|20 - 70|1/6 plate or below (50 grams)
 +
amside|2|g /serving|70 - 130|1/4 plate (100 grams)
 +
amside|3|g /serving|120 - 180|1/2 plate (150 grams)
 +
amside|4|g /serving|170 - 230|2/3 plate (200 grams)
 +
amside|5|g /serving|220 - 280|5/6 plate (250 grams)
 +
</t2b>
  
temp <- melt(surveytemp, measure.vars = 87:92, variable.name = "Variable", value.name = "Value")
+
==== Preprocessing ====
ggplot(temp, aes(x = Value, fill = Country)) + geom_histogram(position = "dodge") + facet_wrap(~ Variable)+
 
  theme_gray(base_size = 24) + labs(title = "Baltic herring sources")
 
  
temp <- melt(surveytemp, measure.vars = 99:108, variable.name = "Variable", value.name = "Value")
+
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.
ggplot(temp, aes(x = Value, fill = Country)) + geom_histogram(position = "dodge") + facet_wrap(~ Variable)+
+
* Model run 13.4.2017 [http://en.opasnet.org/en-opwiki/index.php?title=Special:RTools&id=1QsyOMpBHrvY0H2o]
  theme_gray(base_size = 24) + labs(title = "Reasons to eat Baltic herring")
+
* Model run 20.4.2017 [http://en.opasnet.org/en-opwiki/index.php?title=Special:RTools&id=JuLynAzoCuvu0U3g] (contains surv and helping vectors)
 +
* Model run 21.4.2017 [http://en.opasnet.org/en-opwiki/index.php?title=Special:RTools&id=D9zGDNIqaUV26nP6] surv contains Eatfish, Eatherr and Eatsalm as columns.
  
temp <- melt(surveytemp, measure.vars = 123:132, variable.name = "Variable", value.name = "Value")
+
<rcode name="preprocess2" label="Preprocess (only for developers)">
ggplot(temp, aes(x = Value, fill = Country)) + geom_histogram(position = "dodge") + facet_wrap(~ Variable)+
+
# This code is Op_en7749/preprocess2 on page [[Goherr: Fish consumption study]]
  theme_gray(base_size = 24) + theme(axis.text.x=element_text(angle=90,hjust=1,vjust=0.4)) + labs(title = "Baltic herring actions")
 
  
surveytemp <- subset(survey, survey[[86]] == "No")
 
 
temp <- melt(surveytemp, measure.vars = 111:120, variable.name = "Variable", value.name = "Value")
 
ggplot(temp, aes(x = Value, fill = Country)) + geom_histogram(position = "dodge") + facet_wrap(~ Variable)+
 
  theme_gray(base_size = 24) + labs(title = "Reasons not to eat Baltic herring")
 
 
</rcode>
 
 
== 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 [https://docs.google.com/document/d/1IHyQzzdleM7IVY3PaoVImjxKXVWla6ahL62YuXjKe24 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.
 
 
<rcode name="preprocess" label="Preprocess (only for developers)">
 
 
library(OpasnetUtils)
 
library(OpasnetUtils)
  
############## Generic functions and objects are defined first.
+
objects.latest("Op_en6007", code_name = "answer") # [[OpasnetUtils/Drafts]] webropol.convert, merge.questions
 
 
### webropol.convert converts a csv file from Webropol into a useful data.frame.
 
 
 
webropol.convert <- function(
 
  data, # Data.frame created from a Webropol csv file. The first row should contain headings.
 
  rowfact, # Row number where the factor levels start (in practice, last row + 3)
 
  textmark = "Other open" # The text that is shown in the heading if there is an open sub-question.
 
) {
 
  out <- dropall(data[2:(rowfact - 3) , ])
 
  subquestion <- t(data[1 , ])
 
  subquestion <- gsub("\xa0", " ", subquestion)
 
  subquestion <- gsub("\xb4", " ", subquestion)
 
  subquestion <- gsub("\n", " ", subquestion)
 
  #  subquestion <- gsub("\\(", " ", subquestion)
 
  #  subquestion <- gsub("\\)", " ", subquestion)
 
  textfield <- regexpr(textmark, subquestion) != -1
 
  subquestion <- strsplit(subquestion, ":") # Divide the heading into a main question and a subquestion.
 
  subqtest <- 0 # The previous question name.
 
  for(i in 1:ncol(out)) {
 
    #print(i)
 
    if(subquestion[[i]][1] != subqtest) { # If part of previous question, use previous fact.
 
      fact <- as.character(data[rowfact:nrow(data) , i]) # Create factor levels from the end of Webropol file.
 
      fact <- fact[fact != ""] # Remove empty rows
 
      fact <- gsub("\xa0", " ", fact)
 
      fact <- gsub("\xb4", " ", fact)
 
      fact <- gsub("\n", " ", fact)
 
      fact <- strsplit(fact, " = ") # Separate value (level) and interpretation (label)
 
    }
 
    if(length(fact) != 0 & !textfield[i]) { # Do this only if the column is not a text type column.
 
      out[[i]] <- factor(
 
        out[[i]],
 
        levels = unlist(lapply(fact, function(x) x[1])),
 
        labels = unlist(lapply(fact, function(x) x[2])),
 
        ordered = TRUE
 
      )
 
    }
 
    subqtest <- subquestion[[i]][1]
 
  }
 
  return(out)
 
}
 
 
 
# merge.questions takes a multiple checkbox question and merges that into a single factor.
 
# First levels in levs have priority over others, if several levels apply to a row.
 
 
 
merge.questions <- function(
 
  dat, # data.frame with questionnaire data
 
  cols, # list of vectors of column names or numbers to be merged into one level in the factor
 
  levs, # vector (with the same length as cols) of levels of factors into which questions are merged.
 
  name # text string for the name of the new factor column in the data.
 
) {
 
  for(i in length(cols):1) {
 
    temp <- FALSE
 
    for(j in rev(cols[[i]])) {
 
      temp <- temp | !is.na(dat[[j]])
 
    }
 
    dat[[name]][temp] <- levs[i]
 
  }
 
  dat[[name]] <- factor(dat[[name]], levels = levs, ordered = TRUE)
 
  return(dat)
 
}
 
  
 
############# Data preprocessing
 
############# Data preprocessing
Line 154: Line 278:
 
#Survey original file: N:/Ymal/Projects/Goherr/WP5/Goherr_fish_consumption.csv
 
#Survey original file: N:/Ymal/Projects/Goherr/WP5/Goherr_fish_consumption.csv
  
survey <- opasnet.csv("5/57/Goherr_fish_consumption.csv", sep = ";", fill = TRUE, quote = "\"")
+
survey <- opasnet.csv(
surcol <- t(survey[1,])
+
  "5/57/Goherr_fish_consumption.csv",
 +
  wiki = "opasnet_en", sep = ";", fill = TRUE, quote = "\""
 +
)
 +
#survey <- re#ad.csv(file = "N:/Ymal/Projects/Goherr/WP5/Goherr_fish_consumption.csv",
 +
#                  header=FALSE, sep=";", fill = TRUE, quote="\"")
  
survey <- webropol.convert(survey, 2121, textmark = ":Other open") # Data file is converted to data.frame using levels at row 1269.
+
# Data file is converted to data.frame using levels at row 2121.
 +
survey <- webropol.convert(survey, 2121, textmark = ":Other open")  
  
 
# Take the relevant columnames from the table on the page.
 
# Take the relevant columnames from the table on the page.
colframe <- opbase.data("Op_en7749", subset = "Questions in the Goherr questionnaire")
+
colnames(survey) <- gsub(" ",  ".",
colnames(survey) <- colframe$Result
+
  opbase.data("Op_en7749", subset = "Questions in the Goherr questionnaire")$Result[1:ncol(survey)]
 +
)
 +
survey$Row <- 1:nrow(survey)
 +
survey$Weighting <- as.double(gsub(",",".", survey$Weighting))
 +
survey$Ages <- factor(
 +
  ifelse(as.numeric(as.character(survey$Age)) < 46, "18-45",">45"),
 +
  levels = c("18-45", ">45"), ordered = TRUE
 +
)
  
survey$Row <- 1:nrow(survey)
+
# webropol.convert should put these in the right order but doesn't. So do it manually.
survey$Weighting <- as.double(levels(survey$Weighting))[survey$Weighting]
 
survey$Ages <- ifelse(as.numeric(as.character(survey$Age)) < 46, "18-45",">45")
 
  
 
freqlist <- c(
 
freqlist <- c(
Line 184: Line 318:
 
   "full plate (300 grams)",
 
   "full plate (300 grams)",
 
   "overly full plate (500 grams)"
 
   "overly full plate (500 grams)"
#  "Not able to estimate"
+
  #  "Not able to estimate"
 
)
 
)
  
Line 193: Line 327:
 
   "2/3 plate (200 grams)",
 
   "2/3 plate (200 grams)",
 
   "5/6 plate (250 grams)"
 
   "5/6 plate (250 grams)"
#  "Not able to estimate"
+
  #  "Not able to estimate"
 
)
 
)
 +
 +
fishamounts <- c(29,46:49,95:98)
 +
colnames(survey)[fishamounts]
 +
#[1] "How.often.fish"    "How.often.BS"      "How.much.BS"      "How.often.side.BS"
 +
#[5] "How.much.side.BS"  "How.often.BH"      "How.much.BH"      "How.often.side.BH"
 +
#[9] "How.much.side.BH"
  
 
ansl <- list(
 
ansl <- list(
   `How often eat fish` = freqlist,
+
   freqlist,
   `How often Baltic salmon` = c("Never", freqlist),
+
   c("Never", freqlist),
   `How much Baltic salmon` = amlist,
+
   amlist,
   `How often side Baltic salmon` = c("Never", freqlist),
+
   c("Never", freqlist),
   `How much side Baltic salmon` = sidel,
+
   sidel,
   `How often Baltic herring` = c("Never", freqlist),
+
   c("Never", freqlist),
   `How much Baltic herring` = amlist,
+
   amlist,
   `How often side Baltic herring` = c("Never", freqlist),
+
   c("Never", freqlist),
   `How much side Baltic herring` = sidel
+
   sidel
 
)
 
)
  
for (i in names(ansl)) {
+
for (i in 1:length(fishamounts)) {
   survey[[i]] <- factor(survey[[i]], levels = ansl[[i]])
+
   survey[[fishamounts[i]]] <- factor(survey[[fishamounts[i]]], levels = ansl[[i]], ordered = TRUE)
 
}
 
}
  
objects.store(survey, surcol)
+
oprint(head(survey))
cat("objects survey, surcol were stored.\n")
+
 
 +
agel <- as.character(unique(survey$Ages))
 +
countryl <- sort(as.character(unique(survey$Country)))
 +
genderl <- sort(as.character(unique(survey$Gender)))
 +
fisl <- c("Salmon", "Herring")
 +
 
 +
# Interesting fish eating questions
 +
surv <- survey[c(1,3,158,16,29,30,31,46:49,86,95:98)]
 +
colnames(surv)
 +
#[1] "Country"                      "Gender"                     
 +
#[3] "Ages"                          "Fish eating"                 
 +
#[5] "How often eat fish"            "Salmon eating"               
 +
#[7] "Baltic salmon"                "How often Baltic salmon"     
 +
#[9] "How much Baltic salmon"        "How often side Baltic salmon"
 +
#[11] "How much side Baltic salmon"  "Eat Baltic herring"         
 +
#[13] "How often Baltic herring"      "How much Baltic herring"     
 +
#[15] "How often side Baltic herring" "How much side Baltic herring"
 +
 
 +
# For estimating distributions, we should
 +
#1 remove people with Fish eating = No (142)
 +
#2 merge Eat Baltic herring = I don't know with No (How often BH = NA always)
 +
#3 merge Baltic salmon = NA with No (because they usually have answered BH questions)
 +
 
 +
oprint(table(is.na(rowSums(sapply(surv[4:16], as.numeric)))))
 +
# BUT: there are so many missing values, that we just model BH and BS separately now.
 +
 
 +
surv <- as.data.frame(lapply(surv, FUN = function(x) as.integer(x))) # Coerce to integers
 +
surv[is.na(surv[[12]]) | surv[[12]] == 3 , 12] <- 1 # Eat Baltic herring: I don't know --> No
 +
 
 +
# Row numbers for respondents that have eaten fish, Baltic salmon, and Baltic herring
 +
surv$Eatfish <- surv[[4]] %in% 2
 +
surv$Eatsalm <- surv[[7]] %in% 2 & !is.na(rowSums(surv[7:11]))
 +
surv$Eatherr <- surv[[12]] %in% 2 & !is.na(rowSums(surv[13:16]))
 +
 
 +
oprint(table(surv[c("Eatsalm", "Eatherr", "Eatfish")], useNA = "ifany"))
  
 +
# Oletetaan, että covarianssimatriisi on vakio kaikille maille ja sukupuolille yms
 +
# mutta keskiarvo on spesifi näille ja kysymykselle.
 +
 +
#qlen <-  c(4,2,2,2,6,2,2,7,7,7,5,2,7,7,7,5) # Number of options in each question of surv
 +
# qlen not needed when dbinom is not used.
 +
 +
agel
 +
countryl
 +
genderl
 +
fisl
 +
 +
objects.store(survey, surv, agel, countryl, genderl, fisl)
 +
cat("Data.frames survey and surv, and vectors agel, countryl, genderl and fisl were stored.\n")
 
</rcode>
 
</rcode>
  
==== Calculations ====
+
=== Analyses ===
  
This code calculates how much (g/day) Baltic herring and salmon are eaten based on the questionnaire data. '''Calculation takes several minutes!'''
+
==== Descriptive statistics ====
  
<rcode label="Calculate amount" name=calculate_amount embed=1 graphics=1 store=1>
+
[[File:Goherr survey correlations.png|thumb|300px|Correlation matrix of all questions in the survey (answers converted to numbers).]]
# This is code Op_en7749/calculate_amount on page [[Goherr: Fish consumption study]]
+
 
 +
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
 +
 
 +
Model runs
 +
* [http://en.opasnet.org/en-opwiki/index.php?title=Special:RTools&id=QaMJZqUX0cPaTfOF Model run 13.3.2017]
 +
* Model run 21.4.2017 [http://en.opasnet.org/en-opwiki/index.php?title=Special:RTools&id=0Lmu6OVAjomgJwAN] old code from Answer merged to this code and debugged
 +
 
 +
<rcode label="Descriptive statistics" graphics=1>
 +
# This is code Op_en7749/ on page [[Goherr: Fish consumption study]]
  
 
library(OpasnetUtils)
 
library(OpasnetUtils)
 
library(ggplot2)
 
library(ggplot2)
 
library(reshape2)
 
library(reshape2)
library(rjags)
+
library(car)
 +
library(vegan)
 +
 
 +
objects.latest("Op_en7749", "preprocess2") # [[Goherr: Fish consumption study]]: survey, surv
  
objects.latest("Op_en7749", "preprocess")
+
############################### From a previous code on Answer
assumptions <- opbase.data("Op_en7749.assumptions_for_calculations")
 
  
for (i in 46:49) {
+
for(i in c(5:6, 16, 29:30, 46:49, 85:86, 95:98, 135)) {
   survey[[i]] <- as.character(survey[[i]])
+
   temp <- survey[!is.na(survey[[i]]),]
 +
  p <- ggplot(temp, aes(x = temp[[i]])) + geom_bar() +
 +
    theme_gray(base_size = 18) + theme(axis.text.x=element_text(angle=90,hjust=1,vjust=0.4)) +
 +
    labs(title = colnames(temp[i])) + xlab("") + facet_wrap(~ Country)
 +
  print(p)
 
}
 
}
  
survey[,46:49][is.na(survey[,46:49])] <- ""
+
temp <- melt(survey, measure.vars = 145:153, variable.name = "Changing.factor", value.name = "Impact")
 +
levs <- c("-5 strongly disagree", "-4", "-3", "-2", "-1", "0 Neutral", "1", "2", "3", "4", "5 strongly agree", "I don't know")
 +
temp$Impact <- factor(temp$Impact, levels = levs, labels = levs, ordered = TRUE)
 +
 
 +
ggplot(temp, aes(x = Impact, fill = Country)) + geom_bar(position = "dodge") + facet_wrap(~ Changing.factor)+
 +
  theme_gray(base_size = 24) + theme(axis.text.x=element_text(angle=90,hjust=1,vjust=0.4))
 +
 
 +
surveytemp <- subset(survey, survey[[31]] == "Yes")
 +
 
 +
temp <- melt(surveytemp, measure.vars = 38:43, variable.name = "Variable", value.name = "Value")
 +
ggplot(temp, aes(x = Value, fill = Country)) + geom_bar(position = "dodge") + facet_wrap(~ Variable)+
 +
  theme_gray(base_size = 24) + labs(title = "Baltic salmon sources")
 +
 
 +
temp <- melt(surveytemp, measure.vars = 50:59, variable.name = "Variable", value.name = "Value")
 +
ggplot(temp, aes(x = Value, fill = Country)) + geom_bar(position = "dodge") + facet_wrap(~ Variable)+
 +
  theme_gray(base_size = 24) + labs(title = "Reasons to eat Baltic salmon")
 +
 
 +
temp <- melt(surveytemp, measure.vars = 73:82, variable.name = "Variable", value.name = "Value")
 +
ggplot(temp, aes(x = Value, fill = Country)) + geom_bar(position = "dodge") + facet_wrap(~ Variable)+
 +
  theme_gray(base_size = 24) + theme(axis.text.x=element_text(angle=90,hjust=1,vjust=0.4)) + labs(title = "Baltic salmon actions")
 +
 
 +
surveytemp <- subset(survey, survey[[31]] == "No")
 +
 
 +
temp <- melt(surveytemp, measure.vars = 62:70, variable.name = "Variable", value.name = "Value")
 +
ggplot(temp, aes(x = Value, fill = Country)) + geom_bar(position = "dodge") + facet_wrap(~ Variable)+
 +
  theme_gray(base_size = 24) + labs(title = "Reasons not to eat Baltic salmon")
 +
 
 +
 
 +
surveytemp <- subset(survey, survey[[86]] == "Yes")
 +
 
 +
temp <- melt(surveytemp, measure.vars = 87:92, variable.name = "Variable", value.name = "Value")
 +
ggplot(temp, aes(x = Value, fill = Country)) + geom_bar(position = "dodge") + facet_wrap(~ Variable)+
 +
  theme_gray(base_size = 24) + labs(title = "Baltic herring sources")
 +
 
 +
temp <- melt(surveytemp, measure.vars = 99:108, variable.name = "Variable", value.name = "Value")
 +
ggplot(temp, aes(x = Value, fill = Country)) + geom_bar(position = "dodge") + facet_wrap(~ Variable)+
 +
  theme_gray(base_size = 24) + labs(title = "Reasons to eat Baltic herring")
 +
 
 +
temp <- melt(surveytemp, measure.vars = 123:132, variable.name = "Variable", value.name = "Value")
 +
ggplot(temp, aes(x = Value, fill = Country)) + geom_bar(position = "dodge") + facet_wrap(~ Variable)+
 +
  theme_gray(base_size = 24) + theme(axis.text.x=element_text(angle=90,hjust=1,vjust=0.4)) + labs(title = "Baltic herring actions")
 +
 
 +
surveytemp <- subset(survey, survey[[86]] == "No")
 +
 
 +
temp <- melt(surveytemp, measure.vars = 111:120, variable.name = "Variable", value.name = "Value")
 +
ggplot(temp, aes(x = Value, fill = Country)) + geom_bar(position = "dodge") + facet_wrap(~ Variable)+
 +
  theme_gray(base_size = 24) + labs(title = "Reasons not to eat Baltic herring")
 +
 
 +
#####################################3
 +
 
 +
temp <- sapply(survey, as.numeric) # Can be done for surv to get a smaller matrix
 +
 
 +
survey_correlations <- (cor(temp, method="spearman", use="pairwise.complete.obs"))
 +
 
 +
temp <- colnames(survey_correlations)
 +
 
 +
melted_correlations <- melt(survey_correlations)
 +
 
 +
melted_correlations$Var1 <- factor(melted_correlations$Var1, levels=temp)
 +
melted_correlations$Var2 <- factor(melted_correlations$Var2, levels=temp)
 +
melted_correlations$value <- ifelse(melted_correlations$value >= 0.99,NA,melted_correlations$value)
 +
 
 +
ggplot(melted_correlations, aes(x = Var1, y = Var2, fill = value, label= round(value, 2)))+
 +
  geom_raster()+
 +
  theme(axis.text.x=element_text(angle=90,hjust=1,vjust=0.4))+
 +
  scale_fill_gradient2(low = "#480610", mid = "#FFFFFF", high = "#06480F", midpoint = 0, space = "Lab", guide = "colourbar")
 +
 
 +
####################### Descriptive statistics
  
for (i in 95:98) {
+
oprint(cor(surv, use = "pairwise.complete.obs"))
  survey[[i]] <- as.character(survey[[i]])
+
# --> Baltic salmon and herring eating are correlated, so they should be estimated together
}
 
  
survey[,95:98][is.na(survey[,95:98])] <- ""
+
oprint(table(surv[c(12,7,4)], useNA = "ifany"))
 +
oprint(table(surv[c(13,12)], useNA = "ifany"))
  
survey$Row <- 1:nrow(survey)
+
############################# Plot original data
survey$Weighting <- as.double(levels(survey$Weighting))[survey$Weighting]
 
survey$Ages <- ifelse(as.numeric(as.character(survey$Age)) < 46, "18-45",">45")
 
short <- survey[c("Country", "Gender", "Row", "Ages")]
 
  
salmon_dishtimes <- Ovariable(  
+
# Eating frequencies of fish and Baltic salmon and herring with random noise, all
  "salmon_dishtimes",
+
pl <- surv[surv$Eatfish,c(5,8,10,13,15)]
   data = data.frame(
+
scatterplotMatrix(
    short,
+
   data.matrix(pl) + runif(nrow(pl)*ncol(pl), -0.5, 0.5)
    Value = survey[[46]],
+
)
    Result = 1
 
  )
 
) #salmon with dish times / year
 
  
salmon_dishamount <- Ovariable(
+
ggplot(data.frame(
   "salmon_dishamount",  
+
   X = rep(1,5), Y = 5:1,
   data = data.frame(
+
   legend = c("All", "Finland", "Sweden", "Denmark", "Estonia")
    short,
+
), aes(x=X, y=Y, label=legend))+
    Value = survey[[47]],
+
   geom_text()+
    Result = 1
+
  labs(title="Fish eating questions with random noise")
   )
 
) #salmon with dish amount per one serving
 
  
salmon_wholetimes <- Ovariable("salmon_wholetimes", data = data.frame(
 
  short,
 
  Value = survey[[48]],
 
  Result = 1
 
)) #salmon as such times / year
 
  
salmon_wholeamount <- Ovariable("salmon_wholeamount", data = data.frame(
+
## Fish eating questions with some random noise, all
  short,
+
pl <- surv[surv$Eatfish,c(5,6,7,12)]
  Value = survey[[49]],
+
scatterplotMatrix(
  Result = 1
+
  data.matrix(pl) + runif(nrow(pl)*ncol(pl), -0.5, 0.5)
)) #salmon as whole amount per one serving
+
)
  
salmon_dishtimesassump <- Ovariable("salmon_dishtimesassump", data = assumptions[assumptions$Variable == "V46" , c("Value", "Result")])
+
## Fish eating questions with some random noise, FI
 +
pl <- surv[surv$Country == 1 & surv$Eatfish,c(5,6,7,12)]
 +
scatterplotMatrix(
 +
  data.matrix(pl) + runif(nrow(pl)*ncol(pl), -0.5, 0.5)
 +
)
  
salmon_dishamountassump <- Ovariable("salmon_dishamountassump", data = assumptions[assumptions$Variable == "V47" , c("Value", "Result")])
+
## Fish eating questions with some random noise, SWE
 +
pl <- surv[surv$Country == 2 & surv$Eatfish,c(5,6,7,12)]
 +
scatterplotMatrix(
 +
  data.matrix(pl) + runif(nrow(pl)*ncol(pl), -0.5, 0.5)
 +
)
  
salmon_ingridient <- Ovariable("salmon_ingridient", data = assumptions[assumptions$Variable == "salmon_ingridient", ]["Result"])
+
## Fish eating questions with some random noise, Dk
 +
pl <- surv[surv$Country == 3 & surv$Eatfish,c(5,6,7,12)]
 +
scatterplotMatrix(
 +
  data.matrix(pl) + runif(nrow(pl)*ncol(pl), -0.5, 0.5)
 +
)
  
salmon_wholetimesassump <- Ovariable("salmon_wholetimesassump", data = assumptions[assumptions$Variable == "V48" , c("Value", "Result")])
+
## Fish eating questions with some random noise, EST
 +
pl <- surv[surv$Country == 4 & surv$Eatfish,c(5,6,7,12)]
 +
scatterplotMatrix(
 +
  data.matrix(pl) + runif(nrow(pl)*ncol(pl), -0.5, 0.5)
 +
)
  
salmon_wholeamountassump <- Ovariable("salmon_wholeamountassump", data = assumptions[assumptions$Variable == "V49" , c("Value", "Result")])
+
## Baltic herring questions with some random noise
 +
pl <- surv[surv$Eatherr,13:16]
 +
scatterplotMatrix(
 +
  data.matrix(pl) + runif(nrow(pl)*ncol(pl), -0.5, 0.5)
 +
)
  
amount <- Ovariable("amount",  
+
## Baltic salmon questions with some random noise
                    dependencies = data.frame(Name = c(
+
pl <- surv[surv$Eatsalm,8:11]
                      "salmon_dishamount",
+
scatterplotMatrix(
                      "salmon_dishamountassump",
+
  data.matrix(pl) + runif(nrow(pl)*ncol(pl), -0.5, 0.5)
                      "salmon_ingridient",
 
                      "salmon_dishtimes",
 
                      "salmon_dishtimesassump",
 
                      "salmon_wholeamount",
 
                      "salmon_wholeamountassump",
 
                      "salmon_wholetimes",
 
                      "salmon_wholetimesassump"
 
                    )),
 
                    formula = function(...) {
 
                     
 
                      out1 <- (salmon_dishamount * salmon_dishamountassump * salmon_ingridient)  
 
                      out1@output$Value <- NULL
 
                      out1 <- ((salmon_dishtimes * salmon_dishtimesassump) * out1) / 365
 
                      out1@output$Value <- NULL
 
                      out2 <- (salmon_wholeamount * salmon_wholeamountassump)
 
                      out2@output$Value <- NULL
 
                      out2 <- ((salmon_wholetimes * salmon_wholetimesassump) * out2) / 365
 
                      out2@output$Value <- NULL
 
                      out <- out1 + out2
 
                     
 
                      # Per vuosi -> per d
 
                     
 
                      #result(out)[result(out) == 0] <- 0.01 # Ei jätetä nollia saantiin
 
                      return(out)
 
                    }
 
 
)
 
)
#amount <- EvalOutput(amount)
 
#### Draw N rows from the questionnaire subset filling the condition (in this case from the Country+Gender-group)
 
  
condition <- unique(survey[c("Country", "Gender")])
+
##################### CORRELATION MATRIX
 +
 
 +
temp <- sapply(survey, as.numeric) # Can be done for surv to get a smaller matrix
 +
 
 +
survey_correlations <- (cor(temp, method="spearman", use="pairwise.complete.obs"))
 +
 
 +
temp <- colnames(survey_correlations)
  
rows <- data.frame()
+
melted_correlations <- melt(survey_correlations)
for(i in 1:nrow(condition)) {
+
 
  temp <- survey[
+
melted_correlations$Var1 <- factor(melted_correlations$Var1, levels=temp)
    survey$Gender == condition$Gender[i] & survey$Country == condition$Country[i] ,  
+
melted_correlations$Var2 <- factor(melted_correlations$Var2, levels=temp)
    c("Gender", "Country", "Weighting")
+
melted_correlations$value <- ifelse(melted_correlations$value >= 0.99,NA,melted_correlations$value)
    ] # Eikö tässä voisi yksinkertaistaa ja käyttää vain rivinumeroa eikä koko tempiä?
+
 
   temp <- temp[sample(1:nrow(temp), get("N", envir = openv), replace = TRUE, prob = temp$Weighting) , ]
+
ggplot(melted_correlations, aes(x = Var1, y = Var2, fill = value, label= round(value, 2)))+
  rows <- rbind(rows, data.frame(
+
  geom_raster()+
    condition[i , ],
+
   theme(axis.text.x=element_text(angle=90,hjust=1,vjust=0.4))+
    Iter = 1:get("N", envir = openv),
+
  scale_fill_gradient2(low = "#480610", mid = "#FFFFFF", high = "#06480F", midpoint = 0, space = "Lab", guide = "colourbar")
    Row = as.character(floor(as.numeric(rownames(temp)))),
+
 
    Result = 1
+
############################### PRINCIPAL COORDINATE ANALYSIS (PCoA)
  ))
+
 
}
+
#tämä osa valmistaa sen datan.
 +
hypocols1 <- c(46:49,95:98)
 +
answ <- sapply(survey[hypocols1], FUN=as.numeric)
 +
answ <- as.matrix(answ[!is.na(rowSums(answ)),])
  
# New version with same functionality
+
pcoa_caps <- capscale(t(answ) ~ 1, distance="euclidean") ##PCoA done
# However, the whole approach is inefficient. With N=1000 only ca 200 iterations per country and sex results from here.
 
# Instead, some probability distributions should be fitted based on the survey.
 
rows <- data.frame()
 
for(i in 1:nrow(condition)) {
 
  temp <- (1:nrow(survey))[survey$Gender == condition$Gender[i] &
 
                            survey$Country == condition$Country[i]]
 
  temp <- sample(temp, openv$N, replace = TRUE, prob = survey$Weighting[temp])
 
  rows <- rbind(rows, data.frame(
 
    Iter = 1:openv$N,
 
    Row = temp
 
  ))
 
}
 
  
 +
## Kuva koko hypoteeseista
  
#rows <- Ovariable(output = rows, marginal = c(TRUE, TRUE, TRUE, TRUE, FALSE))
+
colstr <- c("palevioletred1","royalblue1","seagreen1","violet","khaki2","skyblue", "orange")
  
########## create ovariable for impact assessment model with the drawn individuals
+
#hypo_sizes <- (5 - colMeans(answ))
 +
#leg_sizes <- c(4, 3, 2, 1, 0.01)
  
#row <- rows@output
+
#pdf(file="pcoa_plot.pdf", height=6, width=7.5)
#row$Result <- NULL
+
plot(pcoa_caps, display = c("sp", "wa"), type="n")#, xlim=c(-6,4.5)) ## PCoA biplot, full scale
 +
points(pcoa_caps, display= c("sp"), col="gray40") # adding the people points
 +
points(pcoa_caps, display= c("wa"), pch=19)#, cex=hypo_sizes, col=trait.cols)
 +
text(pcoa_caps, display=c("wa"), srt=25, cex=0.5)
 +
#legend(x=-6, y=3.8, levels(traits), fill=colstr, bty="n", cex=1)
 +
#legend(-6, -2, legend=c("Very likely", "Moderately likely",
 +
#                       "No opinion", "Moderately unlikely", "Very unlikely"),
 +
#      pch=21, pt.cex = leg_sizes, bty="n", cex=1)
 +
#dev.off()
 +
</rcode>
  
salmon_dishamount@data <- merge(salmon_dishamount@data, rows) # One merge is enough to choose the rows wanted
+
==== Bayes model ====
#salmon_dishtimes@data <- merge(salmon_dishtimes@data, row)
 
#salmon_wholeamount@data <- merge(salmon_wholeamount@data, row)
 
#salmon_wholetimes@data <- merge(salmon_wholetimes@data, row)
 
  
amountSalmon <- EvalOutput(amount, forceEval = TRUE)
+
* Model run 3.3.2017. All variables assumed independent. [http://en.opasnet.org/en-opwiki/index.php?title=Special:RTools&id=lwlSwXazIDHDyJJg]
 +
* Model run 3.3.2017. p has more dimensions. [http://en.opasnet.org/en-opwiki/index.php?title=Special:RTools&id=ZmbNUuZeb7UOf8NP]
 +
* Model run 25.3.2017. Several model versions: strange binomial+multivarnormal, binomial, fractalised multivarnormal [http://en.opasnet.org/en-opwiki/index.php?title=Special:RTools&id=pKe0s2Ldm1mbIVuO]
 +
* Model run 27.3.2017 [http://en.opasnet.org/en-opwiki/index.php?title=Special:RTools&id=2hY9p2r8CTJi3Qwq]
 +
* Other models except multivariate normal were [http://en.opasnet.org/en-opwiki/index.php?title=Goherr:_Fish_consumption_study&oldid=40185 archived] and removed from active code 29.3.2017.
 +
* Model run 29.3.2017 with raw data graphs [http://en.opasnet.org/en-opwiki/index.php?title=Special:RTools&id=BB8nePJb7hzSw6Ha]
 +
* Model run 29.3.2017 with salmon and herring ovariables stored [http://en.opasnet.org/en-opwiki/index.php?title=Special:RTools&id=2Hz4tYjrQLnUfIXw]
 +
* Model run 13.4.2017 with first version of coordinate matrix and principal coordinate analysis [http://en.opasnet.org/en-opwiki/index.php?title=Special:RTools&id=2k2dKhYPc2UkOCY5]
 +
* Model run 20.4.2017 [http://en.opasnet.org/en-opwiki/index.php?title=Special:RTools&id=QXRSZOliFNfJil39] code works but needs a safety check against outliers
 +
* Model run 21.4.2017 [http://en.opasnet.org/en-opwiki/index.php?title=Special:RTools&id=xbt2OoXPG8fi5COL] some model results plotted
 +
* Model run 21.4.2017 [http://en.opasnet.org/en-opwiki/index.php?title=Special:RTools&id=waDgScuIkUvEShLy] ovariables produced by the model stored.
 +
* Model run 18.5.2017 [http://en.opasnet.org/en-opwiki/index.php?title=Special:RTools&id=hy2clSt3Vo5y4xN5] small updates
  
temp <- amountSalmon@output
+
<rcode name="bayes" label="Initiate Bayes model (for developers only)" graphics=1>
temp <- aggregate(temp$amountResult, by=list(temp$Country, temp$Ages, temp$Gender), FUN = mean)
+
# This is code Op_en7749/bayes on page [[Goherr: Fish consumption study]]
colnames(temp) <- c("Country","Age","Gender","Salmon amount")
 
oprint(temp)
 
  
#################Bayesian approach
+
library(OpasnetUtils)
 +
library(ggplot2)
 +
library(reshape2)
 +
library(rjags)
 +
library(car)
 +
library(vegan)
 +
library(MASS)
 +
#library(gridExtra) # Error: package ‘gridExtra’ was built before R 3.0.0: please re-install it
 +
 
 +
# Fish intake in humans
 +
# Data from data.frame survey from page [[Goherr: Fish consumption study]]
 +
 
 +
objects.latest("Op_en7749", "preprocess2") # [[Goherr: Fish consumption study]]: survey, surv, ...
 +
 
 +
cat("Version with multivariate normal.\n")
 +
 
 +
# Development needs:
 +
## Correlation between salmon.often and herring.often needs to be estimated.
 +
## Gender, country and age-spesific values should be estimated.
  
 
mod <- textConnection("
 
mod <- textConnection("
 
   model{
 
   model{
     for(j in 1:4) {
+
     for(i in 1:S) {
       for(i in 1:N) {
+
       survs[i,1:4] ~ dmnorm(mus[], Omegas[,])
        sal[i , j] ~ dbin(p[j], 9)
+
    }
      }
+
    for(j in 1:H) {
       p[j] ~ dunif(0,1)
+
       survh[j,1:4] ~ dmnorm(muh[], Omegah[,])
 
     }
 
     }
 +
    mus[1:4] ~ dmnorm(mu0[1:4], S2[1:4,1:4])
 +
    Omegas[1:4,1:4] ~ dwish(S3[1:4,1:4],S)
 +
    anss.pred ~ dmnorm(mus[], Omegas[,])
 +
    muh[1:4] ~ dmnorm(mu0[1:4], S2[1:4,1:4])
 +
    Omegah[1:4,1:4] ~ dwish(S3[1:4,1:4],H)
 +
    ansh.pred ~ dmnorm(muh[], Omegah[,])
 
   }
 
   }
 
")
 
")
  
# This row takes data and converts it to numbers. But what should be done is to take
+
jags <- jags.model(
# each variable, remove NA, order answers meaningfully and then convert to numbers.
+
  mod,
# A binomial distribution is assumed for bins of answer choices.
+
  data = list(
salm <- as.data.frame(lapply(survey[46:49], FUN = function(x) as.numeric(as.factor(x))))
+
    survs = surv[surv$Eatsalm,c(8:11)],
jags <- jags.model(mod,
+
    S = sum(surv$Eatsalm),
  data = list(N = nrow(survey),
+
    survh = surv[surv$Eatherr,c(13:16)],
     sal = salm),
+
    H = sum(surv$Eatherr),
 +
    mu0 = rep(2,4),
 +
    S2 = diag(4)/100000,
 +
     S3 = diag(4)/10000
 +
  ),
 
   n.chains = 4,
 
   n.chains = 4,
 
   n.adapt = 100
 
   n.adapt = 100
 
)
 
)
  
update(jags, 1000)
+
update(jags, 100)
 +
samps.j <- jags.samples(
 +
  jags,
 +
  c('mus', 'Omegas', 'anss.pred','muh','Omegah','ansh.pred'),
 +
  1000
 +
)
 +
js <- array(
 +
  c(
 +
    samps.j$mus[,,1],
 +
    samps.j$Omegas[,1,,1],
 +
    samps.j$Omegas[,2,,1],
 +
    samps.j$Omegas[,3,,1],
 +
    samps.j$Omegas[,4,,1],
 +
    samps.j$anss.pred[,,1],
 +
    samps.j$muh[,,1],
 +
    samps.j$Omegah[,1,,1],
 +
    samps.j$Omegah[,2,,1],
 +
    samps.j$Omegah[,3,,1],
 +
    samps.j$Omegah[,4,,1],
 +
    samps.j$ansh.pred[,,1]
 +
  ),
 +
  dim = c(4,1000,6,2),
 +
  dimnames = list(
 +
    Question = 1:4,
 +
    Iter = 1:1000,
 +
    Parameter = c("mu","Omega1", "Omega2", "Omega3", "Omega4", "ans.pred"),
 +
    Fish = c("Salmon", "Herring")
 +
  )
 +
)
 +
 
 +
# Mu for all questions about salmon
 +
scatterplotMatrix(t(js[,,1,1]))
 +
# All parameters for question 1 about salmon
 +
scatterplotMatrix(js[1,,,1])
 +
# Same for herring
 +
scatterplotMatrix(js[1,,,2])
 +
 
 +
jsd <- melt(js)
 +
#ggplot(jsd, aes(x=value, colour=Question))+geom_density()+facet_grid(Parameter ~ Fish)
 +
#ggplot(as.data.frame(js), aes(x = anss.pred, y = Sampled))+geom_point()+stat_ellipse()
 +
 
 +
coda.j <- coda.samples(
 +
  jags,
 +
  c('mus', 'Omegas', 'anss.pred'),
 +
  1000
 +
)
 +
 
 +
plot(coda.j)
 +
 
 +
######## fish.param contains expected values of the distribution parameters from the model
 +
 
 +
fish.param <- list(
 +
  mu = apply(js[,,1,], MARGIN = c(1,3), FUN = mean),
 +
  Omega = lapply(
 +
    1:2,
 +
    FUN = function(x) {
 +
      solve(apply(js[,,2:5,], MARGIN = c(1,3,4), FUN = mean)[,,x])
 +
    } # solve matrix: precision->covariace
 +
  )
 +
)
 +
 
 +
objects.store(fish.param)
 +
cat("List fish.param stored.\n")
 +
</rcode>
 +
 
 +
==== Initiate ovariables ====
 +
 
 +
'''Amount estimated from a bayesian model.
  
samps <- jags.samples(jags, 'p', 1000)
+
* Model run 24.5.2017 [http://en.opasnet.org/en-opwiki/index.php?title=Special:RTools&id=3UORzPwospQxp82h]
  
plot(samps[[1]])
+
<rcode name="modeljsp" label="Initiate jsp from model (for developers only)">
 +
# This is code Op_en7749/modeljsp on page [[Goherr: Fish consumption study]]
  
 +
library(OpasnetUtils)
  
#### Calculate herring amount
+
jsp <- Ovariable(
 +
  "jsp",
 +
  dependencies = data.frame(Name = "fish.param", Ident = "Op_en7749/bayes"),
 +
  formula = function(...) {
 +
    require(MASS)
 +
    require(reshape2)
 +
    jsp <- lapply(
 +
      1:2,
 +
      FUN = function(x) {
 +
        mvrnorm(openv$N, fish.param$mu[,x], fish.param$Omega[[x]])
 +
      }
 +
    )
 +
   
 +
    jsp <- rbind(
 +
      cbind(
 +
        Fish = "Salmon",
 +
        Iter = 1:nrow(jsp[[1]]),
 +
        as.data.frame(jsp[[1]])
 +
      ),
 +
      cbind(
 +
        Fish = "Herring",
 +
        Iter = 1:nrow(jsp[[2]]),
 +
        as.data.frame(jsp[[2]])
 +
      )
 +
    )
 +
    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)
 +
  }
 +
)
  
herring_dishtimes <- Ovariable("herring_dishtimes", data = data.frame(
+
objects.store(jsp)
  short,
+
cat("Ovariable jsp stored.\n")
  Value = survey[[95]],
+
</rcode>
  Result = 1
 
)) #herring with dish times / year
 
  
herring_dishamount <- Ovariable("herring_dishamount", data = data.frame(
+
'''Amount estimates directly from data rather than from a bayesian model.
  short,
 
  Value = survey[[96]],
 
  Result = 1
 
)) #herring with dish amount per one serving
 
  
herring_wholetimes <- Ovariable("herring_wholetimes", data = data.frame(
+
* Initiation run 18.5.2017 [http://en.opasnet.org/en-opwiki/index.php?title=Special:RTools&id=crW1kboP72BN1JbK]
  short,
 
  Value = survey[[97]],
 
  Result = 1
 
)) #herring as such times / year
 
  
herring_wholeamount <- Ovariable("herring_wholeamount", data = data.frame(
+
<rcode name="surveyjsp" label="Initiate jsp from survey (for developers only)">
  short,
+
# This is code Op_en7749/surveyjsp on page [[Goherr: Fish consumption study]]
  Value = survey[[98]],
+
# The code produces amount esimates (jsp ovariable) directly from data rather than bayesian model.
  Result = 1
 
)) #herring as whole amount per one serving
 
  
herring_dishtimesassump <- Ovariable("herring_dishtimesassump", data = assumptions[assumptions$Variable == "V95" , c("Value", "Result")])
+
library(OpasnetUtils)
 +
library(reshape2)
  
herring_dishamountassump <- Ovariable("herring_dishamountassump", data = assumptions[assumptions$Variable == "V96" , c("Value", "Result")])
+
objects.latest("Op_en7749", code_name="preprocess2") # original survey data (surv)
  
herring_ingridient <- Ovariable("herring_ingridient", data = assumptions[assumptions$Variable == "herring_ingridient", ]["Result"])
+
sur <- survey[c(157,1,3,158,16,29,30,31,46:49,86,95:98)]
  
herring_wholetimesassump <- Ovariable("herring_wholetimesassump", data = assumptions[assumptions$Variable == "V97" , c("Value", "Result")])
+
#colnames(sur)
 +
#[1] "Row"              "Country"          "Gender"            "Ages"           
 +
#[5] "Eat.fish"          "How.often.fish"    "Eat.salmon"        "Baltic.salmon"  
 +
#[9] "How.often.BS"      "How.much.BS"      "How.often.side.BS" "How.much.side.BS"
 +
#[13] "Eat.BH"            "How.often.BH"      "How.much.BH"       "How.often.side.BH"
 +
#[17] "How.much.side.BH"
  
herring_wholeamountassump <- Ovariable("herring_wholeamountassump", data = assumptions[assumptions$Variable == "V98" , c("Value", "Result")])
+
colnames(sur)[c(1,8:17)] <- c("Iter",rep(as.character(c(5,1:4)),2))
 +
sur[8:17] <- sapply(sur[8:17], as.numeric)
 +
sur <- rbind(cbind(Fish="Herring", sur[-(8:12)]),
 +
            cbind(Fish="Salmon", sur[-(13:17)])
 +
)
 +
sur <- melt(
 +
  sur,
 +
  measure.vars=as.character(1:5),
 +
  variable.name="Question",
 +
  value.name="Result"
 +
)
 +
sur$Result[is.na(sur$Result)] <- 1 # Ovariable often becomes never -> amount becomes 0.
  
amount <- Ovariable("amount",  
+
jsp <- Ovariable(
                    dependencies = data.frame(Name = c(
+
  "jsp",  
                      "herring_dishamount",
+
  output = sur,
                      "herring_dishamountassump",
+
  marginal = colnames(sur) %in% c("Fish", "Iter", "Question")
                      "herring_ingridient",
 
                      "herring_dishtimes",
 
                      "herring_dishtimesassump",
 
                      "herring_wholeamount",
 
                      "herring_wholeamountassump",
 
                      "herring_wholetimes",
 
                      "herring_wholetimesassump"
 
                    )),
 
                    formula = function(...) {
 
                     
 
                      out1 <- (herring_dishamount * herring_dishamountassump * herring_ingridient)
 
                      out1@output$Value <- NULL
 
                      out1 <- ((herring_dishtimes * herring_dishtimesassump) * out1) / 365
 
                      out1@output$Value <- NULL
 
                      out2 <- (herring_wholeamount * herring_wholeamountassump)
 
                      out2@output$Value <- NULL
 
                      out2 <- ((herring_wholetimes * herring_wholetimesassump) * out2) / 365
 
                      out2@output$Value <- NULL
 
                      out <- out1 + out2
 
                     
 
                      # Per vuosi -> per d
 
                     
 
                      return(out)
 
                    }
 
 
)
 
)
  
 +
objects.store(jsp)
 +
cat("Ovariable jsp with actual survey data: each respondent is an iteration.\n")
 +
</rcode>
  
#### Draw N rows from the questionnaire subset filling the condition (in this case from the Country+Gender-group)
+
'''Initiate other ovariables
  
rows <- data.frame()
+
* Code stores ovariables assump, often, much, oftenside, muchside, amount.
for(i in 1:nrow(condition)) {
+
* Model run 19.5.2017 [http://en.opasnet.org/en-opwiki/index.php?title=Special:RTools&id=FauP3x6hviC4xWCD]
  temp <- survey[
+
* Initiation run 24.5.2017 without jsp [http://en.opasnet.org/en-opwiki/index.php?title=Special:RTools&id=6U3FWqVRaNumPcok]
    survey$Gender == condition$Gender[i] & survey$Country == condition$Country[i] ,
+
* Model run 8.6.2017 [http://en.opasnet.org/en-opwiki/index.php?title=Special:RTools&id=euGolhOQvPqzQDvf]
    c("Gender", "Country", "Weighting")
+
 
    ] # Eikö tässä voisi yksinkertaistaa ja käyttää vain rivinumeroa eikä koko tempiä?
+
<rcode name="initiate" label="Initiate ovariables (for developers only)">
  temp <- temp[sample(1:nrow(temp), get("N", envir = openv), replace = TRUE, prob = temp$Weighting) , ]
+
# This is code Op_en7749/initiate on page [[Goherr: Fish consumption study]]
  rows <- rbind(rows, data.frame(
 
    condition[i , ],
 
    Iter = 1:get("N", envir = openv),
 
    Row = as.character(floor(as.numeric(rownames(temp)))),
 
    Result = 1
 
  ))
 
}
 
rows <- Ovariable(output = rows, marginal = c(TRUE, TRUE, TRUE, TRUE, FALSE))
 
  
########## create ovariable for impact assessment model with the drawn individuals
+
library(OpasnetUtils)
  
row <- rows@output
+
# Combine modelled survey answers with estimated amounts and frequencies by:
row$Result <- NULL
+
# Rounding the modelled result and merging that with value in ovariable assump
  
herring_dishamount@data <- merge(herring_dishamount@data, row)
+
often <- Ovariable(
herring_dishtimes@data <- merge(herring_dishtimes@data, row)
+
  "often",
herring_wholeamount@data <- merge(herring_wholeamount@data, row)
+
  dependencies = data.frame(Name=c("jsp","assump")),
herring_wholetimes@data <- merge(herring_wholetimes@data, row)
+
  formula = function(...) {
 +
    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
 +
    )
 +
    out <- out[!colnames(out) %in% c("Value", "Variable", "Result")]
 +
    colnames(out)[colnames(out) == "assumpResult"] <- "Result"
 +
    return(out)
 +
  }
 +
)
  
amountHerring <- EvalOutput(amount, forceEval = TRUE)
+
much <- Ovariable(
 +
  "much",
 +
  dependencies = data.frame(Name=c("jsp","assump")),
 +
  formula = function(...) {
 +
    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
 +
    )
 +
    out <- out[!colnames(out) %in% c("Value", "Variable", "Result")]
 +
    colnames(out)[colnames(out) == "assumpResult"] <- "Result"
 +
    return(out)
 +
  }
 +
)
  
temp <- amountHerring@output
+
oftenside <- Ovariable(
temp <- aggregate(temp$amountResult, by=list(temp$Country,temp$Ages,temp$Gender), FUN = mean)
+
  "oftenside",
colnames(temp) <- c("Country","Age","Gender","Herring amount")
+
  dependencies = data.frame(Name=c("jsp","assump")),
oprint(temp)
+
  formula = function(...) {
 +
    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
 +
    )
 +
    out <- out[!colnames(out) %in% c("Value", "Variable", "Result")]
 +
    colnames(out)[colnames(out) == "assumpResult"] <- "Result"
 +
    return(out)
 +
  }
 +
)
  
objects.store(amountHerring, amountSalmon)
+
muchside <- Ovariable(
cat("objects amountHerring, amountSalmon were stored.\n")
+
  "muchside",
</rcode>
+
  dependencies = data.frame(Name=c("jsp","assump")),
 +
  formula = function(...) {
 +
    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
 +
    )
 +
    out <- out[!colnames(out) %in% c("Value", "Variable", "Result")]
 +
    colnames(out)[colnames(out) == "assumpResult"] <- "Result"
 +
    return(out)
 +
  }
 +
)
  
==== Assumptions ====
+
assump <- Ovariable(
 +
  "assump",
 +
  ddata = "Op_en7749", subset = "Assumptions for calculations"
 +
)
  
The following assumptions are used:
+
amount <- Ovariable(
<t2b name="Assumptions for calculations" index="Variable,Value,Explanation" obs="Result" unit="-">
+
  "amount",
V46|6|times per year|260 - 364
+
  dependencies = data.frame(Name = c(
V46|5|times per year|104 - 208
+
    "often",
V46|4|times per year|52
+
    "much",
V46|3|times per year|12 - 36
+
    "oftenside",
V46|2|times per year|2 - 5
+
    "muchside",
V46|1|times per year|0.5 - 0.9
+
    "assump"
V46||times per year|0
+
  )),
V47|1/6 plate or below (50 grams)|grams / serving|20 - 50
+
   formula = function(...) {
V47|1/3 plate (100 grams)|grams / serving      |70 - 100
+
    away <- c(
V47|1/2 plate (150 grams)|grams / serving   |120 - 150
+
      "assumpUnit",
V47|2/3 plate (200 grams)|grams / serving|170 - 200
+
      "Eat.fish",
V47|5/6 plate (250 grams)|grams / serving|220 - 250
+
      "How.often.fish",
V47|full plate (300 grams)|grams / serving|270 - 300
+
      "Eat.salmon"
V47|overly full plate (500 grams)|grams / serving|450 - 500
+
    )
V47|Not able to estimate|grams / serving|20 - 500
+
    often <- often[ , !colnames(often@output) %in% away]
V47||grams|0
+
    much <- much[ , !colnames(much@output) %in% away]
salmon_ingridient||fraction|0.1 - 0.3
+
    oftenside <- oftenside[ , !colnames(oftenside@output) %in% away]
V48|Never|times per year|0
+
    muchside <- muchside[ , !colnames(muchside@output) %in% away]
V48|5 or more times per week|times per year|260 - 364
+
    assump <- assump[assump$Variable == "ingredient", !colnames(assump@output) %in%
V48|2 - 4 times per week|times per year|104 - 208
+
      c("Variable", "Value", "Explanation", "assumpUnit")]
V48|once a week|times per year|52
 
V48|1 - 3 times per month|times per year|12 - 36
 
V48|A few times a year|times per year|2 - 5
 
V48|less than once a year|times per year|0.5 - 0.9
 
V48||times per year |0
 
V49|1/6 plate or below (50 grams)|grams / serving|20 - 50
 
V49|1/4 plate (100 grams)|grams / serving|70 - 100
 
V49|1/2 plate (150 grams)|grams / serving|120 - 150
 
V49|2/3 plate (200 grams)|grams / serving|170 - 200
 
V49|5/6 plate (250 grams)|grams / serving|220 - 250
 
V49|Not able to estimate|grams / serving|20 - 250
 
V49||grams|0
 
V95|Never|times per year|0
 
V95|5 or more times per week|times per year|260 - 364
 
V95|2 - 4 times per week|times per year|104 - 208
 
V95|once a week|times per year|52
 
V95|1 - 3 times per month|times per year|12 - 36
 
V95|A few times a year|times per year|2 - 5
 
V95|less than once a year|times per year|0.5 - 0.9
 
V95||times per year|0
 
V96|1/6 plate or below (50 grams)|grams / serving|20 - 50
 
V96|1/3 plate (100 grams)|grams / serving|70 - 100
 
V96|1/2 plate (150 grams)|grams / serving|120 - 150
 
V96|2/3 plate (200 grams)|grams / serving|170 - 200
 
V96|5/6 plate (250 grams)|grams / serving|220 - 250
 
V96|full plate (300 grams)|grams / serving|270 - 300
 
V96|overly full plate (500 grams)|grams / serving|450 - 500
 
V96|Not able to estimate|grams / serving|20 - 500
 
V96||grams|0
 
herring_ingridient||fraction|0.1 - 0.3
 
V97|Never|times per year|0
 
V97|5 or more times per week|times per year|260 - 364
 
V97|2 - 4 times per week|times per year|104 - 208
 
V97|once a week|times per year|52
 
V97|1 - 3 times per month|times per year|12 - 36
 
V97|A few times a year|times per year|2 - 5
 
V97|less than once a year|times per year|0.5 - 0.9
 
V97||times per year|0
 
V98|1/6 plate or below (50 grams)|grams / serving|20 - 50
 
V98|1/4 plate (100 grams)|grams / serving|70 - 100
 
V98|1/2 plate (150 grams)|grams / serving|120 - 150
 
V98|2/3 plate (200 grams)|grams / serving|170 - 200
 
V98|5/6 plate (250 grams)|grams / serving|220 - 250
 
V98|Not able to estimate|grams / serving|20 - 250
 
V98||grams|0
 
</t2b>
 
  
==== Questionnaire ====
+
    out <- (often * much + oftenside * muchside * assump)/365 # g /d
 +
    return(out)
 +
  }
 +
)
  
{{hidden|
+
objects.store(assump, often, much, oftenside, muchside, amount)
<t2b name="Questions in the Goherr questionnaire" index="Index,Full question" obs="Question" unit="-">
+
cat("Ovariables assump, often, much, oftenside, muchside, amount stored.\n")
V1 |Country |Country
+
</rcode>
V2 |1. What is the postal code of your residence? |Postal code
 
V3 |2. What is your gender? |Gender
 
V4 |2. How old are you? |Age
 
V5 |3. What is the level of your highest education? |Education
 
V6 |4. How would you rate the purchasing power of your household? |Purchasing power
 
V7 |5. Which of the following food supplements (as a separate product or as a part of some multicompound) do you eat often at least part of the year?:Fatty acids (Omega 3, DHA, EPA etc.) |Omega3
 
V8 |5. Which of the following food supplements (as a separate product or as a part of some multicompound) do you eat often at least part of the year?:D vitamin |Vitamin D
 
V9 |5. Which of the following food supplements (as a separate product or as a part of some multicompound) do you eat often at least part of the year?:Other vitamins |Other vitamins
 
V10 |5. Which of the following food supplements (as a separate product or as a part of some multicompound) do you eat often at least part of the year?:None of the above |None above
 
V11 |5. Which of the following food supplements (as a separate product or as a part of some multicompound) do you eat often at least part of the year?:Don't Know |Don't know
 
V12 |6. Does someone in your household fish?:No |No fishing
 
V13 |6. Does someone in your household fish?:Yes, for recreational purposes |Recreational
 
V14 |6. Does someone in your household fish?:Yes, for household use |Household use
 
V15 |6. Does someone in your household fish?:Yes, as a professional fisherman |Professional
 
V16 |7. Do you eat fish? |Fish eating
 
V17 |8. Why don't you eat fish?:Allergy |Allergy
 
V18 |8. Why don't you eat fish?:I don't like the taste |Don't like taste
 
V19 |8. Why don't you eat fish?:I don't like fish bones |Don't like bones
 
V20 |8. Why don't you eat fish?:Difficult to cook |Cooking difficult
 
V21 |8. Why don't you eat fish?Health risks |Risky to health
 
V22 |8. Why don't you eat fish?:I'm not used to |Not used to
 
V23 |8. Why don't you eat fish?:I'm concerned about the sustainability of fish stocks |Sustainability of stock
 
V24 |8. Why don't you eat fish?:It is ethically wrong to eat animals |Ethically wrong
 
V25 |8. Why don't you eat fish?:I'm a vegetarian |Vegetarian
 
V26 |8.  Why don't you eat fish?:Don't Know |Don't know
 
V27 |8. Why don't you eat fish?:Other |Other
 
V28 |8. Why don't you eat fish?:Other open |Open
 
V29 |9. How often do you eat fish? |How often eat fish
 
V30 |10. Do you eat salmon or trout at least sometimes? |Salmon eating
 
V31 |11. Which of the following salmonids do you eat at least sometimes?:Wild Baltic salmon |Baltic salmon
 
V32 |11. Which of the following salmonids do you eat at least sometimes?:Wild Atlantic salmon |Atlantic salmon
 
V33 |11. Which of the following salmonids do you eat at least sometimes?:Norwegian cultured salmon |Norwegian salmon
 
V34 |11. Which of the following salmonids do you eat at least sometimes?:Rainbow trout |Rainbow trout
 
V35 |11. Which of the following salmonids do you eat at least sometimes?:I never know which salmon I eat |Unknown salmon
 
V36 |11. Which of the following salmonids do you eat at least sometimes?:Some other salmon, what? |Other salmon
 
V37 |11. Which of the following salmonids do you eat at least sometimes?:Other open |Open
 
V38 |12. Where do you usually get the wild Baltic salmon that you eat?:Someone in our hosehold catches it |Own catch
 
V39 |12. Where do you usually get the wild Baltic salmon that you eat?:Buy from a grocery store |Grocery store
 
V40 |12. Where do you usually get the wild Baltic salmon that you eat?:Buy from a market place/fishmonger or similar |Market place
 
V41 |12. Where do you usually get the wild Baltic salmon that you eat?:Eat in a restaurant/cafe/canteen or similar |Restaurant
 
V42 |12. Where do you usually get the wild Baltic salmon that you eat?:Directly from a fisher |From fisher
 
V43 |12. Where do you usually get the wild Baltic salmon that you eat?:From a relative, friend, or similar |From friend
 
V44 |12. Where do you usually get the wild Baltic salmon that you eat?:Other |Other
 
V45 |12. Where do you usually get the wild Baltic salmon that you eat?:Other open |Open
 
V46 |13. How often do you on average eat wild Baltic salmon as an ingredient in a dish (i.e. as part of a soup, gravy, sushi, casserole etc.)? |How often Baltic salmon
 
V47 |14. How much on average do you eat of a dish with wild Baltic salmon in it? Think of a medium sized lunch plate and the amount of the whole dish, not just the salmon. |How much Baltic salmon
 
V48 |15. How often do you on average eat wild Baltic salmon as a side dish (i.e as a separate product such as fish balls, stake, fillets, graved, canned etc.)? |How often side Baltic salmon
 
V49 |16. What is the average amount of wild Baltic salmon as a side dish? Think of a medium sized lunch plate. |How much side Baltic salmon
 
V50 |17. Select up to three most important reasons for you to eat wild Baltic salmon?:It tastes good |Tastes good
 
V51 |17. Select up to three most important reasons for you to eat wild Baltic salmon?:I caught it |I caught it
 
V52 |17. Select up to three most important reasons for you to eat wild Baltic salmon?:It's easy to cook |Easy to cook
 
V53 |17. Select up to three most important reasons for you to eat wild Baltic salmon?:It's quick to cook |Quick to cook
 
V54 |17. Select up to three most important reasons for you to eat wild Baltic salmon?:It's readily available |Readily available
 
V55 |17. Select up to three most important reasons for you to eat wild Baltic salmon?:It's healthy |Healthy
 
V56 |17. Select up to three most important reasons for you to eat wild Baltic salmon?:It's inexpensive |Inexpensive
 
V57 |17. Select up to three most important reasons for you to eat wild Baltic salmon?:My family likes it |Family likes it
 
V58 |17. Select up to three most important reasons for you to eat wild Baltic salmon?:It's environmentally/climate friendly choice |Environmentally friendly
 
V59 |17. Select up to three most important reasons for you to eat wild Baltic salmon?:It's a traditional dish |Traditional dish
 
V60 |17. Select up to three most important reasons for you to eat wild Baltic salmon?:Some other reasons, what? |Other
 
V61 |17. Select up to three most important reasons for you to eat wild Baltic salmon?:Other open |Open
 
V62 |18. You answered in the previous question that you don't eat wild Baltic salmon. Select up to three most important reasons for why not eating it.:I don't like the taste |Don't like taste
 
V63 |18. You answered in the previous question that you don't eat wild Baltic salmon. Select up to three most important reasons for why not eating it.:I am not used to eating it / not offered at home |Not used to
 
V64 |18. You answered in the previous question that you don't eat wild Baltic salmon. Select up to three most important reasons for why not eating it.:I don't know how to cook it |Don't know how to cook
 
V65 |18. You answered in the previous question that you don't eat wild Baltic salmon. Select up to three most important reasons for why not eating it.:It is not easily available |Not available
 
V66 |18. You answered in the previous question that you don't eat wild Baltic salmon. Select up to three most important reasons for why not eating it.:I'm worried about the possible health risks caused by the harmful chemicals in it |Health risks
 
V67 |18. You answered in the previous question that you don't eat wild Baltic salmon. Select up to three most important reasons for why not eating it.:I doubt the quality/freshness of the products |Quality issues
 
V68 |18. You answered in the previous question that you don't eat wild Baltic salmon. Select up to three most important reasons for why not eating it.:I'm worried about the sustainability of the stocks |Sustainability of stock
 
V69 |18. You answered in the previous question that you don't eat wild Baltic salmon. Select up to three most important reasons for why not eating it.:It doesn't belong to traditional dishes of my home area |Not traditional
 
V70 |18. You answered in the previous question that you don't eat wild Baltic salmon. Select up to three most important reasons for why not eating it.:It is too expensive |Expensive
 
V71 |18. You answered in the previous question that you don't eat wild Baltic salmon. Select up to three most important reasons for why not eating it.:Some other reason, what? |Other
 
V72 |18. You answered in the previous question that you don't eat wild Baltic salmon. Select up to three most important reasons for why not eating it.:Other open |Open
 
V73 |19. How would the following factors influence on your consumption of wild Baltic salmon compared to your current use? Select one for each option:Lower price |Lower price
 
V74 |19. How would the following factors influence on your consumption of wild Baltic salmon compared to your current use? Select one for each option:Higher price |Higher price
 
V75 |19. How would the following factors influence on your consumption of wild Baltic salmon compared to your current use? Select one for each option:Better availability |Better availability
 
V76 |19. How would the following factors influence on your consumption of wild Baltic salmon compared to your current use? Select one for each option:Availability of wider variety of ready meals / refined products |Ready meals
 
V77 |19. How would the following factors influence on your consumption of wild Baltic salmon compared to your current use? Select one for each option:Cooking suggestions and recipes provided within the store or in the package. |Recipes
 
V78 |19. How would the following factors influence on your consumption of wild Baltic salmon compared to your current use? Select one for each option:Better information (e.g. package markings or in the store) on the catch date, area, fisher and/or the refiner |Package markings
 
V79 |19. How would the following factors influence on your consumption of wild Baltic salmon compared to your current use? Select one for each option:Improvement of the stocks (eco-labelling) |Eco-labelling
 
V80 |19. How would the following factors influence on your consumption of wild Baltic salmon compared to your current use? Select one for each option:Lower level of harmful chemicals in the fish |Less chemicals
 
V81 |19. How would the following factors influence on your consumption of wild Baltic salmon compared to your current use? Select one for each option:National food safety authorities publish a recommendation to eat it |Recommendation
 
V82 |19. How would the following factors influence on your consumption of wild Baltic salmon compared to your current use? Select one for each option:National food safety authorities publish a recommendation to limit eating it |Limit recommendation
 
V83 |19. How would the following factors influence on your consumption of wild Baltic salmon compared to your current use? Select one for each option:Some other reason, what? |Other
 
V84 |19. How would the following factors influence on your consumption of wild Baltic salmon compared to your current use? Select one for each option:Other open |Open
 
V85 |20. Do you eat any herring (Baltic or other) at least sometimes? |Eat herring
 
V86 |21. Do you eat Baltic herring? This means herring caught from Baltic sea, not from Atlantic ocean |Eat Baltic herring
 
V87 |22. Where do you usually get the wild Baltic herring that you eat?:Someone in our hosehold catches it |Own catch
 
V88 |22. Where do you usually get the wild Baltic herring that you eat?:Buy from a grocery store |Grocery store
 
V89 |22. Where do you usually get the wild Baltic herring that you eat?:Buy from a market place/fishmonger or similar |Market place
 
V90 |22. Where do you usually get the wild Baltic herring that you eat?:Eat in a restaurant/cafe/canteen or similar |Restaurant
 
V91 |22. Where do you usually get the wild Baltic herring that you eat?:Directly from a fisher |From fisher
 
V92 |22. Where do you usually get the wild Baltic herring that you eat?:From a relative, friend, or similar |From friend
 
V93 |22. Where do you usually get the wild Baltic herring that you eat?:Other |Other
 
V94 |22. Where do you usually get the wild Baltic herring that you eat?:Other open |Open
 
V95 |23. How often do you on average eat Baltic herring as ingredient of a dish? (i.e as part of a dish such as in a casserole or some other food including Baltic herring)? |How often Baltic herring
 
V96 |24. How much on average do you eat of a dish with Baltic herring in it? Think of a medium sized lunch plate and the amount of the whole dish, not just the amount of Baltic herring |How much Baltic herring
 
V97 |25. How often do you on average eat whole Baltic herrings or fillets as a side dish (fried, smoked, rolls, pickled, salted or otherwise prepared)? |How often side Baltic herring
 
V98 |26. How much on average of Baltic herring as a side dish (think of a regular sized lunch plate)? |How much side Baltic herring
 
V99 |27. Select up to three most important reasons for you to eat Baltic herring?:It tastes good |Tastes good
 
V100 |27. Select up to three most important reasons for you to eat Baltic herring?:I caught it |I caught it
 
V101 |27. Select up to three most important reasons for you to eat Baltic herring?:It's easy to cook |Easy to cook
 
V102 |27. Select up to three most important reasons for you to eat Baltic herring?:It's quick to cook |Quick to cook
 
V103 |27. Select up to three most important reasons for you to eat Baltic herring?:It's readily available |Readily available
 
V104 |27. Select up to three most important reasons for you to eat Baltic herring?:It's healthy |Healthy
 
V105 |27. Select up to three most important reasons for you to eat Baltic herring?:It's inexpensive |Inexpensive
 
V106 |27. Select up to three most important reasons for you to eat Baltic herring?:My family likes it |Family likes it
 
V107 |27. Select up to three most important reasons for you to eat Baltic herring?:It's environmentally/climate friendly choice |Environmentally friendly
 
V108 |27. Select up to three most important reasons for you to eat Baltic herring?:It's a traditional dish |Traditional dish
 
V109 |27. Select up to three most important reasons for you to eat Baltic herring?:Some other reasons, what? |Other
 
V110 |27. Select up to three most important reasons for you to eat Baltic herring?:Other open |Open
 
V111 |28. You answered in the previous question that you don't eat Baltic herring. Select up to three most important reasons for why not eating it.:I don't like the taste and/or smell of it |Don't like taste
 
V112 |28. You answered in the previous question that you don't eat Baltic herring. Select up to three most important reasons for why not eating it.:I am not used to eating it / not offered at home |Not used to
 
V113 |28. You answered in the previous question that you don't eat Baltic herring. Select up to three most important reasons for why not eating it.:I don't know how to cook it |Don't know how to cook
 
V114 |28. You answered in the previous question that you don't eat Baltic herring. Select up to three most important reasons for why not eating it.:It is difficult to cook |Difficult to cook
 
V115 |28. You answered in the previous question that you don't eat Baltic herring. Select up to three most important reasons for why not eating it.:It is not easily available |Not available
 
V116 |28. You answered in the previous question that you don't eat Baltic herring. Select up to three most important reasons for why not eating it.:I'm worried about the possible risks caused by the harmful chemicals in it |Health risks
 
V117 |28. You answered in the previous question that you don't eat Baltic herring. Select up to three most important reasons for why not eating it.:It is more suitable for animal feed than human food |Better for feed
 
V118 |28. You answered in the previous question that you don't eat Baltic herring. Select up to three most important reasons for why not eating it.:I doubt the quality/freshness of the products |Quality issues
 
V119 |28. You answered in the previous question that you don't eat Baltic herring. Select up to three most important reasons for why not eating it.:I'm worried about the sustainability of the stocks |Sustainability of stock
 
V120 |28. You answered in the previous question that you don't eat Baltic herring. Select up to three most important reasons for why not eating it.:It doesn't belong to traditional dishes of my home area |Not traditional
 
V121 |28. You answered in the previous question that you don't eat Baltic herring. Select up to three most important reasons for why not eating it.:Some other reason, what? |Other
 
V122 |28. You answered in the previous question that you don't eat Baltic herring. Select up to three most important reasons for why not eating it.:Other open |Open
 
V123 |29. How would the following factors influence your consumption of Baltic herring compared to your current use? Select one option for each row.:Lower price |Lower price
 
V124 |29. How would the following factors influence your consumption of Baltic herring compared to your current use? Select one option for each row.:Higher price |Higher price
 
V125 |29. How would the following factors influence your consumption of Baltic herring compared to your current use? Select one option for each row.:Better availability |Better availability
 
V126 |29. How would the following factors influence your consumption of Baltic herring compared to your current use? Select one option for each row.:Availability of wider variety of ready meals / processed products |Ready meals
 
V127 |29. How would the following factors influence your consumption of Baltic herring compared to your current use? Select one option for each row.:Cooking suggestions and recipes provided in the store or in the package. |Recipes
 
V128 |29. How would the following factors influence your consumption of Baltic herring compared to your current use? Select one option for each row.:Better information (e.g. package markings or in the store) on the catch date, area, fisher and/or processing company. |Package markings
 
V129 |29. How would the following factors influence your consumption of Baltic herring compared to your current use? Select one option for each row.:Improved stocks (eco-labelling) |Eco-labelling
 
V130 |29. How would the following factors influence your consumption of Baltic herring compared to your current use? Select one option for each row.:Lower level of harmful chemicals in the fish |Less chemicals
 
V131 |29. How would the following factors influence your consumption of Baltic herring compared to your current use? Select one option for each row.:National food safety authorities publish a recommendation to eat it |Recommendation
 
V132 |29. How would the following factors influence your consumption of Baltic herring compared to your current use? Select one option for each row.:National food safety authorities publish a recommendation to limit eating it |Limit recommendation
 
V133 |29. How would the following factors influence your consumption of Baltic herring compared to your current use? Select one option for each row.:Some other reason, what? |Other
 
V134 |29. How would the following factors influence your consumption of Baltic herring compared to your current use? Select one option for each row.:Other open |Open
 
V135 |30. Are you familiar with the possible eating recommendations of Baltic herring and/or wild Baltic salmon in your country? |Recommendation awareness
 
V136 |31. How strongly do you agree or disagree with the following statements on Baltic salmon? Please indicate your position by selecting a number from -5 (strongly disagree) to 5 (strongly agree).:It contributes to the economic wellbeing of the society |Economic wellbeing
 
V137 |31. How strongly do you agree or disagree with the following statements on Baltic salmon? Please indicate your position by selecting a number from -5 (strongly disagree) to 5 (strongly agree).:It is a natural resource for humans to utilize |Natural resource
 
V138 |31. How strongly do you agree or disagree with the following statements on Baltic salmon? Please indicate your position by selecting a number from -5 (strongly disagree) to 5 (strongly agree).:It belongs to all Baltic Sea citizens equally |Belongs to Baltic Sea
 
V139 |31. How strongly do you agree or disagree with the following statements on Baltic salmon? Please indicate your position by selecting a number from -5 (strongly disagree) to 5 (strongly agree).:It involves long traditions related to fishing and fish eating |Long traditions
 
V140 |31. How strongly do you agree or disagree with the following statements on Baltic salmon? Please indicate your position by selecting a number from -5 (strongly disagree) to 5 (strongly agree).:It inspires to search experiences from nature, cultural sites, fish markets or from different dishes |Inspiring experiences
 
V141 |31. How strongly do you agree or disagree with the following statements on Baltic salmon? Please indicate your position by selecting a number from -5 (strongly disagree) to 5 (strongly agree).:It is among the most renowned fish species of the Baltic Sea |Renowned species
 
V142 |31. How strongly do you agree or disagree with the following statements on Baltic salmon? Please indicate your position by selecting a number from -5 (strongly disagree) to 5 (strongly agree).:It is part of the Baltic Sea ecosystem |Part of ecosystem
 
V143 |31. How strongly do you agree or disagree with the following statements on Baltic salmon? Please indicate your position by selecting a number from -5 (strongly disagree) to 5 (strongly agree).:I have an emotional bond to it |Emotional bond
 
V144 |31. How strongly do you agree or disagree with the following statements on Baltic salmon? Please indicate your position by selecting a number from -5 (strongly disagree) to 5 (strongly agree).:It helps me to achieve my personal aims |Personal aims
 
V145 |32. How strongly do you agree or disagree with the following statements on Baltic herring? Please indicate your position by selecting a number from -5 (strongly disagree) to 5 (strongly agree).:It contributes to the economic wellbeing of the society |Economic wellbeing
 
V146 |32. How strongly do you agree or disagree with the following statements on Baltic herring? Please indicate your position by selecting a number from -5 (strongly disagree) to 5 (strongly agree).:It is a natural resource for humans to utilize |Natural resource
 
V147 |32. How strongly do you agree or disagree with the following statements on Baltic herring? Please indicate your position by selecting a number from -5 (strongly disagree) to 5 (strongly agree).:It belongs to all Baltic Sea citizens equally |Belongs to Baltic Sea
 
V148 |32. How strongly do you agree or disagree with the following statements on Baltic herring? Please indicate your position by selecting a number from -5 (strongly disagree) to 5 (strongly agree).:It involves long traditions related to fishing and fish eating |Long traditions
 
V149 |32. How strongly do you agree or disagree with the following statements on Baltic herring? Please indicate your position by selecting a number from -5 (strongly disagree) to 5 (strongly agree).:It inspires to search experiences from nature, cultural sites, fish markets or from different dishes |Inspiring experiences
 
V150 |32. How strongly do you agree or disagree with the following statements on Baltic herring? Please indicate your position by selecting a number from -5 (strongly disagree) to 5 (strongly agree).:It is among the most renowned fish species of the Baltic Sea |Renowned species
 
V151 |32. How strongly do you agree or disagree with the following statements on Baltic herring? Please indicate your position by selecting a number from -5 (strongly disagree) to 5 (strongly agree).:It is part of the Baltic Sea ecosystem |Part of ecosystem
 
V152 |32. How strongly do you agree or disagree with the following statements on Baltic herring? Please indicate your position by selecting a number from -5 (strongly disagree) to 5 (strongly agree).:I have an emotional bond to it |Emotional bond
 
V153 |32. How strongly do you agree or disagree with the following statements on Baltic herring? Please indicate your position by selecting a number from -5 (strongly disagree) to 5 (strongly agree).:It helps me to achieve my personal aims |Personal aims
 
V154 |Weighting |Weighting
 
V155 |How old are you? Age category FI |Age category FI
 
V156 |2. How old are you? Age category SWE, DK, EST |Age category other
 
</t2b>
 
}}
 
  
 
=== Dependencies ===
 
=== Dependencies ===
 +
 
The survey data will be used as input in the [[Benefit-risk_assessment_of_Baltic_herring_and_salmon_intake | benefit-risk assessment of Baltic herring and salmon intake]], which is part of the WP5 work in Goherr-project.
 
The survey data will be used as input in the [[Benefit-risk_assessment_of_Baltic_herring_and_salmon_intake | benefit-risk assessment of Baltic herring and salmon intake]], which is part of the WP5 work in Goherr-project.
  
=== Formula ===
+
==See also==
  
==See also==
+
* Useful information about Wishart distribution and related topics:
 +
** [[:en:Scatter matrix]]
 +
** [[:en: Wishart distribution]]
 +
** [[:en:Chi-squared distribution]]
  
 
==Keywords==
 
==Keywords==
Line 758: Line 1,005:
  
 
==Related files==
 
==Related files==
 
{{mfiles}}
 
  
 
{{publication
 
{{publication

Latest revision as of 10:12, 8 June 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

Original questionnaire analysis results

  • 13.3.2017 --# : These should be presented somewhere --Arja (talk) 07:39, 26 April 2017 (UTC)

Consumption amount estimates

Do you want to use directly the survey data rather than modelled data?:

+ 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 can be found from the link below (see Data).

Data

Questionnaire

Original datafile File:Goherr fish consumption.csv.



Assumptions

The following assumptions are used:

Assumptions for calculations(-)
ObsVariableValueUnitResultDescription
1freq1times /a0Never
2freq2times /a0.5 - 0.9less than once a year
3freq3times /a2 - 5A few times a year
4freq4times /a12 - 361 - 3 times per month
5freq5times /a52once a week
6freq6times /a104 - 2082 - 4 times per week
7freq7times /a260 - 3645 or more times per week
8amdish1g /serving20 - 701/6 plate or below (50 grams)
9amdish2g /serving70 - 1301/3 plate (100 grams)
10amdish3g /serving120 - 1801/2 plate (150 grams)
11amdish4g /serving170 - 2302/3 plate (200 grams)
12amdish5g /serving220 - 2805/6 plate (250 grams)
13amdish6g /serving270 - 400full plate (300 grams)
14amdish7g /serving400 - 550overly full plate (500 grams)
15ingredientfraction0.1 - 0.3Fraction of fish in the dish
16amside1g /serving20 - 701/6 plate or below (50 grams)
17amside2g /serving70 - 1301/4 plate (100 grams)
18amside3g /serving120 - 1801/2 plate (150 grams)
19amside4g /serving170 - 2302/3 plate (200 grams)
20amside5g /serving220 - 2805/6 plate (250 grams)

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 [2]
  • Model run 20.4.2017 [3] (contains surv and helping vectors)
  • Model run 21.4.2017 [4] surv contains Eatfish, Eatherr and Eatsalm as columns.

+ Show code

Analyses

Descriptive statistics

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

Model runs

+ Show code

Bayes model

  • Model run 3.3.2017. All variables assumed independent. [6]
  • Model run 3.3.2017. p has more dimensions. [7]
  • Model run 25.3.2017. Several model versions: strange binomial+multivarnormal, binomial, fractalised multivarnormal [8]
  • Model run 27.3.2017 [9]
  • Other models except multivariate normal were archived and removed from active code 29.3.2017.
  • Model run 29.3.2017 with raw data graphs [10]
  • Model run 29.3.2017 with salmon and herring ovariables stored [11]
  • Model run 13.4.2017 with first version of coordinate matrix and principal coordinate analysis [12]
  • Model run 20.4.2017 [13] code works but needs a safety check against outliers
  • Model run 21.4.2017 [14] some model results plotted
  • Model run 21.4.2017 [15] ovariables produced by the model stored.
  • Model run 18.5.2017 [16] small updates

+ Show code

Initiate ovariables

Amount estimated from a bayesian model.

  • Model run 24.5.2017 [17]

+ Show code

Amount estimates directly from data rather than from a bayesian model.

  • Initiation run 18.5.2017 [18]

+ Show code

Initiate other ovariables

  • Code stores ovariables assump, often, much, oftenside, muchside, amount.
  • Model run 19.5.2017 [19]
  • Initiation run 24.5.2017 without jsp [20]
  • Model run 8.6.2017 [21]

+ Show code

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.

See also

Keywords

References


Related files

Goherr: Fish consumption study. Opasnet . [22]. Accessed 18 May 2024.