Goherr: Fish consumption study: Difference between revisions

From Opasnet
Jump to navigation Jump to search
(added references)
 
(88 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{variable|moderator=Arja|stub=Yes}}
{{progression class
|progression=Reviewed
|curator=THL
|date=2019-08-26
}}
{{study|moderator=Arja}}
 
:''This page contains a detailed description about data management and analysis of an international survey related to scientific article ''Forage Fish as Food: Consumer Perceptions on Baltic Herring'' by Mia Pihlajamäki, Arja Asikainen, Suvi Ignatius, Päivi Haapasaari, and Jouni T. Tuomisto.<ref name="pihlajamaki2019">Mia Pihlajamäki, Arja Asikainen, Suvi Ignatius, Päivi Haapasaari and Jouni T. Tuomisto. Forage Fish as Food: Consumer Perceptions on Baltic Herring. Sustainability 2019, 11(16), 4298; https://doi.org/10.3390/su11164298</ref> The results of this survey where also used in another article ''Health effects of nutrients and environmental pollutants in Baltic herring and salmon: a quantitative benefit-risk assessment'' by the same group.<ref name="tuomisto2020">Tuomisto, J.T., Asikainen, A., Meriläinen, P., Haapasaari, P. Health effects of nutrients and environmental pollutants in Baltic herring and salmon: a quantitative benefit-risk assessment. BMC Public Health 20, 64 (2020). https://doi.org/10.1186/s12889-019-8094-1</ref>


== Question ==
== Question ==
Line 5: Line 12:


== 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>
* Model run with all the results of the article<ref name="pihlajamaki2019"/> [http://en.opasnet.org/en-opwiki/index.php?title=Special:RTools&id=B2jMOHfuUSmTjfrn 26.8.2018]
* Original questionnaire analysis results [http://en.opasnet.org/en-opwiki/index.php?title=Special:RTools&id=QaMJZqUX0cPaTfOF 13.3.2017]
* 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]
 
== 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 can be found from the link below (see Data).
 
=== Data ===
 
==== Questionnaire ====
 
Original datafile [[File:Goherr_fish_consumption.csv]].
 
{{hidden|
<t2b name="Questions in the Goherr questionnaire" index="Index,Full question" obs="Question" desc="Description" unit="-">
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|A derived variable
V156|2. How old are you? Age category SWE, DK, EST|Age category other|A derived variable
V157|Row number of respondent|Row|A derived variable
V158|Age category "18-45" or ">45"|Ages|A derived variable
V159|Original question converted to a number and .n added to name|Eat.fish.m|A derived variable
V160|Original question converted to a number and .n added to name|How.often.fish.n|A derived variable
V161|Original question converted to a number and .n added to name|Eat.salmon.n|A derived variable
V162|Original question converted to a number and .n added to name|Baltic.salmon.n|A derived variable
V163|Original question converted to a number and .n added to name|How.often.BS.n|A derived variable
V164|Original question converted to a number and .n added to name|How.much.BS.n|A derived variable
V165|Original question converted to a number and .n added to name|How.often.side.BS.n|A derived variable
V166|Original question converted to a number and .n added to name|How.much.side.BS.n|A derived variable
V167|Original question converted to a number and .n added to name|Better.availability.BS.n|A derived variable
V168|Original question converted to a number and .n added to name|Less.chemicals.BS.n|A derived variable
V169|Original question converted to a number and .n added to name|Eat.BH.n|A derived variable
V170|Original question converted to a number and .n added to name|How.often.BH.n|A derived variable
V171|Original question converted to a number and .n added to name|How.much.BH.n|A derived variable
V172|Original question converted to a number and .n added to name|How.often.side.BH.n|A derived variable
V173|Original question converted to a number and .n added to name|How.much.side.BH.n|A derived variable
V174|Original question converted to a number and .n added to name|Better.availability.BH.n|A derived variable
V175|Original question converted to a number and .n added to name|Less.chemicals.BH.n|A derived variable
</t2b>
}}
 
==== Assumptions ====
 
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)
change|1|fraction|-1 - -0.8|Decrease it to zero
change|2|fraction|-0.9 - -0.5|Decrease it to less than half
change|3|fraction|-0.6 - -0.1|Decrease it a bit
change|4|fraction|0|No effect
change|5|fraction|0.1 - 0.6|Increase it a bit
change|6|fraction|0.5 - 0.9|Increase it over by half
change|7|fraction|0.8 - 1.3|Increase it over to double
change|8|fraction|-0.3 - 0.3|Don't know
</t2b>
 
==== 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 11.7.2018 [http://en.opasnet.org/en-opwiki/index.php?title=Special:RTools&id=Fa8TMg6h8DbEmhjp]
* Model run 27.3.2019 with country codes DK EE FI SE [http://en.opasnet.org/en-opwiki/index.php?title=Special:RTools&id=6UJy6JKNE3EyNHEQ]
 
<rcode name="preprocess2" label="Preprocess (only for developers)">
# This code is Op_en7749/preprocess2 on page [[Goherr: Fish consumption study]]
 
library(OpasnetUtils)
 
objects.latest("Op_en6007", code_name = "webropol") # [[OpasnetUtils/Drafts]] webropol.convert, merge.questions
 
############# Data preprocessing
 
# Get the data either from Opasnet or your own hard drive.
 
#survey1 original fi_le: N:/Ymal/Projects/Goherr/WP5/Goherr_fish_consumption.csv
 
survey1 <- opasnet.csv(
  "5/57/Goherr_fish_consumption.csv",
  wiki = "opasnet_en", sep = ";", fill = TRUE, quote = "\""
)
#survey1 <- re#ad.csv(fi_le = "N:/Ymal/Projects/Goherr/WP5/Goherr_fish_consumption.csv",
#                  header=FALSE, sep=";", fill = TRUE, quote="\"")
 
# Data fi_le is converted to data.frame using levels at row 2121.
survey1 <- webropol.convert(survey1, 2121, textmark = ":Other open")
 
# Delete rows that are clearly overestimations
 
survey1 <- survey1[-c(636, 1465, 1865, 1876, 2062, 2088), ]
 
# Take the relevant columnames from the table on the page.
colnames(survey1) <- gsub(
  " ",  ".",
  opbase.data(
    "Op_en7749",
    subset = "Questions in the Goherr questionnaire")$Result[1:ncol(survey1)]
)
 
survey1$Row <- 1:nrow(survey1)
survey1$Weighting <- as.double(gsub(",",".", survey1$Weighting))
survey1$Ages <- factor(
  ifelse(as.numeric(as.character(survey1$Age)) < 46, "18-45",">45"),
  levels = c("18-45", ">45"), ordered = TRUE
)
survey1$Country <- factor(
  survey1$Country,
  levels=c("DK","EST","FI","SWE"),
  labels=c("DK","EE","FI","SE")
)
# Anonymize data
survey1$Postal.code <- NA
survey1$Age <- NA
 
# webropol.convert should put these in the right order but doesn't. So do it manually.
 
freqlist <- c(
  "less than once a year",
  "A few times a year",
  "1 - 3 times per month",
  "once a week",
  "2 - 4 times per week",
  "5 or more times per week"
)
 
amlist <- c(
  "1/6 plate or below (50 grams)",
  "1/3 plate (100 grams)",
  "1/2 plate (150 grams)",
  "2/3 plate (200 grams)",
  "5/6 plate (250 grams)",
  "full plate (300 grams)",
  "overly full plate (500 grams)"
  #  "Not able to estimate"
)
 
sidel <- c(
  "1/6 plate or below (50 grams)",
  "1/4 plate (100 grams)",
  "1/2 plate (150 grams)",
  "2/3 plate (200 grams)",
  "5/6 plate (250 grams)"
  #  "Not able to estimate"
)
 
fishamounts <- c(29,46:49,95:98)
colnames(survey1)[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(
  freqlist,
  c("Never", freqlist),
  amlist,
  c("Never", freqlist),
  sidel,
  c("Never", freqlist),
  amlist,
  c("Never", freqlist),
  sidel
)
 
for (i in 1:length(fishamounts)) {
  survey1[[fishamounts[i]]] <- factor(survey1[[fishamounts[i]]], levels = ansl[[i]], ordered = TRUE)
}
 
oprint(head(survey1))
 
agel <- as.character(unique(survey1$Ages))
countryl <- sort(as.character(unique(survey1$Country)))
genderl <- sort(as.character(unique(survey1$Gender)))
fisl <- c("Salmon", "Herring")
 
# Interesting fish eating questions
surv <- c(1,3,158,16,29,30,31,46:49,75,80,86,95:98, 125, 130)
colnames(survey1[surv]) # Shown without .n
#[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"  "Better availability BS"
#[13] "Less chemicals BS"            "Eat Baltic herring"         
#[15] "How often Baltic herring"      "How much Baltic herring"     
#[17] "How often side Baltic herring" "How much side Baltic herring"
#[19] "Better availability BH"        "Less chemicals BH"
 
# 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(survey1[surv[4:20]], as.numeric)))))
# BUT: there are so many missing values, that we just model BH and BS separately now.
 
# Take the key questions and treat them as numeric
 
temp <- as.data.frame(lapply(
  survey1[c(16,29,30,31,46:49,75,80,86,95:98, 125, 130)],
  FUN = function(x) as.integer(x)
)) # Coerce to integers
colnames(temp) <- paste(colnames(temp),"n",sep=".")
survey1 <- cbind(survey1,temp)
 
survey1[is.na(survey1$Eat.Baltic.herring.n) | survey1$Eat.Baltic.herring.n==3 , 14] <- 1 # I don't know --> No
 
# Logical variable for respondents that have eaten fish, Baltic salmon, and Baltic herring
survey1$Eatfish <- survey1$Eat.fish == "Yes"
survey1$Eatsalm <- survey1$Baltic.salmon=="Yes" & !is.na(rowSums(survey1[162:166]))
survey1$Eatherr <- survey1$Eat.BH=="Yes" & !is.na(rowSums(survey1[169:173]))
 
oprint(table(survey1[c("Eatsalm", "Eatherr", "Eatfish")], useNA = "ifany"))
 
# Oletetaan, että covarianssimatriisi on vakio kaikille maille ja sukupuolille yms
# mutta keskiarvo on spesifi näille ja kysymykselle.
 
agel
countryl
genderl
fisl
 
objects.store(survey1, surv, agel, countryl, genderl, fisl)
cat("Data.frame survey1 and vectors agel, countryl, genderl and fisl were stored.\n")
</rcode>
 
=== Analyses ===
 
* Sketches about modelling determinants of eating (spring 2018) [http://en.opasnet.org/en-opwiki/index.php?title=Benefit-risk_assessment_of_Baltic_herring_and_salmon_intake&oldid=41947#Sketches_about_modelling_determinants_of_eating]
 
==== Figures, tables and stat analyses for the first manuscript ====
 
* Model run 8.5.2019 with thlVerse code (not run on Opasnet) [http://en.opasnet.org/en-opwiki/index.php?title=Special:RTools&id=46qKuh08I7PHqXRX] [http://en.opasnet.org/en-opwiki/index.php?title=Special:RTools&id=lnq3yNAPXAJFxwaG]
* Model run 26.8.2018 with fig 6 as table [http://en.opasnet.org/en-opwiki/index.php?title=Special:RTools&id=B2jMOHfuUSmTjfrn]
* Previous model runs are [http://en.opasnet.org/en-opwiki/index.php?title=Goherr:_Fish_consumption_study&oldid=42828#Figures.2C_tables_and_stat_analyses_for_the_first_manuscript archived].
 
Methodological concerns:
* [https://stackoverflow.com/questions/12953045/warning-non-integer-successes-in-a-binomial-glm-survey-packages Is the warning in logistic regression important?]
* [https://stats.stackexchange.com/questions/46345/how-to-calculate-goodness-of-fit-in-glm-r Goodness of fit in logistic regression]
* [https://stats.stackexchange.com/questions/8661/logistic-regression-in-r-odds-ratio Calculate odds ratios in logistic regression]
* [https://www3.nd.edu/~rwilliam/stats3/ordinalindependent.pdf You might treat independent ordinal variables as continuous]
* [https://www.color-blindness.com/coblis-color-blindness-simulator/ Color blindness simulator to adjust colors for the color blind and for black and white printing]
 
<rcode graphics=1>
# This is code Op_en7749/ on page [[Goherr: Fish consumption study]]
 
library(OpasnetUtils)
library(ggplot2)
library(reshape2)
library(MASS)
#library(extrafont) # Needed to save Arial fonts to PDF or EPS
#library(thlVerse)
#library(car)
#library(vegan)
 
BS <- 24
localcomp <- FALSE
thl <- FALSE
 
# Set colours
 
#library(thlVerse)
#library(tidyverse)
#colors <- c(
#  thlColors(6,"quali","bar",thin=0.8),
#  thlColors(6,"quali","bar",thin=1)
#)[c(1,8,3,10,11,6)]
#ggplot(tibble(A=as.character(1:6),B=1),aes(x=A,weight=B,fill=A))+
#  geom_bar()+
#  scale_fill_manual(values=colors)
 
colors <- c("#74AF59FF","#2F62ADFF","#D692BDFF","#29A0C1FF","#BE3F72FF","#FBB848FF")
 
########################## Functions
 
#### thlLinePlot was adjusted to enable different point shapes
 
thlLinePlot <- function (data, xvar, yvar, groupvar = NULL, ylabel = yvar,
                        xlabel = NULL, colors = thlColors(n = 12, type = "quali",
                                                          name = "line"), title = NULL, subtitle = NULL, caption = NULL,
                        legend.position = "none", base.size = 16, linewidth = 3,
                        show.grid.x = FALSE, show.grid.y = TRUE, lang = "fi", ylimits = NULL,
                        marked.treshold = 10, plot.missing = FALSE, xaxis.breaks = waiver(),
                        yaxis.breaks = waiver(), panels = FALSE, nrow.panels = 1,
                        labels.end = FALSE)
{
  lwd <- thlPtsConvert(linewidth)
  gg <- ggplot(data, aes_(x = substitute(xvar), y = substitute(yvar),
                          group = ifelse(!is.null(substitute(groupvar)), substitute(groupvar),
                                        NA), colour = ifelse(!is.null(substitute(groupvar)),
                                                              substitute(groupvar), ""))) + geom_line(size = lwd)
  if (isTRUE(plot.missing)) {
    df <- thlNaLines(data = data, xvar = deparse(substitute(xvar)),
                    yvar = deparse(substitute(yvar)), groupvar = unlist(ifelse(deparse(substitute(groupvar)) !=
                                                                                  "NULL", deparse(substitute(groupvar)), list(NULL))))
    if (!is.null(df)) {
      gg <- gg + geom_line(data = df, aes_(x = substitute(xvar),
                                          y = substitute(yvar), group = ifelse(!is.null(substitute(groupvar)),
                                                                                substitute(groupvar), NA), colour = ifelse(!is.null(substitute(groupvar)),
                                                                                                                          substitute(groupvar), "")), linetype = 2,
                          size = lwd)
    }
  }
  if (!is.null(marked.treshold)) {
    if (length(unique(data[, deparse(substitute(xvar))])) >
        marked.treshold) {
      if (is.factor(data[, deparse(substitute(xvar))]) ||
          is.character(data[, deparse(substitute(xvar))]) ||
          is.logical(data[, deparse(substitute(xvar))])) {
        levs <- levels(factor(data[, deparse(substitute(xvar))]))
        min <- levs[1]
        max <- levs[length(levs)]
      }
      else {
        min <- min(data[, deparse(substitute(xvar))])
        max <- max(data[, deparse(substitute(xvar))])
      }
      subdata <- data[c(data[, deparse(substitute(xvar))] %in%
                          c(min, max)), ]
      gg <- gg + geom_point(data = subdata, aes_(
        x = substitute(xvar),
        y = substitute(yvar),
        group = ifelse(!is.null(substitute(groupvar)), substitute(groupvar), NA),
        colour = ifelse(!is.null(substitute(groupvar)), substitute(groupvar), ""),
        shape = substitute(groupvar)),
        fill = "white",
        stroke = 1.35 * lwd,
        size = 10/3 * lwd)+scale_shape_manual(values=21:25)
    }
    else {
      gg <- gg + geom_point(
        aes_(
          shape = substitute(groupvar)
        ),
        fill = "white",
        stroke = 1.35 * lwd,
        size = 10/3 * lwd)+scale_shape_manual(values=21:25)
    }
  }
  if (isTRUE(labels.end)) {
    if (is.factor(data[, deparse(substitute(xvar))]) ||
        is.character(data[, deparse(substitute(xvar))]) ||
        is.logical(data[, deparse(substitute(xvar))])) {
      levs <- levels(factor(data[, deparse(substitute(xvar))]))
      maxd <- data[data[, deparse(substitute(xvar))] ==
                    levs[length(levs)], ]
    }
    else {
      maxd <- data[data[, deparse(substitute(xvar))] ==
                    max(data[, deparse(substitute(xvar))]), ]
    }
    brks <- maxd[, deparse(substitute(yvar))]
    labsut <- maxd[, deparse(substitute(groupvar))]
  }
  else (brks <- labsut <- waiver())
  gg <- gg + ylab(ifelse(deparse(substitute(ylabel)) == "yvar",
                        deparse(substitute(yvar)), ylabel)) + labs(title = title,
                                                                    subtitle = subtitle, caption = caption) + thlTheme(show.grid.y = show.grid.y,
                                                                                                                      show.grid.x = show.grid.x, base.size = base.size, legend.position = legend.position,
                                                                                                                      x.axis.title = ifelse(!is.null(xlabel), TRUE, FALSE)) +
    xlab(ifelse(!is.null(xlabel), xlabel, "")) + scale_color_manual(values = colors) +
    thlYaxisControl(lang = lang, limits = ylimits, breaks = yaxis.breaks,
                    sec.axis = labels.end, sec.axis.breaks = brks, sec.axis.labels = labsut)
  if (is.factor(data[, deparse(substitute(xvar))]) || is.character(data[,
                                                                        deparse(substitute(xvar))]) || is.logical(data[, deparse(substitute(xvar))])) {
    gg <- gg + scale_x_discrete(breaks = xaxis.breaks, expand = expand_scale(mult = c(0.05)))
  }
  else (gg <- gg + scale_x_continuous(breaks = xaxis.breaks))
  if (isTRUE(panels)) {
    fmla <- as.formula(paste0("~", substitute(groupvar)))
    gg <- gg + facet_wrap(fmla, scales = "free", nrow = nrow.panels)
  }
  gg
}
 
groups <- function(o) {
  o$Group <- paste(o$Gender, o$Ages)
  o$Group <- factor(o$Group, levels = c(
    "Female 18-45",
    "Male 18-45",
    "Female >45",
    "Male >45"
  ))
  return(o)
}
 
#' @title reasons produces a ggplot object for a graph that shows fractions of reasons mentioned in the data.
#' @param dat a data.frame containing survey answers for the target subgroup.
#' @param title an atomic string with the name to be shown as the title of graph
#' @return ggplot object
 
reasons <- function(
  dat,
  title
) {
  require(reshape2)
  weight <- Ovariable("weight",data=data.frame(
    Row=dat$Row,
    Result=dat$Weight
  ))
  levels(dat$Country) <- paste0(
    levels(dat$Country), " (n=",
    aggregate(dat$Country, dat["Country"], length)$x, ")"
  )
  tmp <- melt(
    dat[setdiff(colnames(dat),"Weighting")],
    id.vars = c("Country","Row"),
    variable.name ="Reason",
    value.name="Result"
  )
  tmp$Result <- (tmp$Result %in% c("Yes","1"))*1
  tmp <- weight * (Ovariable("tmp",data=tmp))
  cat(title, ": number of individual answers.\n")
  oprint(oapply(tmp, c("tmpResult","Country"),length)@output)
 
  tmp <- (oapply(tmp, c("Country","Reason"), sum)/oapply(tmp, "Country",sum))
  popu <- oapply(tmp, "Reason",sum)@output
  popu <- popu$Reason[order(popu$Result)]
  tmp$Reason <- factor(tmp$Reason, levels=popu)
  levels(tmp$Reason) <- gsub("( BH| BS)", "", gsub("\\.", " ", levels(tmp$Reason)))
  cat(title, ": fractions shown on graph.\n")
  oprint(tmp@output)
 
  if(thl) {
    tmp <- thlLinePlot(tmp@output, xvar=Reason, yvar=Result,groupvar=Country,
                      colors= c("#519B2FFF", "#2F62ADFF", "#BE3F72FF","#88D0E6FF"), # #29A0C1FF"),
                      # THL colors but fourth is brigter
                      legend.position = c(0.85,0.2), base.size = BS, title=title,
                      subtitle="Fraction of population")+
      coord_flip()+
      scale_y_continuous(labels=scales::percent_format(accuracy=1))
  } else {
    tmp <- ggplot(tmp@output, aes(x=Reason, y=Result,colour=Country, group=Country))+
      geom_point(shape=21, size=5, fill="Grey", stroke=2)+
      geom_line(size=1.2)+
      coord_flip()+
      theme_gray(base_size=BS)+
      scale_y_continuous(labels=scales::percent_format())+#accuracy=1))+
      scale_colour_manual(values=colors)+
      labs(
        title=title,
        x="Answer",
        y="Fraction of population")
  }
  return(tmp)
}
 
#' @title Function impacts produces a graph showing the magnitude of impact if some things change
#' @param dat data.frame containing answers
#' @param title string to be used as the title of the graph
#' @param population ovariable of country population weights
#' @return ggplot object
 
impacts <- function(dat,title, population) {
  tmp <- melt(
    dat,
    id.vars = c("Country","Weighting"),
    variable.name ="Reason",
    value.name="Response"
  )
  tmp$Response <- factor(
    tmp$Response,
    levels=c(
      "I don't know",
      "Increase it over to double",
      "Increase it over by half",
      "Increase it a bit",
      "No effect",
      "Decrease it a bit",
      "Decrease it to less than half",
      "Decrease it to zero"
    ),
    ordered=TRUE
  )
  levels(tmp$Response)[levels(tmp$Response) %in% c(
    "Decrease it to zero",
    "Decrease it to less than half",
    "Decrease it a bit"
  )] <- "Decrease"
  levels(tmp$Response)[levels(tmp$Response) %in% c(
    "Increase it a bit",
    "Increase it over by half",
    "Increase it over to double"
  )] <- "Increase"
 
  colnames(tmp)[colnames(tmp)=="Weighting"] <- "Result"
  tmp <- Ovariable("tmp",data=tmp) * population
 
  popu <- aggregate(as.numeric(tmp$Response), tmp@output["Reason"],sum)
  popu <- popu$Reason[order(popu$x)]
  tmp$Reason <- factor(tmp$Reason, levels=popu)
  levels(tmp$Reason) <- gsub("( BH| BS)", "", gsub("\\.", " ", levels(tmp$Reason)))
 
  tmp <- (oapply(tmp, c("Reason","Response"), sum)/
            oapply(tmp, c("Reason"),sum))
 
  oprint(tmp@output)
 
  print(ggplot(tmp@output,
              aes(x=Reason, weight=Result, fill=Response))+geom_bar()+
          coord_flip()+#facet_grid(.~Country)+
          theme_gray(base_size=BS)+
          theme(legend.position = "bottom")+
          scale_fill_manual(values=c("Grey",colors[c(1,6,5)]))+
          scale_y_continuous(breaks=c(0.5,1),labels=scales::percent_format())+
          labs(
            title=title,
            x="Cause",
            y="Fraction of population"
          ))
 
  return(tmp@output)
}
 
#' @title or95 prints the odds ratio and 95 % confidence interval of a glm fit
#' @param fit a glm fit
#' @return data.frame with OR and 95%CI
 
or95 <- function(fit) {
  cat("Odds ratios with 95 % confidence intervals\n")
  tmp <- exp(cbind(coef(fit), confint(fit)))
  tmp <- data.frame(
    rownames(tmp),
    paste0(sprintf("%.2f",tmp[,1]), " (",sprintf("%.2f", tmp[,2]),"-",sprintf("%.2f",tmp[,3]),")")
  )
  colnames(tmp) <- c("Parameter","OR (95% CI)")
  return(tmp)
}
 
#' @title Perform and print regression analyses
#' @param dat data.frame with data
#' @param y name of column to be used as dependent variable
#' @param countries logical atom to tell whether to run country-specific analyses
#' @return returns the model fit object
 
printregr <- function(dat, y, title, countries = TRUE) {
 
  dat$y <- dat[[y]]
  cat("\n############### Logistic regression analysis:",title, "(", y, ")\n")
  fit <- glm(
    y ~ Ages + Gender + Country + as.numeric(Education) + as.numeric(Purchasing.power),
    family=binomial(),na.action="na.omit",weights=Weighting,
    data=dat
  )
  step <- stepAIC(fit, direction = "both")
  oprint(step$anova)
  oprint(summary(fit))
  oprint(or95(fit))
 
  if(countries) {
    for(i in unique(dat$Country)) {
      cat("\n#### Country-specific logistic regression analysis:", i, y, "\n")
      fit <- glm(
        Eat.fish ~ Ages + Gender + as.numeric(Education) + as.numeric(Purchasing.power),
        family=binomial(),na.action="na.omit",weights=Weighting,
        data=dat[dat$Country==i,]
      )
      step <- stepAIC(fit, direction = "both")
      oprint(step$anova)
      oprint(summary(fit))
      oprint(or95(fit))
    }
  }
  return(fit)
}
 
#################### Data for Figure 1.
 
if(thl) { # Commented out because needs package thlVerse.
 
  dat <- opbase.data("Op_en7749", subset="Fish consumption as food in Finland") # [[Goherr: Fish consumption study]]
  dat$Year <- as.numeric(as.character(dat$Year))
 
  gr <- thlLinePlot(
    dat[dat$Species=="Total",],
    xvar=Year,
    yvar=Result,
    ylimits=c(0,12),
    groupvar=Origin,
    base.size=24,
    title="Fish consumption in Finland",
    ylabel="",
    subtitle="(kg/a per person)",
    legend.position = "bottom"
  )
 
  if(localcomp) ggsave("Figure 1.pdf", width=8,height=6)
  if(localcomp) ggsave("Figure 1.png", width=8,height=6)
 
} # End if
################## Get data
 
objects.latest("Op_en7749", "preprocess2") # [[Goherr: Fish consumption study]]: survey1, surv
objects.latest("Op_en7749", "nonsamplejsp") # [[Goherr: Fish consumption study]]: jsp every respondent from data exactly once.
objects.latest("Op_en7749", "initiate") # [[Goherr: Fish consumption study]]: amount etc.
openv.setN(50)
survey1 <- groups(survey1)
#levels(survey1$Country) <- c("FI","SE","DK","EE") # WHY was this here? It is a potential hazard.
effinfo <- 0 # No policies implemented.
effrecomm <- 0
 
population <- EvalOutput(Ovariable(
  "population",
  ddata = "Op_en7748",
  subset = "Population"
))
levels(population$Country) <- c("DK","EE","FI","SE")
population <- oapply(population, c("Country"),sum)
 
amount <- EvalOutput(amount)
#result(amount)[result(amount)==0] <- 0.1 Not needed if not log-transformed.
amount <- amount * 365.25 / 1000 # g/day --> kg/year
 
#### General fish eating
 
su1 <- EvalOutput(Ovariable(
  "su1",
  data = data.frame(
    survey1[c("Country","Gender","Education","Purchasing.power")],
    Result=1
  )
))
 
# Figure 1. Origin of consumed fish in Finland between 1999 and 2016.
# Data not on this page, drawn separately.
 
# Table 1. Dimensions of embeddedness, modified from Hass (2007, p. 16)
# Written directly on the manuscript.
 
# Table 2: statistics of the survey population in each country (n, female %, education, purchasing power)
 
tmp <- round(t(data.frame(
  n = tapply(rep(1,nrow(survey1)), survey1$Country,sum),
  Females = tapply(survey1$Gender=="Female", survey1$Country,mean)*100,
  Old = tapply(survey1$Ages==">45", survey1$Country,mean)*100,
  PurcVlow = tapply(survey1$Purchasing.power=="Very low", survey1$Country,mean)*100,
  PurcLow = tapply(survey1$Purchasing.power=="Low", survey1$Country,mean)*100,
  PurcSuf = tapply(survey1$Purchasing.power=="Sufficient", survey1$Country,mean)*100,
  PurcGood = tapply(survey1$Purchasing.power=="Good", survey1$Country,mean)*100,
  PurcVgood = tapply(survey1$Purchasing.power=="Very good", survey1$Country,mean)*100,
  PurcExc = tapply(survey1$Purchasing.power=="Excellent", survey1$Country,mean)*100,
  EducPri = tapply(survey1$Education=="Primary education", survey1$Country,mean)*100,
  EducSec = tapply(survey1$Education=="Secondary education (gymnasium, vocational school or similar)", survey1$Country,mean)*100,
  EducCol = tapply(survey1$Education=="Lower level college education or similar", survey1$Country,mean)*100,
  EducHig = tapply(survey1$Education=="Higher level college education or similar", survey1$Country,mean)*100
)))
rownames(tmp) <- c(
  "Number of respondents",
  "Females (%)",
  ">45 years (%)",
  "Purchasing power: Very low (%)",
  "Low (%)",
  "Sufficient (%)",
  "Good (%)",
  "Very good (%)",
  "Excellent (%)",
  "Education: Primary education (%)",
  "Secondary education (%)",
  "Lower level college (%)",
  "Higher level college (%)"
)
oprint(tmp, digits=0)
 
cat("Weighted fraction of fish eaters\n")
tmp <- aggregate(survey1$Weighting, survey1[c("Eat.fish","Country")],FUN=sum)
oprint(aggregate(tmp$x, tmp["Country"],FUN=function(x) x[2]/sum(x)))
 
ggplot(survey1,
      aes(x=Eat.fish, weight=Weighting, group=Country), stat="count")+
  geom_bar(aes(y=..prop.., fill=Country), position="dodge")+
  theme_gray(base_size=BS)+
  scale_fill_manual(values=colors)+
  scale_y_continuous(labels=scales::percent_format())+
  labs(title="Fraction of fish eaters within population")
 
############## Answers to open questions
if(FALSE){
  cat("Number of open-ended answers per question and country\n")
 
  tmp <- survey1[c(1,3,27:28,36:37,44:45,60:61,71:72,83:84,93:94,109:110,121:122,133:134,154,157:158)]
  tmp <- reshape(
    tmp,
    varying=list(
      Condition = colnames(tmp)[grepl("other",tolower(colnames(tmp)))],
      Text = colnames(tmp)[grepl("open",colnames(tmp))]
    ),
    times = colnames(tmp)[grepl("other",tolower(colnames(tmp)))],
    direction="long"
  )
  tmp <- tmp[tmp$Why.not.fish.open!="" , ]
  oprint(table(tmp$time,tmp$Country))
  oprint(tmp)
} # End if(FALSE)
 
#### Baltic salmon
 
reasons(
  survey1[survey1$Eat.fish=="No"& !is.na(survey1$Eat.fish),c(1,17:26,154,157)], # 1 Country, 8 Why don't you eat fish
  "Reasons not to eat among fish non-consumers"
)
 
# Figure 5
 
cat("Figure 5 (to be converted to text)\n")
 
reasons(
  survey1[survey1$Eat.salmon=="Yes"& !is.na(survey1$Eat.salmon),c(1,31:36,154,157)], # 1 Country, 11 Which salmon species
  "Species used among salmon consumers"
)
 
reasons(
  survey1[survey1$Baltic.salmon=="Yes"& !is.na(survey1$Baltic.salmon),c(1,50:59,154,157)], # 1 Country, 17 Why Baltic salmon
  "Reasons to eat among Baltic salmon consumers"
)
 
if(localcomp) ggsave("Figure 5.pdf", width=10,height=5)
if(localcomp) ggsave("Figure 5.png", width=10,height=5)
 
reasons(
  survey1[survey1$Baltic.salmon=="No"& !is.na(survey1$Baltic.salmon),c(1,62:70,154,157)], # 1 Country, 18 Why not Baltic salmon
  "Reasons not to eat, Baltic salmon non-consumers"
)
 
if(localcomp) ggsave("Figure 6.pdf", width=10,height=5)
if(localcomp) ggsave("Figure 6.png", width=10,height=5)
 
impacts.sal <- impacts(
  survey1[survey1$Baltic.salmon=="Yes"& !is.na(survey1$Baltic.salmon),c(1,73:82,154)],
  "Effect on Baltic salmon consumption",
  population
)
 
####### Any herring
 
ggplot(survey1[survey1$Eat.fish=="Yes",],
      aes(x=Country, weight=Weighting, fill=Eat.herring))+geom_bar(position="fill")+
  coord_flip()+#facet_grid(.~Country)+
  theme_gray(base_size=BS)+
  theme(legend.position = "bottom")+
  scale_y_continuous(labels=scales::percent_format())+
  scale_fill_manual(values=colors)+
  labs(
    title="Any herring consumption",
    y="Fraction of fish consumers"
  )
 
####### Baltic herring
 
### Figure 2. Comparison of Baltic herring consumption habits.
 
survey1$What <- ifelse(is.na(survey1$Eat.BH), "Other fish", as.character(survey1$Eat.BH))
survey1$What <- factor(
  survey1$What,
  levels=(c("Yes","I don't know","No","Other fish")),
  labels=(c("Baltic herring","Some herring","Other herring","Other fish"))
)
 
tmp <- survey1[survey1$Eat.fish=="Yes",]
colnames(tmp)[colnames(tmp)=="Weighting"] <- "Result"
tmp <- EvalOutput(Ovariable("tmp", data=tmp))
tmp <- oapply(tmp, c("What","Country"), sum) / oapply(tmp,"Country",sum)
tmp$Country <- factor(tmp$Country, levels=rev(levels(tmp$Country)))
 
if(thl) {
  thlBarPlot(tmp@output, xvar=Country, yvar=Result, groupvar=What, horizontal = TRUE, stacked = TRUE,
            legend.position = "bottom",,
            title="Baltic herring consumption",
            subtitle="Fraction of fish consumers",
  )+
    scale_y_continuous(labels=scales::percent_format())
 
} else {
  ggplot(tmp@output, aes(x=Country, weight=Result, fill=What))+geom_bar(position="fill")+
    coord_flip()+#facet_grid(.~Country)+
    theme_gray(base_size=BS)+
    theme(legend.position = "bottom")+
    scale_y_continuous(labels=scales::percent_format())+
    scale_fill_manual(values=c("gray",colors))+
    guides(fill=guide_legend(reverse=TRUE))+
    labs(
      title="Baltic herring consumption",
      y="Fraction of fish consumers"
    )
 
}
 
if(localcomp) ggsave("Figure 2.pdf",width=10, height=5)
if(localcomp) ggsave("Figure 2.png",width=6, height=3)
 
tmp <- survey1[survey1$Eat.fish=="Yes",]
tmp <- aggregate(tmp$Weighting, tmp[c("What","Country")], sum)
 
rown <- tmp$What[tmp$Country=="FI"]
tmp <- aggregate(tmp$x, tmp["Country"],FUN=function(x) x/sum(x))
colnames(tmp[[2]]) <- rown
oprint(as.matrix(tmp))
 
 
ggplot(survey1[survey1$Eat.herring=="Yes",],
      aes(x=Country, weight=Weighting, fill=Eat.BH))+geom_bar(position="fill")+
  coord_flip()+#facet_grid(.~Country)+
  theme_gray(base_size=BS)+
  theme(legend.position = "bottom")+
  scale_y_continuous(labels=scales::percent_format())+
  scale_fill_manual(values=c(colors))+
  labs(
    title="Baltic herring consumption",
    y="Fraction of herring consumers"
  )
 
####### Any salmon
 
ggplot(survey1[survey1$Eat.fish=="Yes",],
      aes(x=Country, weight=Weighting, fill=Eat.salmon))+geom_bar(position="fill")+
  coord_flip()+
  theme_gray(base_size=BS)+
  theme(legend.position = "bottom")+
  scale_y_continuous(labels=scales::percent_format())+
  scale_fill_manual(values=colors)+
  labs(
    title="Any salmon consumption",
    y="Fraction of fish consumers"
  )
 
####### Baltic salmon
 
ggplot(survey1[survey1$Eat.fish=="Yes",],
      aes(x=Country, weight=Weighting, fill=Baltic.salmon))+geom_bar(position="fill")+
  coord_flip()+
  theme_gray(base_size=BS)+
  theme(legend.position = "bottom")+
  scale_y_continuous(labels=scales::percent_format())+
  scale_fill_manual(values=colors)+
  labs(
    title="Baltic salmon consumption",
    y="Fraction of fish consumers"
  )
 
ggplot(survey1[survey1$Eat.salmon=="Yes",],
      aes(x=Country, weight=Weighting, fill=Baltic.salmon))+geom_bar(position="fill")+
  coord_flip()+
  theme_gray(base_size=BS)+
  theme(legend.position = "bottom")+
  scale_y_continuous(labels=scales::percent_format())+
  scale_fill_manual(values=colors)+
  labs(
    title="Baltic salmon consumption",
    y="Fraction of salmon consumers"
  )
 
############## Recommendation awareness
 
levels(survey1$Recommendation.awareness) <- c("Not aware","Aware","Know content")
ggplot(survey1,
      aes(x=Country, weight=Weighting, fill=Recommendation.awareness))+geom_bar(position="fill")+
  coord_flip()+#facet_grid(.~Country)+
  theme_gray(base_size=BS)+
  theme(legend.position = "bottom")+
  scale_y_continuous(labels=scales::percent_format())+
  scale_fill_manual(values=colors)+
  labs(title="Awareness of food recommendations about Baltic fish")
 
# Figure 3. Percentages of reasons to eat Baltic herring
 
reasons(
  survey1[survey1$Eat.BH=="Yes"& !is.na(survey1$Eat.BH),c(1,99:108,154,157)], # 1 Country, 27 why Baltic herring
  "Reasons to eat among Baltic herring consumers"
)
 
if(localcomp) ggsave("Figure 3.pdf", width=10, height=5)
if(localcomp) ggsave("Figure 3.png", width=10, height=5)
 
# Figure 4. Reasons for not to eat Baltic herring.
# Denmark and Estonia were omitted because they had less than 20 observations.
 
reasons(
  survey1[
    survey1$Eat.BH=="No"&
      survey1$Country %in% c("FI","SE") &
      !is.na(survey1$Eat.BH),c(1,111:120,154,157)], # 1 Country, 28 Why not Baltic herring
  "Reasons not to eat, Baltic herring non-consumers"
)+scale_color_manual(values=c("#BE3F72FF","#88D0E6FF"))+
  scale_shape_manual(values=23:24)
 
if(localcomp) ggsave("Figure 4.pdf", width=10, height=5)
if(localcomp) ggsave("Figure 4.png", width=10, height=5)
 
# Figure 7. The role of different determinants on Baltic salmon consumption
 
impacts.herr <- impacts(
  survey1[survey1$Eat.BH=="Yes"& !is.na(survey1$Eat.BH),c(1,123:132,154)], # 1 Country, 29 Influence of Baltic herring policies
  title="Effect on Baltic herring consumption",
  population
)
 
tmp <- rbind(
  data.frame(
    Fish="Herring",
    impacts.herr
  ),
  data.frame(
    Fish="Salmon",
    impacts.sal
  )
)
 
oprint(aggregate(tmp$Result,tmp[c("Reason","Response","Fish")],sum))
 
if(thl) {
  tmp$Response <- factor(tmp$Response, levels=rev(levels(tmp$Response)))
  thlBarPlot(aggregate(tmp$Result,tmp[c("Reason","Response","Fish")],sum),
            xvar=Reason, yvar=x, groupvar=Response, legend.position = "bottom",
            horizontal = TRUE, stacked = TRUE,
            base.size = BS, title="Effect on Baltic fish consumption",
            subtitle="Fraction of population")+
    facet_grid(.~Fish)+
    scale_fill_manual(values=rev(c("gray",colors[c(1,6,5)])))+
    scale_y_continuous(breaks=c(0.5,1),labels=scales::percent_format(accuracy=1))
    
    
} else {
  ggplot(tmp, aes(x=Reason, weight=Result, fill=Response))+geom_bar()+
    coord_flip()+facet_grid(.~Fish)+
    theme_gray(base_size=BS)+
    theme(legend.position = "bottom")+
    scale_fill_manual(values=c("gray",colors[c(1,6,5)]))+
    scale_y_continuous(breaks=c(0.5,1),labels=scales::percent_format())+#accuracy=1))+
    guides(fill=guide_legend(reverse=TRUE))+
    labs(
      title="Effect on Baltic fish consumption",
      x="Cause",
      y="Fraction of population"
    )
}
if(localcomp) ggsave("Figure 7.pdf", width=12, height=7)
if(localcomp) ggsave("Figure 7.png", width=12, height=7)
######### Amounts estimated for each respondent
amount <- groups(amount)
#tmp <- amount*info
#tmp <- tmp[
#  tmp$Info.improvements=="BAU" &
#    tmp$Recomm.herring=="BAU" &
#    tmp$Recomm.salmon=="BAU" ,
#  ]
tmp <- cbind(
  oapply(amount, c("Country","Group","Gender","Ages","Fish"), FUN=mean)@output,
  SD=oapply(amount, c("Country","Group","Gender","Ages","Fish"), FUN=sd)$amountResult
)
# Figure 3 (old, unused). Average consumption (kg/year) of Baltic herring in four countries,
# calculated with Monte Carlo simulation (1000 iterations).
ggplot(tmp[tmp$Fish=="Herring",], aes(x=Group, weight=amountResult, fill=Group))+
  geom_bar()+facet_wrap(~Country)+
  theme_gray(base_size=BS)+
  scale_fill_manual(values=colors)+
  guides(fill=FALSE)+
  theme(axis.text.x = element_text(angle = -90))+
  labs(
    title="Baltic herring consumption in subgroups",
    y="Average consumption (kg/year)")
# if(localcomp) ggsave("Figure3.pdf", width=9, height=10)
# if(localcomp) ggsave("Figure3.png", width=9, height=10)
tmp$Result <- paste0(sprintf("%.1f",tmp$amountResult), " (",sprintf("%.1f", tmp$SD,1),")")
tmp <- reshape(tmp, v.names="Result", timevar="Country", idvar=c("Fish","Group"),drop=c("Gender","Ages","amountResult","SD"), direction="wide")
colnames(tmp) <- gsub("Result\\.", "", colnames(tmp))
cat("Average fish consumption in subgroups, mean (sd)\n")
oprint(tmp)
weight <- EvalOutput(Ovariable("weight",data=data.frame(
  amount@output[c("Row","Iter","Fish","Country")],
  Result=amount$Weighting
)))
tmp <- (oapply(amount * weight, c("Fish","Country"), sum) / oapply(weight,c("Fish","Country"), sum))@output
cat("Average fish consumption per country (kg/year)\n")
oprint(tmp)
result(amount)[result(amount)==0] <- 0.1
ggplot(amount@output, aes(x=amountResult, colour=Group))+stat_ecdf()+scale_x_log10()+
  facet_wrap(~Fish)
############################
#### Statistical analyses
dat <- merge(survey1,amount@output) # [amount$Fish=="Herring",]) # This results in 50 * 2 times of rows
# These should be corrected to preprocess2. NOT ordered.
dat$Country <- factor(dat$Country, ordered=FALSE)
dat$Ages <- factor(dat$Ages, ordered=FALSE)
dat$Gender <- factor(dat$Gender, ordered=FALSE)
ggplot(dat, aes(x=amountResult, weight=Weighting, color=Country))+stat_ecdf()+facet_wrap(~Fish)+
  scale_x_log10()
gro <- unique(dat$Group)
out <- list(data.frame(), data.frame())
for(i in unique(dat$Fish)) {
  for(j in unique(dat$Country)){
    for(k in unique(dat$Iter)) {
      res <- kruskal.test(amountResult ~ Group, data=dat[
        dat$Iter==k  & dat$Country==j & dat$Fish==i,])
      out[[1]] <- rbind(out[[1]], data.frame(
        test="Kruskal-Wallis",
        Fish=i,
        Country=j,
        Iter=k,
        p.value=res[[3]])
      )
      for(l in 1:(length(gro)-1)) {
        for(m in (l+1):length(gro)) {
          res2 <- wilcox.test(
            x=dat$amountResult[dat$Iter==k  & dat$Country==j & dat$Fish==i & dat$Group==gro[l]],
            y=dat$amountResult[dat$Iter==k  & dat$Country==j & dat$Fish==i & dat$Group==gro[m]], conf.int = FALSE)
          out[[2]] <- rbind(out[[2]], data.frame(
            Fish=i,
            Country=j,
            Iter=k,
            Pair1=gro[l],
            Pair2=gro[m],
            p.value = res2$p.value
          ))
        }
      }
    }
  }
}
ggplot(out[[1]], aes(x=paste(Fish, Country), y = p.value, colour = Country))+geom_jitter()+
  geom_hline(yintercept=0.05)+coord_flip()+theme_gray(base_size=BS)+
  labs(title="Kruskal-Wallis non-parametric test across all groups")
ggplot(out[[2]], aes(x=paste(Fish, Country), y=p.value, colour=Pair1, shape=Pair2))+geom_jitter()+
  geom_hline(yintercept=0.05)+coord_flip()+theme_gray(base_size=BS)+
  labs(title="Mann-Whitney U test across all pairs of groups")
cat("Kurskal-Wallis non-parametric test for 50 iterations of amount\n")
oprint(aggregate(out[[1]]["p.value"], out[[1]][c("Country","Fish")], mean))
cat("Mann-Whitney U non-parametric test for 50 iterations of amount\n")
oprint(aggregate(out[[2]]["p.value"], out[[2]][c("Pair1","Pair2","Country","Fish")], mean))
###################### Logistic regression
dat2 <- dat[dat$Iter==1 & dat$Fish=="Herring",]
tmp <- printregr(dat2, "Eat.fish", "What explains whether people eat fish at all?")
tmp <- printregr(dat2, "Eat.herring", "What explains whether people eat herring compared with other fish?")
dat2$Eat.BH2 <- ifelse(dat2$Eat.BH!="Yes" | is.na(dat2$Eat.BH),0,1)
tmp <- printregr(dat2, "Eat.BH2", "What explains whether people eat Baltic herring compared with everyone else?")
dat2$What2 <- ifelse(dat2$What=="Baltic herring",1,ifelse(dat2$What=="Other herring",0,NA))
tmp <- printregr(dat2, "What2", "What explains whether people eat Baltic herring compared with other herring?")
cat("###################### How fish-specific causes are explained by
    population determinants?\n")
for(j in c(
  "Tastes.good.BH",
  "Self.caught.BH",
  "Easy.to.cook.BH",
  "Quick.to.cook.BH",
  "Readily.available.BH",
  "Healthy.BH",
  "Inexpensive.BH",
  "Family.likes.it.BH",
  "Environmental.BH",
  "Traditional.BH"
)) {
  tmp <- printregr(dat2, j, "What explains the reason to eat Baltic herring?")
}
for(j in c(
  "Bad.taste.BH",
  "Not.used.to.BH",
  "Cannot.cook.BH",
  "Difficult.to.cook.BH",
  "Not.available.BH",
  "Health.risks.BH",
  "Better.for.feed.BH",
  "Quality.issues.BH",
  "Sustainability.BH",
  "Not.traditional.BH"
)) {
  tmp <- printregr(dat2, j, "What explains the reason to not eat Baltic herring?")
}
# tmp <- printregr(dat2, "Eat.salmon", "What explains whether people eat any salmon compared with other fish?")
# tmp <- printregr(dat2, "Baltic.salmon", "What explains whether people eat Baltic salmon compared with other salmon?")
</rcode>
Luke data about fish consumption in Finland [https://stat.luke.fi/en/fish-consumption-2017_en][http://statdb.luke.fi/PXWeb/pxweb/en/LUKE/LUKE__06%20Kala%20ja%20riista__06%20Muut__02%20Kalan%20kulutus/2_Kalankulutus.px/table/tableViewLayout1/?rxid=dc711a9e-de6d-454b-82c2-74ff79a3a5e0]
<t2b name="Fish consumption as food in Finland" index="Origin,Species,Year" locations="1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016,2017" unit="kg/a per person">
domestic fish|Total|6.1|6.1|5.9|6.2|5.8|5.3|5.2|5.0|5.0|4.4|4.5|4.3|3.8|3.8|3.8|4.0|4.1|4.1|4.1
domestic fish|Farmed rainbow trout|1.6|1.6|1.6|1.6|1.3|1.3|1.4|1.1|1.1|1.2|1.2|1.1|1.0|1.0|1.1|1.1|1.3|1.2|1.2
domestic fish|Baltic herring|0.8|1.2|1.1|1.1|0.9|0.8|0.7|0.5|0.4|0.4|0.4|0.3|0.3|0.3|0.3|0.3|0.3|0.3|0.3
domestic fish|Pike|0.8|0.7|0.7|0.7|0.6|0.7|0.7|0.8|0.7|0.6|0.6|0.6|0.5|0.4|0.4|0.5|0.5|0.4|0.4
domestic fish|Perch|0.7|0.7|0.7|0.7|0.6|0.6|0.6|0.7|0.7|0.5|0.5|0.5|0.4|0.4|0.4|0.5|0.5|0.4|0.4
domestic fish|Vendace|0.7|0.7|0.7|0.7|0.8|0.8|0.7|0.6|0.6|0.6|0.6|0.7|0.6|0.6|0.6|0.6|0.6|0.5|0.6
domestic fish|European whitefish|0.4|0.4|0.4|0.4|0.3|0.3|0.3|0.3|0.5|0.3|0.3|0.3|0.3|0.3|0.3|0.3|0.2|0.3|0.3
domestic fish|Pike perch|0.3|0.2|0.2|0.2|0.3|0.3|0.3|0.3|0.3|0.3|0.3|0.3|0.3|0.3|0.3|0.3|0.3|0.4|0.4
domestic fish|Other domestic fish|0.8|0.6|0.5|0.8|1.0|0.5|0.5|0.7|0.7|0.5|0.6|0.5|0.4|0.5|0.4|0.5|0.4|0.5|0.5
imported fish|Total|6.0|6.2|7.0|7.1|8.0|8.6|7.9|8.6|9.7|9.7|9.3|10.2|11.1|10.9|10.8|10.9|10.2|9.1|9.8
imported fish|Farmed rainbow trout|0.2|0.3|0.4|0.6|0.9|0.6|0.6|0.7|1.0|1.0|0.8|0.8|0.9|1.0|0.9|0.9|0.8|0.9|0.8
imported fish|Farmed salmon|1.0|0.9|1.2|1.3|1.6|2.2|1.9|2.0|2.7|2.6|2.9|3.1|3.9|4.2|4.0|4.4|4.1|3.5|4.0
imported fish|Tuna (prepared and preserved)|1.0|1.2|1.4|1.4|1.5|1.6|1.6|1.5|1.7|1.7|1.6|1.7|1.7|1.6|1.9|1.7|1.6|1.4|1.5
imported fish|Saithe (frozen fillet)|0.7|0.6|0.7|0.7|0.7|0.6|0.4|0.5|0.5|0.5|0.5|0.5|0.6|0.5|0.5|0.5|0.5|0.4|0.4
imported fish|Shrimps|0.5|0.4|0.5|0.5|0.5|0.5|0.5|0.5|0.6|0.6|0.6|0.7|0.7|0.6|0.6|0.5|0.5|0.4|0.4
imported fish|Herring and Baltic herring (preserved)|0.6|0.5|0.6|0.6|0.5|0.4|0.5|0.6|0.5|0.6|0.3|0.5|0.4|0.3|0.4|0.5|0.5|0.5|0.5
imported fish|Other imported fish|2.0|2.3|2.2|2.0|2.3|2.7|2.4|2.8|2.7|2.7|2.6|2.9|2.9|2.7|2.5|2.3|2.3|1.9|2.2
</t2b>
==== Descriptive statistics ====
[[File:Goherr survey correlations.png|thumb|300px|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
* [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(car)
library(vegan)


objects.latest("Op_en7749", "preprocess")
objects.latest("Op_en7749", "preprocess2") # [[Goherr: Fish consumption study]]: survey, surv
 
############################### From a previous code on Answer


for(i in c(5:6, 16, 29:30, 46:49, 85:86, 95:98, 135)) {
for(i in c(5:6, 16, 29:30, 46:49, 85:86, 95:98, 135)) {
   temp <- survey[!is.na(survey[[i]]),]
   temp <- survey[!is.na(survey[[i]]),]
    p <- ggplot(temp, aes(x = temp[[i]])) + geom_bar() +
  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)) +
     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)
     labs(title = colnames(temp[i])) + xlab("") + facet_wrap(~ Country)
Line 27: Line 1,370:
temp$Impact <- factor(temp$Impact, levels = levs, labels = levs, ordered = TRUE)
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)+
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))
   theme_gray(base_size = 24) + theme(axis.text.x=element_text(angle=90,hjust=1,vjust=0.4))


Line 33: Line 1,376:


temp <- melt(surveytemp, measure.vars = 38:43, variable.name = "Variable", value.name = "Value")
temp <- melt(surveytemp, measure.vars = 38:43, variable.name = "Variable", value.name = "Value")
ggplot(temp, aes(x = Value, fill = Country)) + geom_histogram(position = "dodge") + facet_wrap(~ Variable)+
ggplot(temp, aes(x = Value, fill = Country)) + geom_bar(position = "dodge") + facet_wrap(~ Variable)+
  theme_gray(base_size = 24) + labs(title = "Baltic salmon sources")
  theme_gray(base_size = 24) + labs(title = "Baltic salmon sources")


temp <- melt(surveytemp, measure.vars = 50:59, variable.name = "Variable", value.name = "Value")
temp <- melt(surveytemp, measure.vars = 50:59, variable.name = "Variable", value.name = "Value")
ggplot(temp, aes(x = Value, fill = Country)) + geom_histogram(position = "dodge") + facet_wrap(~ Variable)+
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")
  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")
temp <- melt(surveytemp, measure.vars = 73:82, variable.name = "Variable", value.name = "Value")
ggplot(temp, aes(x = Value, fill = Country)) + geom_histogram(position = "dodge") + facet_wrap(~ Variable)+
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")
  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")
surveytemp <- subset(survey, survey[[31]] == "No")


temp <- melt(surveytemp, measure.vars = 62:70, variable.name = "Variable", value.name = "Value")
temp <- melt(surveytemp, measure.vars = 62:70, variable.name = "Variable", value.name = "Value")
ggplot(temp, aes(x = Value, fill = Country)) + geom_histogram(position = "dodge") + facet_wrap(~ Variable)+
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")
  theme_gray(base_size = 24) + labs(title = "Reasons not to eat Baltic salmon")




Line 54: Line 1,397:


temp <- melt(surveytemp, measure.vars = 87:92, variable.name = "Variable", value.name = "Value")
temp <- melt(surveytemp, measure.vars = 87:92, variable.name = "Variable", value.name = "Value")
ggplot(temp, aes(x = Value, fill = Country)) + geom_histogram(position = "dodge") + facet_wrap(~ Variable)+
ggplot(temp, aes(x = Value, fill = Country)) + geom_bar(position = "dodge") + facet_wrap(~ Variable)+
  theme_gray(base_size = 24) + labs(title = "Baltic herring sources")
  theme_gray(base_size = 24) + labs(title = "Baltic herring sources")


temp <- melt(surveytemp, measure.vars = 99:108, variable.name = "Variable", value.name = "Value")
temp <- melt(surveytemp, measure.vars = 99:108, variable.name = "Variable", value.name = "Value")
ggplot(temp, aes(x = Value, fill = Country)) + geom_histogram(position = "dodge") + facet_wrap(~ Variable)+
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")
  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")
temp <- melt(surveytemp, measure.vars = 123:132, variable.name = "Variable", value.name = "Value")
ggplot(temp, aes(x = Value, fill = Country)) + geom_histogram(position = "dodge") + facet_wrap(~ Variable)+
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")
  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")
surveytemp <- subset(survey, survey[[86]] == "No")


temp <- melt(surveytemp, measure.vars = 111:120, variable.name = "Variable", value.name = "Value")
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)+
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")
  theme_gray(base_size = 24) + labs(title = "Reasons not to eat Baltic herring")


</rcode>
#####################################3


== Rationale ==
temp <- sapply(survey, as.numeric) # Can be done for surv to get a smaller matrix
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.
survey_correlations <- (cor(temp, method="spearman", use="pairwise.complete.obs"))
=== Data ===
Original datafile [[File:Goherr_fish_consumption.csv]]


==== Preprocessing ====
temp <- colnames(survey_correlations)
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)">
melted_correlations <- melt(survey_correlations)
library(OpasnetUtils)


############## Generic functions and objects are defined first.
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)


### webropol.convert converts a csv file from Webropol into a useful data.frame.
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")


webropol.convert <- function(
####################### Descriptive statistics
  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.
oprint(cor(surv, use = "pairwise.complete.obs"))
# First levels in levs have priority over others, if several levels apply to a row.
# --> Baltic salmon and herring eating are correlated, so they should be estimated together


merge.questions <- function(
oprint(table(surv[c(12,7,4)], useNA = "ifany"))
  dat, # data.frame with questionnaire data
oprint(table(surv[c(13,12)], useNA = "ifany"))
  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
############################# Plot original data


# Get the data either from Opasnet or your own hard drive.
# Eating frequencies of fish and Baltic salmon and herring with random noise, all
pl <- surv[surv$Eatfish,c(5,8,10,13,15)]
scatterplotMatrix(
  data.matrix(pl) + runif(nrow(pl)*ncol(pl), -0.5, 0.5)
)


#Survey original file: N:/Ymal/Projects/Goherr/WP5/Goherr_fish_consumption.csv
ggplot(data.frame(
  X = rep(1,5), Y = 5:1,
  legend = c("All", "Finland", "Sweden", "Denmark", "Estonia")
), aes(x=X, y=Y, label=legend))+
  geom_text()+
  labs(title="Fish eating questions with random noise")


survey <- opasnet.csv("5/57/Goherr_fish_consumption.csv", sep = ";", fill = TRUE, quote = "\"")
surcol <- t(survey[1,])


survey <- webropol.convert(survey, 2121, textmark = ":Other open") # Data file is converted to data.frame using levels at row 1269.
## Fish eating questions with some random noise, all
pl <- surv[surv$Eatfish,c(5,6,7,12)]
scatterplotMatrix(
  data.matrix(pl) + runif(nrow(pl)*ncol(pl), -0.5, 0.5)
)


# Take the relevant columnames from the table on the page.
## Fish eating questions with some random noise, FI
colframe <- opbase.data("Op_en7749", subset = "Questions in the Goherr questionnaire")
pl <- surv[surv$Country == 1 & surv$Eatfish,c(5,6,7,12)]
colnames(survey) <- colframe$Result
scatterplotMatrix(
  data.matrix(pl) + runif(nrow(pl)*ncol(pl), -0.5, 0.5)
)


survey$Row <- 1:nrow(survey)
## Fish eating questions with some random noise, SWE
survey$Weighting <- as.double(levels(survey$Weighting))[survey$Weighting]
pl <- surv[surv$Country == 2 & surv$Eatfish,c(5,6,7,12)]
survey$Ages <- ifelse(as.numeric(as.character(survey$Age)) < 46, "18-45",">45")
scatterplotMatrix(
  data.matrix(pl) + runif(nrow(pl)*ncol(pl), -0.5, 0.5)
)


freqlist <- c(
## Fish eating questions with some random noise, Dk
  "less than once a year",
pl <- surv[surv$Country == 3 & surv$Eatfish,c(5,6,7,12)]
  "A few times a year",
scatterplotMatrix(
  "1 - 3 times per month",
   data.matrix(pl) + runif(nrow(pl)*ncol(pl), -0.5, 0.5)
   "once a week",
  "2 - 4 times per week",
  "5 or more times per week"
)
)


amlist <- c(
## Fish eating questions with some random noise, EST
  "1/6 plate or below (50 grams)",
pl <- surv[surv$Country == 4 & surv$Eatfish,c(5,6,7,12)]
  "1/3 plate (100 grams)",
scatterplotMatrix(
   "1/2 plate (150 grams)",
   data.matrix(pl) + runif(nrow(pl)*ncol(pl), -0.5, 0.5)
  "2/3 plate (200 grams)",
  "5/6 plate (250 grams)",
  "full plate (300 grams)",
  "overly full plate (500 grams)"
#  "Not able to estimate"
)
)


sidel <- c(
## Baltic herring questions with some random noise
   "1/6 plate or below (50 grams)",
pl <- surv[surv$Eatherr,13:16]
  "1/4 plate (100 grams)",
scatterplotMatrix(
  "1/2 plate (150 grams)",
   data.matrix(pl) + runif(nrow(pl)*ncol(pl), -0.5, 0.5)
  "2/3 plate (200 grams)",
  "5/6 plate (250 grams)"
#  "Not able to estimate"
)
)


ansl <- list(
## Baltic salmon questions with some random noise
   `How often eat fish` = freqlist,
pl <- surv[surv$Eatsalm,8:11]
  `How often Baltic salmon` = c("Never", freqlist),
scatterplotMatrix(
  `How much Baltic salmon` = amlist,
   data.matrix(pl) + runif(nrow(pl)*ncol(pl), -0.5, 0.5)
  `How often side Baltic salmon` = c("Never", freqlist),
  `How much side Baltic salmon` = sidel,
  `How often Baltic herring` = c("Never", freqlist),
  `How much Baltic herring` = amlist,
  `How often side Baltic herring` = c("Never", freqlist),
  `How much side Baltic herring` = sidel
)
)


for (i in names(ansl)) {
##################### CORRELATION MATRIX
   survey[[i]] <- factor(survey[[i]], levels = ansl[[i]])
 
}
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")
 
############################### 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)),])
 
pcoa_caps <- capscale(t(answ) ~ 1, distance="euclidean") ##PCoA done
 
## Kuva koko hypoteeseista
 
colstr <- c("palevioletred1","royalblue1","seagreen1","violet","khaki2","skyblue", "orange")


objects.store(survey, surcol)
#hypo_sizes <- (5 - colMeans(answ))
cat("objects survey, surcol were stored.\n")
#leg_sizes <- c(4, 3, 2, 1, 0.01)


#pdf(file="pcoa_plot.pdf", height=6, width=7.5)
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>
</rcode>


Line 221: Line 1,550:
* 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. 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 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
* 13.2.2018 old model run but with new Opasnet [http://en.opasnet.org/en-opwiki/index.php?title=Special:RTools&id=flr56viVhZ0VzZQu]


<rcode name="bayes" label="Initiate Bayes model (for developers only)" graphics=1>
<rcode name="bayes" label="Initiate Bayes model (for developers only)" graphics=1>
Line 226: Line 1,566:


library(OpasnetUtils)
library(OpasnetUtils)
library(ggplot2)
library(reshape2)
library(reshape2)
library(rjags)
library(rjags)
library(car)
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
# Fish intake in humans
# Data from data.frame survey from page [[Goherr: Fish consumption study]]
# Data from data.frame survey from page [[Goherr: Fish consumption study]]
# Start with salmon questions 46:49 (amounts eaten)
# Some preprocessing should be moved away from this code.
# Model assumes that questionnaire data follows binomial distribution with parameter p and max value 9.
# p depends on country (4 groups), sex (2), age (2) that are known individually.
# We should test whether sex makes a difference or whether it can be omitted.
# Predicted p for each question, determined by the group, are produced from the bayes model.
# p is used to sample answers, which are then combined with estimates of amounts related to each answer.
# Total amount eaten of each fish per modelled individual is finally calculated.
objects.latest("Op_en7749", "preprocess") # [[Goherr: Fish consumption study]]: survey, surcol
# Interesting fish eating questions
surv <- survey[c(1,3,4,16,29,30,31,46:49,86,95:98,158)]
colnames(surv)
consume <- data.matrix(survey[c(
  "Baltic salmon",
  "Eat Baltic herring"
)])
consume <- 1 - (consume!=2 | is.na(consume)) # Yes=1, other=0
agel <- as.character(unique(survey$Ages))
countryl <- sort(as.character(unique(survey$Country)))
genderl <- sort(as.character(unique(survey$Gender)))
fisl <- c("Salmon", "Herring")
ans.sal <- survey[
    grep("Yes", survey[["Baltic salmon"]]) ,
    c(
      "How often Baltic salmon",
      "How much Baltic salmon",
      "How often side Baltic salmon",
      "How much side Baltic salmon",
      "Ages",
      "Country",
      "Gender"
    )]


ans.her <- survey[
objects.latest("Op_en7749", "preprocess2") # [[Goherr: Fish consumption study]]: survey, surv, ...
    grep("Yes", survey[["Eat Baltic herring"]]) ,
    c(
      "How often Baltic herring",
      "How much Baltic herring",
      "How often side Baltic herring",
      "How much side Baltic herring",
      "Ages",
      "Country",
      "Gender"
    )]
quesl <-    c(
  "How often",
  "How much",
  "How often side",
  "How much side",
  "Ages",
  "Country",
  "Gender"
)
colnames(ans.sal) <- quesl
colnames(ans.her) <- quesl
ans <- rbind(ans.sal, ans.her)


head(ans)
cat("Version with multivariate normal.\n")
qlen <-  c(7,7,7,5) # Number of options in each question


questionl <- colnames(ans.sal)
# Development needs:
questionl.her <- colnames(ans.her)
## Correlation between salmon.often and herring.often needs to be estimated.
 
## Gender, country and age-spesific values should be estimated.
agel
countryl
genderl
fisl


mod <- textConnection("
mod <- textConnection("
   model{
   model{
# Data1: Full questionnaire
     for(i in 1:S) {
     for(f in 1:2) { # Salmon or herring
       survs[i,1:4] ~ dmnorm(mus[], Omegas[,])
       for(i in 1:U) { # Full questionnaire
        consume[i,f] ~ dbern(p[f,ageU[i],countryU[i],genderU[i]])
      }
    }
# Data2: Those responses that reported either Baltic herring or salmon
    for(q in 1:Q) { # Q = # of fish-specific questions
      for(i in 1:S) { # S = # respondents who eat Baltic salmon or herring
        ans[i,q] ~ dbin(p2[fis[i],age[i],country[i],gender[i],q], qlen[q])
      }
     }
     }
# Priors (multidimensional)
     for(j in 1:H) {
     for(i in 1:A) { # Age groups
       survh[j,1:4] ~ dmnorm(muh[], Omegah[,])
       for(j in 1:C) { # Countries
        for(k in 1:G) { #Genders
          for(f in 1:2) { # Fish species
            p[f,i,j,k] ~ dbeta(1,1)
            for(q in 1:Q) { # Q = # of fish-specific questions
              p2[f,i,j,k,q] ~ dbeta(1,1)
              ans.pred[f,i,j,k,q] ~ dbin(p2[f,i,j,k,q], qlen[q])
            }
          }
        }
      }
     }
     }
    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[,])
   }
   }
")
")
Line 339: Line 1,605:
   mod,
   mod,
   data = list(
   data = list(
     U = nrow(surv),
     survs = surv[surv$Eatsalm,c(8:11)],
    Q = 4,
     S = sum(surv$Eatsalm),
    S = nrow(ans),
     survh = surv[surv$Eatherr,c(13:16)],
    consume = consume,
     H = sum(surv$Eatherr),
    ans = data.matrix(ans[1:4]) - 1, # Zero is the first option
     mu0 = rep(2,4),
    qlen = qlen-1, # Subtract 1 because starts from 0.
     S2 = diag(4)/100000,
    age = match(ans$Ages, agel),
     S3 = diag(4)/10000
    country = match(ans$Country, countryl),
     gender = match(ans$Gender, genderl),
     ageU = match(survey$Ages, agel),
    countryU = match(survey$Country, countryl),
     genderU = match(survey$Gender, genderl),
     fis = c(rep(1, nrow(ans.sal)), rep(2, nrow(ans.her))),
     A = length(agel),
     C = length(countryl),
    G = length(genderl)
   ),
   ),
   n.chains = 4,
   n.chains = 4,
Line 361: Line 1,618:


update(jags, 100)
update(jags, 100)
samps <- jags.samples(jags, c('ans.pred','p','p2'), 1000)
samps.j <- jags.samples(
#samps.coda <- coda.samples(jags, c('mu', 'pcd.pred', 'ans.pred'), 1000)
  jags,  
 
  c('mus', 'Omegas', 'anss.pred','muh','Omegah','ansh.pred'),  
ans.pred <- array(
  1000
   samps$ans.pred,  
)
  dim = c(length(fisl), length(agel), length(countryl), length(genderl), length(quesl), 1000, 4),  
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(
   dimnames = list(
    Fish = fisl,
     Question = 1:4,
    Age = agel,
    Country = countryl,
    Gender = genderl,
     Question = quesl,
     Iter = 1:1000,
     Iter = 1:1000,
     Seed = c("S1","S2","S3","S4")
     Parameter = c("mu","Omega1", "Omega2", "Omega3", "Omega4", "ans.pred"),
    Fish = c("Salmon", "Herring")
   )
   )
)
)


p.pred <- array(
# Mu for all questions about salmon
  samps$p,  
scatterplotMatrix(t(js[,,1,1]))
  dim = c(length(fisl), length(agel), length(countryl), length(genderl), 1000, 4),  
# All parameters for question 1 about salmon
  dimnames = list(
scatterplotMatrix(js[1,,,1])
    Fish = fisl,
# Same for herring
    Age = agel,
scatterplotMatrix(js[1,,,2])
    Country = countryl,
 
    Gender = genderl,
jsd <- melt(js)
    Iter = 1:1000,
#ggplot(jsd, aes(x=value, colour=Question))+geom_density()+facet_grid(Parameter ~ Fish)
    Seed = c("S1","S2","S3","S4")
#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)


p2.pred <- array(
######## fish.param contains expected values of the distribution parameters from the model
   samps$p2,
 
  dim = c(length(fisl), length(agel), length(countryl), length(genderl), length(quesl), 1000, 4),  
fish.param <- list(
   dimnames = list(
   mu = apply(js[,,1,], MARGIN = c(1,3), FUN = mean),
     Fish = fisl,
   Omega = lapply(
     Age = agel,
     1:2,
    Country = countryl,
     FUN = function(x) {
    Gender = genderl,
      solve(apply(js[,,2:5,], MARGIN = c(1,3,4), FUN = mean)[,,x])
    Question = quesl,
    } # solve matrix: precision->covariace
    Iter = 1:1000,
    Seed = c("S1","S2","S3","S4")
   )
   )
)
)


ansm <- melt(ans.pred)
objects.store(fish.param)
pm <- melt(p.pred)
cat("List fish.param stored.\n")
p2m <- melt(p2.pred)
</rcode>


scatterplotMatrix(t(ans.pred[1,1,,1,1,,1]))
==== Initiate ovariables ====


scatterplotMatrix(t(p2.pred[1,1,,1,1,,1]))
=====jsp taken directly from data WITHOUT salmpling=====
scatterplotMatrix(t(p2.pred[,1,3,1,1,,1]))
scatterplotMatrix(t(p2.pred[1,,3,1,1,,1]))
scatterplotMatrix(t(p2.pred[1,1,3,,1,,1]))
scatterplotMatrix(t(p2.pred[1,1,3,1,,,1]))


scatterplotMatrix(t(p.pred[1,1,,1,,1]))
<rcode name="nonsamplejsp" label="Initiate jsp from data without sampling (for developers only)" embed=1>
scatterplotMatrix(t(p.pred[,1,3,1,,1]))
# This is code Op_en7749/nonsamplejsp on page [[Goherr: Fish consumption study]]
scatterplotMatrix(t(p.pred[1,,3,1,,1]))
# The code produces amount esimates (jsp ovariable) directly from data rather than bayesian model or sampling.
scatterplotMatrix(t(p.pred[1,1,3,,,1]))


objects.store(ans.pred, p.pred, p2.pred)
library(OpasnetUtils)
cat("Arrays ans.pred (answer), p.pred (probability to eat), p2.pred (p of answer) stored.\n")
</rcode>


==== Calculations ====
jsp <- Ovariable(
  "jsp",
  dependencies = data.frame(Name="survey1", Ident="Op_en7749/preprocess2"), # [[Goherr: Fish consumption study]]
  formula = function(...) {
    require(reshape2)
   
    sur <- survey1[c(157,1,3,158,162:178,81,82,131,132,154)] # Removed, not needed:16,29,30?
   
    #colnames(sur)
    #[1] "Row"                      "Country"                  "Gender"                 
    #[4] "Ages"                    "Baltic.salmon.n"          "How.often.BS.n"         
    #[7] "How.much.BS.n"            "How.often.side.BS.n"      "How.much.side.BS.n"     
    #[10] "Better.availability.BS.n" "Less.chemicals.BS.n"      "Eat.BH.n"               
    #[13] "How.often.BH.n"          "How.much.BH.n"            "How.often.side.BH.n"   
    #[16] "How.much.side.BH.n"      "Better.availability.BH.n" "Less.chemicals.BH.n"   
    #[19] "Eatfish"                  "Eatsalm"                  "Eatherr"               
    #[22] "Recommended.BS"          "Not.recommended.BS"      "Recommended.BH"         
    #[25] "Not.recommended.BH"      "Weighting"             
   
    # Make sure that Row is kept separate from Iter because in the sampling version they are different.
    # sur contained columns Eat.fish, How.often.fish, Eat.salmon. Are these needed, as all other questions are melted? No
    # Columns 5-7 removed, so colnames list above does not match.
   
    colnames(sur)[5] <- "Eat.BS"
    colnames(sur) <- gsub("\\.n","",colnames(sur))
    sur[22:25] <- sapply(sur[22:25], as.numeric)
    sur <- melt(
      sur,
      id.vars=c(1:4,26),
      variable.name="Question",
      value.name="Result"
    )
    sur$Fish <- ifelse(grepl("BH",sur$Question),"Herring","Salmon")
    sur$Question <- gsub("\\.BS","",sur$Question)
    sur$Question <- gsub("\\.BH","",sur$Question)
   
    ########## If the missing values are not adjusted, they drop out in the next stage.   
    if(TRUE) {
      # The adjustments below probably should go to the preprocess2 code.
      sur$Result[sur$Question %in% c(
        "Better.availability",
        "Less.chemicals",
        "Recommended",
        "Not.recommended"
      ) & is.na(sur$Result)] <- 4 # If missing --> no change 
      sur$Result[is.na(sur$Result)] <- 1 # Replace missing values with 1. That will produce 0 g/d.
    }
   
    return(Ovariable(
      output = sur,
      marginal = colnames(sur) %in% c("Fish", "Iter", "Question")
    ))
  }
)


This code calculates how much (g/day) Baltic herring and salmon are eaten based on an Bayesian model build up based on the questionnaire data.
objects.store(jsp)
cat("Ovariable jsp with actual survey data: every respondent is kept in data without sampling.\n")
</rcode>


<rcode label="Calculate amount" name=calculate_amount embed=1 graphics=1 store=1>
===== Amount estimated from a bayesian model =====
# This is code Op_en7749/calculate_amount on page [[Goherr: Fish consumption study]]


objects.latest("Op_en7749", code_name = "bayes") #: ans.pred, p.pred, p2.pred
* Model run 24.5.2017 [http://en.opasnet.org/en-opwiki/index.php?title=Special:RTools&id=3UORzPwospQxp82h]


ql <- melt(ans.pred)
<rcode name="modeljsp" label="Initiate jsp from model (for developers only)">
# This is code Op_en7749/modeljsp on page [[Goherr: Fish consumption study]]


##Assumptions for amount and frequencies
library(OpasnetUtils)


assumptions <- opbase.data("Op_en7749.assumptions_for_calculations")
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)
  }
)


salmon_dishtimesassump <- Ovariable("salmon_dishtimesassump", data = assumptions[assumptions$Variable == "freq" , c("value", "Result")])
objects.store(jsp)
cat("Ovariable jsp stored.\n")
</rcode>


salmon_dishamountassump <- Ovariable("salmon_dishamountassump", data = assumptions[assumptions$Variable == "amdish" , c("value", "Result")])
===== Amount estimates directly from data rather than from a bayesian model =====


salmon_ingridient <- Ovariable("salmon_ingridient", data = assumptions[assumptions$Variable == "ingridient", ]["Result"])
* Initiation run 18.5.2017 [http://en.opasnet.org/en-opwiki/index.php?title=Special:RTools&id=crW1kboP72BN1JbK]
* Initiation run 24.2.2018: sampling from survey rather than each respondent once [http://en.opasnet.org/en-opwiki/index.php?title=Special:RTools&id=yJavDqd5zPUyt5pK]


salmon_sidetimesassump <- Ovariable("salmon_wholetimesassump", data = assumptions[assumptions$Variable == "freq" , c("value", "Result")])
<rcode name="surveyjsp" label="Initiate jsp from survey (for developers only)" embed=1>
# This is code Op_en7749/surveyjsp on page [[Goherr: Fish consumption study]]
# The code produces amount esimates (jsp ovariable) directly from data rather than bayesian model.


salmon_sideamountassump <- Ovariable("salmon_wholeamountassump", data = assumptions[assumptions$Variable == "amside" , c("value", "Result")])
library(OpasnetUtils)


##Build up the variables to calculate amount of Baltic salmon eating
jsp <- Ovariable(
  "jsp",
  dependencies = data.frame(Name="survey1", Ident="Op_en7749/preprocess2"), # [[Goherr: Food cunsumption study]]
  formula = function(...) {
    require(reshape2)
   
    sur <- survey1[
      sample(1:nrow(survey1), openv$N, replace=TRUE, prob=survey1$Weighting) ,
      c(157,1,3,158,162:178,81,82,131,132) # Removed, not needed:16,29,30?
      ]
    sur$Iter <- 1:openv$N
   
    #colnames(sur)
    #[1] "Row"                      "Country"                  "Gender"                 
    #[4] "Ages"                    "Baltic.salmon.n"          "How.often.BS.n"         
    #[7] "How.much.BS.n"            "How.often.side.BS.n"      "How.much.side.BS.n"     
    #[10] "Better.availability.BS.n" "Less.chemicals.BS.n"      "Eat.BH.n"               
    #[13] "How.often.BH.n"          "How.much.BH.n"            "How.often.side.BH.n"   
    #[16] "How.much.side.BH.n"      "Better.availability.BH.n" "Less.chemicals.BH.n"   
    #[19] "Eatfish"                  "Eatsalm"                  "Eatherr"               
    #[22] "Recommended.BS"          "Not.recommended.BS"      "Recommended.BH"         
    #[25] "Not.recommended.BH"      "Iter"                   
   
    # Make sure that Row is kept separate from Iter because in the sampling version they are different.
    # sur contained columns Eat.fish, How.often.fish, Eat.salmon. Are these needed, as all other questions are melted? No
    # Columns 5-7 removed, so colnames list above does not match.
   
    colnames(sur)[5] <- "Eat.BS"
    colnames(sur) <- gsub("\\.n","",colnames(sur))
    sur[22:25] <- sapply(sur[22:25], as.numeric)
    sur <- melt(
      sur,
      id.vars=c(1:4,26),
      variable.name="Question",
      value.name="Result"
    )
    sur$Fish <- ifelse(grepl("BH",sur$Question),"Herring","Salmon")
    sur$Question <- gsub("\\.BS","",sur$Question)
    sur$Question <- gsub("\\.BH","",sur$Question)
   
    # The adjustments below probably should go to the preprocess2 code.
    sur$Result[sur$Question %in% c(
      "Better.availability",
      "Less.chemicals",
      "Recommended",
      "Not.recommended"
    ) & is.na(sur$Result)] <- 4 # If missing --> no change 
    sur$Result[is.na(sur$Result)] <- 1 # Replace missing values with 1. That will produce 0 g/d.
   
    return(Ovariable(
      output = sur,
      marginal = colnames(sur) %in% c("Fish", "Iter", "Question")
    ))
  }
)


salmon_dishtimes <-  Ovariable("salmon_dishtimes", data = data.frame(
objects.store(jsp)
  subset(ql, ql$Fish == "Salmon" & ql$Question == "How often" & ql$Seed == "S1"),
cat("Ovariable jsp with actual survey data: a respondent is sampled for each iteration.\n")
  Result = 1
</rcode>
))


salmon_dishtimes@data$Question <- NULL
===== Initiate other ovariables =====


salmon_dishamount <- Ovariable("salmon_dishamount", data = data.frame(
* Code stores ovariables assump, often, much, oftenside, muchside, amount.
  subset(ql, ql$Fish == "Salmon" & ql$Question == "How much" & ql$Seed == "S1"),
* Model run 19.5.2017 [http://en.opasnet.org/en-opwiki/index.php?title=Special:RTools&id=FauP3x6hviC4xWCD]
  Result = 1
* Initiation run 24.5.2017 without jsp [http://en.opasnet.org/en-opwiki/index.php?title=Special:RTools&id=6U3FWqVRaNumPcok]
)) #salmon with dish amount per one serving
* Model run 8.6.2017 [http://en.opasnet.org/en-opwiki/index.php?title=Special:RTools&id=euGolhOQvPqzQDvf]


salmon_dishamount@data$Question <- NULL 
<rcode name="initiate" label="Initiate ovariables (for developers only)" embed=1>
# This is code Op_en7749/initiate on page [[Goherr: Fish consumption study]]


salmon_sidetimes <- Ovariable("salmon_sidetimes", data = data.frame(
library(OpasnetUtils)
  subset(ql, ql$Fish == "Salmon" & ql$Question == "How often side" & ql$Seed == "S1"),
  Result = 1
)) #salmon as such times / year


salmon_sidetimes@data$Question <- NULL
# Combine modelled survey answers with estimated amounts and frequencies by:
# Rounding the modelled result and merging that with value in ovariable assump


salmon_sideamount <- Ovariable("salmon_sideamount", data = data.frame(
often <- Ovariable(
  subset(ql, ql$Fish == "Salmon" & ql$Question == "How much side" & ql$Seed == "S1"),
  "often",
  Result = 1
  dependencies = data.frame(
)) #salmon as whole amount per one serving
    Name=c("jsp","assump"),
    Ident=c("Op_en7749/surveyjsp","Op_en7749/initiate")
  ),
  formula = function(...) {
    out <- jsp[jsp$Question == "How.often" , ]
    out$Value <- round(result(out))
    out <- merge(
      assump@output[assump$Variable == "freq",],
      out@output
    )
    out <- out[!colnames(out) %in% c("Value", "Variable", "Result","Question")]
    colnames(out)[colnames(out) == "assumpResult"] <- "Result"
    return(out)
  }
)


salmon_sideamount@data$Question <- NULL
much <- Ovariable(
  "much",
  dependencies = data.frame(
    Name=c("jsp","assump"),
    Ident=c("Op_en7749/surveyjsp","Op_en7749/initiate")
  ),
  formula = function(...) {
    out <- jsp[jsp$Question == "How.much" , ]
    out$Value <- round(result(out))
    out <- merge(
      assump@output[assump$Variable == "amdish",],
      out@output
    )
    out <- out[!colnames(out) %in% c("Value", "Variable", "Result","Question")]
    colnames(out)[colnames(out) == "assumpResult"] <- "Result"
    return(out)
  }
)


amount <- Ovariable("amount",  
oftenside <- Ovariable(
                    dependencies = data.frame(Name = c(
  "oftenside",
                      "salmon_dishamount",
  dependencies = data.frame(
                      "salmon_dishamountassump",
    Name=c("jsp","assump"),
                      "salmon_ingridient",
    Ident=c("Op_en7749/surveyjsp","Op_en7749/initiate")
                      "salmon_dishtimes",
  ),
                      "salmon_dishtimesassump",
  formula = function(...) {
                      "salmon_sideamount",
    out <- jsp[jsp$Question == "How.often.side" , ]
                      "salmon_sideamountassump",
    out$Value <- round(result(out))
                      "salmon_sidetimes",
    out <- merge(
                      "salmon_sidetimesassump"
      assump@output[assump$Variable == "freq",],
                    )),
      out@output
                    formula = function(...) {
    )
                     
    out <- out[!colnames(out) %in% c("Value", "Variable", "Result","Question")]
                      out1 <- (salmon_dishamount * salmon_dishamountassump * salmon_ingridient)
    colnames(out)[colnames(out) == "assumpResult"] <- "Result"
                      out1@output$value <- NULL
    return(out)
                      out1 <- ((salmon_dishtimes * salmon_dishtimesassump) * out1) / 365
  }
                      out1@output$value <- NULL
                      out2 <- (salmon_sideamount * salmon_sideamountassump)
                      out2@output$value <- NULL
                      out2 <- ((salmon_sidetimes * salmon_sidetimesassump) * 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)
                    }
)
)


amountSalmon <- EvalOutput(amount, forceEval = TRUE, N = 1000)
muchside <- Ovariable(
  "muchside",
  dependencies = data.frame(
    Name=c("jsp","assump"),
    Ident=c("Op_en7749/surveyjsp","Op_en7749/initiate")
  ),
  formula = function(...) {
    out <- jsp[jsp$Question == "How.much.side" , ]
    out$Value <- round(result(out))
    out <- merge(
      assump@output[assump$Variable == "amside",],
      out@output
    )
    out <- out[!colnames(out) %in% c("Value", "Variable", "Result","Question")]
    colnames(out)[colnames(out) == "assumpResult"] <- "Result"
    return(out)
  }
)


temp <- amountSalmon@output
assump <- Ovariable(
temp <- aggregate(temp$amountResult, by=list(temp$Country, temp$Age, temp$Gender), FUN = mean)
  "assump",
colnames(temp) <- c("Country","Age","Gender","Salmon amount")
  ddata = "Op_en7749", subset = "Assumptions for calculations"
oprint(temp)
)


##Build up the variables to calculate amount of Baltic herring eating
effinfo <- Ovariable( # Effect of information
  "effinfo",
  dependencies = data.frame(
    Name=c("jsp","assump"),
    Ident=c("Op_en7749/surveyjsp","Op_en7749/initiate")
  ),
  formula = function(...) {
    away <- c("Value","Variable","Result","Question","assumpUnit","assumpSource","jspResult","jspSource")
    # Better availability of fish
    o1 <- jsp[jsp$Question == "Better.availability" , ]
    o1$Value <- round(result(o1))
    o1 <- merge(
      assump@output[assump$Variable == "change",],
      o1@output
    )
    colnames(o1)[colnames(o1)=="assumpResult"] <- "Better.availabilityResult"
    o1 <- Ovariable(name="Better.availability", output=o1[!colnames(o1) %in% away])
   
    # Less chemicals
    o2 <- jsp[jsp$Question == "Less.chemicals" , ]
    o2$Value <- round(result(o2))
    o2 <- merge(
      assump@output[assump$Variable == "change",],
      o2@output
    )
    colnames(o2)[colnames(o2)=="assumpResult"] <- "Less.chemicalsResult"
    o2 <- Ovariable(name="Less.chemicals", output=o2[!colnames(o2) %in% away])
   
    out <- (o1 + o2)@output
    return(Ovariable(output=out, marginal=colnames(out) %in% c("Iter","Fish")))
  }
)


herring_dishtimes <- Ovariable("herring_dishtimes", data = data.frame(
effrecommRaw <- Ovariable( # Effect of recommendations
   subset(ql, ql$Fish == "Herring" & ql$Question == "How often" & ql$Seed == "S1"),
  "effrecommRaw",
  Result = 1
  dependencies = data.frame(
))
    Name=c("jsp","assump"),
    Ident=c("Op_en7749/surveyjsp","Op_en7749/initiate")
  ),
   formula = function(...) {
    # Recommend more fish
    o1 <- jsp[jsp$Question == "Recommended" , ]
    o1$Value <- round(result(o1))
    o1 <- merge(
      assump@output[assump$Variable == "change",],
      o1@output
    )
    colnames(o1)[colnames(o1)=="assumpResult"] <- "Result"
    o1$Recommendation <- "Eat more"
   
    # Recommend less fish
    o2 <- jsp[jsp$Question == "Not.recommended" , ]
    o2$Value <- round(result(o2))
    o2 <- merge(
      assump@output[assump$Variable == "change",],
      o2@output
    )
    colnames(o2)[colnames(o2)=="assumpResult"] <- "Result"
    o2$Recommendation <- "Eat less"
   
    out <- rbind(o1, o2)[!colnames(o1) %in%
            c("Value","Variable","Question","assumpUnit","assumpSource","jspResult","jspSource")
]


herring_dishtimes@data$Question <- NULL
    return(Ovariable(output=out, marginal=colnames(out) %in% c("Iter","Fish","Recommendation")))
  },
  unit = "change of amount in fractions"
)


herring_dishamount <- Ovariable("herring_dishamount", data = data.frame(
# effrecommRaw and effrecomm are needed to enable decisions to affect the effect of recommendation before
  subset(ql, ql$Fish == "Herring" & ql$Question == "How much" & ql$Seed == "S1"),
# the ovariable is collapsed. So, target the decisions to effrecommRaw and collapses to effrecomm.
  Result = 1
)) #herring with dish amount per one serving


herring_dishamount@data$Question <- NULL 
effrecomm <- Ovariable(
  "effrecomm",
  dependencies = data.frame(Name="effrecommRaw"),
  formula = function(...) {
    return(effrecommRaw)
  }
)


herring_sidetimes <- Ovariable("herring_sidetimes", data = data.frame(
amountRaw <- Ovariable(
   subset(ql, ql$Fish == "Herring" & ql$Question == "How often side" & ql$Seed == "S1"),
  "amountRaw",
  Result = 1
  dependencies = data.frame(Name = c(
)) #herring as such times / year
    "often",
    "much",
    "oftenside",
    "muchside",
    "assump"
  )),
   formula = function(...) {
    away <- c(
      "assumpUnit",  
      "jspResult",
      "jspSource",
      "Variable",
      "Value",
      "Explanation"
    )
    often <- often[ , !colnames(often@output) %in% away]
    much <- much[ , !colnames(much@output) %in% away]
    oftenside <- oftenside[ , !colnames(oftenside@output) %in% away]
    muchside <- muchside[ , !colnames(muchside@output) %in% away]
    assump <- assump[assump$Variable == "ingredient", !colnames(assump@output) %in% away]
   
    out <- (often * much + oftenside * muchside * assump)/365 # g /d
    return(out)
  }
)


herring_sidetimes@data$Question <- NULL
amount <- Ovariable(
  "amount",
  dependencies = data.frame(Name = c(
    "amountRaw",
    "effinfo",
    "effrecomm"
  )),
  formula = function(...) {


herring_sideamount <- Ovariable("herring_sideamount", data = data.frame(
    out <- amountRaw * (1 + effinfo + effrecomm)
  subset(ql, ql$Fish == "Herring" & ql$Question == "How much side" & ql$Seed == "S1"),
    result(out)[result(out)<0] <- 0
   Result = 1
    result(out)[result(out)>100] <- 100
)) #herring as whole amount per one serving
    return(out)
   }
)


herring_sideamount@data$Question <- NULL
rm(wiki_username)
objects.store(list=ls())
cat("Ovariables", ls(), "stored.\n")
</rcode>


herring_dishtimesassump <- Ovariable("herring_dishtimesassump", data = assumptions[assumptions$Variable == "freq" , c("value", "Result")])
==== Other code ====


herring_dishamountassump <- Ovariable("herring_dishamountassump", data = assumptions[assumptions$Variable == "amdish" , c("value", "Result")])
This is code for analysing EFSA food intake data about fish for BONUS GOHERR manuscript Ronkainen L, Lehikoinen A, Haapasaari P, Tuomisto JT. 2019.


herring_ingridient <- Ovariable("herring_ingridient", data = assumptions[assumptions$Variable == "ingridient", ]["Result"])
<rcode>
################################
# This is code for analysing EFSA food intake data about fish for manuscript
# Ronkainen L, Lehikoinen A, Haapasaari P, Tuomisto JT. 2019


herring_sidetimesassump <- Ovariable("herring_wholetimesassump", data = assumptions[assumptions$Variable == "freq" , c("value", "Result")])
library(ggplot2)


herring_sideamountassump <- Ovariable("herring_wholeamountassump", data = assumptions[assumptions$Variable == "amside" , c("value", "Result")])
# Change the encoding from UCS-2 to UTF-8 first.
dat <- read.csv(
#  "C:/_Eivarmisteta/EFSA fish chronic intake.csv",
  "C:/_Eivarmisteta/EFSA herring salmon chronic intake.csv",
  header=TRUE, sep=",",dec=".",quote='\"'
)


amount <- Ovariable("amount",
#> colnames(dat)
                    dependencies = data.frame(Name = c(
#[1] "ï..Survey.s.country"     "Survey.start.year"      "Survey"               
                      "herring_dishamount",
#[4] "Population.Group..L2."  "pop.order"               "Exposure.hierarchy..L1."
                      "herring_dishamountassump",
#[7] "Number.of.subjects"     "Number.of.consumers"     "Mean"                  
                      "herring_ingridient",
#[10] "Standard.Deviation"     "X5th.percentile"         "X10th.percentile"      
                      "herring_dishtimes",
#[13] "Median"                 "X95th.percentile"        "X97.5th.percentile"   
                      "herring_dishtimesassump",
#[16] "X99th.percentile"        "Comment"               
                      "herring_sideamount",
                      "herring_sideamountassump",
                      "herring_sidetimes",
                      "herring_sidetimesassump"
                    )),
                    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_sideamount * herring_sideamountassump)
                      out2@output$value <- NULL
                      out2 <- ((herring_sidetimes * herring_sidetimesassump) * 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)
                    }
)


amountHerring <- EvalOutput(amount, forceEval = TRUE, N = 1000)
colnames(dat)[c(1,2,4,12)] <- c("Country","Year","Group","Fish")


temp <- amountHerring@output
#> levels(dat$Group)
temp <- aggregate(temp$amountResult, by=list(temp$Country, temp$Age, temp$Gender), FUN = mean)
#[1] "Adolescents"    "Adults"         "Elderly"         "Infants"         "Lactating women"
colnames(temp) <- c("Country","Age","Gender","Herring amount")
#[6] "Other children"  "Pregnant women"  "Toddlers"        "Very elderly" 
oprint(temp)


objects.store(amountHerring, amountSalmon)
levels(dat$Group) <- c("Children","Adults","Elderly","Children","Pregnant women",
cat("objects amountHerring, amountSalmon were stored.\n")
                      "Children","Pregnant women","Children","Elderly")
dat <- dat[dat$Fish !="Diadromous fish",] # Foodex2 level 7 entries
ggplot(dat,aes(x=Country, y=Mean, colour=Group))+
  geom_point()+coord_flip()+facet_wrap(~Fish, scales="free")+
  labs(title="Fish consumption in European countries",
      y="Average consumption (g/d)")
</rcode>
</rcode>


==== Assumptions ====
=== Dependencies ===
 
The following assumptions are used:
<t2b name="Assumptions for calculations" index="Variable,value,Explanation" obs="Result" unit="-">
freq|6|times per year|260 - 364
freq|5|times per year|104 - 208
freq|4|times per year|52
freq|3|times per year|12 - 36
freq|2|times per year|2 - 5
freq|1|times per year|0.5 - 0.9
freq|0|times per year|0
amdish|0|grams / serving|20 - 50
amdish|1|grams / serving|70 - 100
amdish|2|grams / serving|120 - 150
amdish|3|grams / serving|170 - 200
amdish|4|grams / serving|220 - 250
amdish|5|grams / serving|270 - 300
amdish|6|grams / serving|450 - 500
ingridient||fraction|0.1 - 0.3
amside|0|grams / serving|20 - 50
amside|1|grams / serving|70 - 100
amside|2|grams / serving|120 - 150
amside|3|grams / serving|170 - 200
amside|4|grams / serving|220 - 250
</t2b>
 
==== Questionnaire ====
 
{{hidden|
<t2b name="Questions in the Goherr questionnaire" index="Index,Full question" obs="Question" unit="-">
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 |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 ===
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 805: Line 2,151:


==Related files==
==Related files==
{{mfiles}}


{{publication
{{publication

Latest revision as of 15:39, 12 August 2020

Progression class
In Opasnet many pages being worked on and are in different classes of progression. Thus the information on those pages should be regarded with consideration. The progression class of this page has been assessed:
This page is reviewed
It has been read with a critical eye and commented on by an outside source, and given impairment suggestions have been included in the page. An equivalent to a peer-reviewed article.
The content and quality of this page is/was being curated by the project that produced the page.

The quality was last checked: 2019-08-26.



This page contains a detailed description about data management and analysis of an international survey related to scientific article Forage Fish as Food: Consumer Perceptions on Baltic Herring by Mia Pihlajamäki, Arja Asikainen, Suvi Ignatius, Päivi Haapasaari, and Jouni T. Tuomisto.[1] The results of this survey where also used in another article Health effects of nutrients and environmental pollutants in Baltic herring and salmon: a quantitative benefit-risk assessment by the same group.[2]

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

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)
21change1fraction-1 - -0.8Decrease it to zero
22change2fraction-0.9 - -0.5Decrease it to less than half
23change3fraction-0.6 - -0.1Decrease it a bit
24change4fraction0No effect
25change5fraction0.1 - 0.6Increase it a bit
26change6fraction0.5 - 0.9Increase it over by half
27change7fraction0.8 - 1.3Increase it over to double
28change8fraction-0.3 - 0.3Don't know

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 11.7.2018 [2]
  • Model run 27.3.2019 with country codes DK EE FI SE [3]

+ Show code

Analyses

  • Sketches about modelling determinants of eating (spring 2018) [4]

Figures, tables and stat analyses for the first manuscript

  • Model run 8.5.2019 with thlVerse code (not run on Opasnet) [5] [6]
  • Model run 26.8.2018 with fig 6 as table [7]
  • Previous model runs are archived.

Methodological concerns:

+ Show code

Luke data about fish consumption in Finland [8][9]

Fish consumption as food in Finland(kg/a per person)
ObsOriginSpecies1999200020012002200320042005200620072008200920102011201220132014201520162017
1domestic fishTotal6.16.15.96.25.85.35.25.05.04.44.54.33.83.83.84.04.14.14.1
2domestic fishFarmed rainbow trout1.61.61.61.61.31.31.41.11.11.21.21.11.01.01.11.11.31.21.2
3domestic fishBaltic herring0.81.21.11.10.90.80.70.50.40.40.40.30.30.30.30.30.30.30.3
4domestic fishPike0.80.70.70.70.60.70.70.80.70.60.60.60.50.40.40.50.50.40.4
5domestic fishPerch0.70.70.70.70.60.60.60.70.70.50.50.50.40.40.40.50.50.40.4
6domestic fishVendace0.70.70.70.70.80.80.70.60.60.60.60.70.60.60.60.60.60.50.6
7domestic fishEuropean whitefish0.40.40.40.40.30.30.30.30.50.30.30.30.30.30.30.30.20.30.3
8domestic fishPike perch0.30.20.20.20.30.30.30.30.30.30.30.30.30.30.30.30.30.40.4
9domestic fishOther domestic fish0.80.60.50.81.00.50.50.70.70.50.60.50.40.50.40.50.40.50.5
10imported fishTotal6.06.27.07.18.08.67.98.69.79.79.310.211.110.910.810.910.29.19.8
11imported fishFarmed rainbow trout0.20.30.40.60.90.60.60.71.01.00.80.80.91.00.90.90.80.90.8
12imported fishFarmed salmon1.00.91.21.31.62.21.92.02.72.62.93.13.94.24.04.44.13.54.0
13imported fishTuna (prepared and preserved)1.01.21.41.41.51.61.61.51.71.71.61.71.71.61.91.71.61.41.5
14imported fishSaithe (frozen fillet)0.70.60.70.70.70.60.40.50.50.50.50.50.60.50.50.50.50.40.4
15imported fishShrimps0.50.40.50.50.50.50.50.50.60.60.60.70.70.60.60.50.50.40.4
16imported fishHerring and Baltic herring (preserved)0.60.50.60.60.50.40.50.60.50.60.30.50.40.30.40.50.50.50.5
17imported fishOther imported fish2.02.32.22.02.32.72.42.82.72.72.62.92.92.72.52.32.31.92.2

Descriptive statistics

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. [11]
  • Model run 3.3.2017. p has more dimensions. [12]
  • Model run 25.3.2017. Several model versions: strange binomial+multivarnormal, binomial, fractalised multivarnormal [13]
  • Model run 27.3.2017 [14]
  • Other models except multivariate normal were archived and removed from active code 29.3.2017.
  • Model run 29.3.2017 with raw data graphs [15]
  • Model run 29.3.2017 with salmon and herring ovariables stored [16]
  • Model run 13.4.2017 with first version of coordinate matrix and principal coordinate analysis [17]
  • Model run 20.4.2017 [18] code works but needs a safety check against outliers
  • Model run 21.4.2017 [19] some model results plotted
  • Model run 21.4.2017 [20] ovariables produced by the model stored.
  • Model run 18.5.2017 [21] small updates
  • 13.2.2018 old model run but with new Opasnet [22]

+ Show code

Initiate ovariables

jsp taken directly from data WITHOUT salmpling

+ Show code

Amount estimated from a bayesian model
  • Model run 24.5.2017 [23]

+ Show code

Amount estimates directly from data rather than from a bayesian model
  • Initiation run 18.5.2017 [24]
  • Initiation run 24.2.2018: sampling from survey rather than each respondent once [25]

+ Show code

Initiate other ovariables
  • Code stores ovariables assump, often, much, oftenside, muchside, amount.
  • Model run 19.5.2017 [26]
  • Initiation run 24.5.2017 without jsp [27]
  • Model run 8.6.2017 [28]

+ Show code

Other code

This is code for analysing EFSA food intake data about fish for BONUS GOHERR manuscript Ronkainen L, Lehikoinen A, Haapasaari P, Tuomisto JT. 2019.

+ 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

  1. Jump up to: 1.0 1.1 Mia Pihlajamäki, Arja Asikainen, Suvi Ignatius, Päivi Haapasaari and Jouni T. Tuomisto. Forage Fish as Food: Consumer Perceptions on Baltic Herring. Sustainability 2019, 11(16), 4298; https://doi.org/10.3390/su11164298
  2. Tuomisto, J.T., Asikainen, A., Meriläinen, P., Haapasaari, P. Health effects of nutrients and environmental pollutants in Baltic herring and salmon: a quantitative benefit-risk assessment. BMC Public Health 20, 64 (2020). https://doi.org/10.1186/s12889-019-8094-1

Related files

Goherr: Fish consumption study. Opasnet . [29]. Accessed 15 May 2025.