Difference between revisions of "Goherr: Fish consumption study"
(technical edits) |
(→Initiate ovariables) |
||
(13 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
− | {{ | + | {{study|moderator=Arja|stub=Yes}} |
== Question == | == Question == | ||
Line 6: | Line 6: | ||
== Answer == | == Answer == | ||
+ | Original questionnaire analysis results | ||
+ | *[http://en.opasnet.org/en-opwiki/index.php?title=Special:RTools&id=QaMJZqUX0cPaTfOF 13.3.2017] {{comment|# |These should be presented somewhere|--[[User:Arja|Arja]] ([[User talk:Arja|talk]]) 07:39, 26 April 2017 (UTC)}} | ||
+ | Consumption amount estimates | ||
+ | * Model run 21.4.2017 [http://en.opasnet.org/en-opwiki/index.php?title=Special:RTools&id=xc0kaCs8cgzpjwo9] first distribution | ||
+ | * Model run 18.5.2017 [http://en.opasnet.org/en-opwiki/index.php?title=Special:RTools&id=YnuQMDJTQgW1Se5a with modelled data]; [http://en.opasnet.org/en-opwiki/index.php?title=Special:RTools&id=KXXFiP0aj0DYEPdx with direct survey data] | ||
+ | |||
+ | <rcode graphics=1 variables=" | ||
+ | name:usesurvey|description:Do you want to use directly the survey data rather than modelled data?|type:selection|options: | ||
+ | FALSE;No, use modelled data;TRUE;Yes, use survey data | ||
+ | "> | ||
+ | # This is code Op_en7749/ on page [[Goherr: Fish consumption study#Answer]] | ||
+ | |||
+ | library(OpasnetUtils) | ||
+ | library(ggplot2) | ||
+ | |||
+ | objects.latest("Op_en7749", code_name="initiate") # [[Goherr: Fish consumption study]] ovariables | ||
+ | |||
+ | if(usesurvey) { | ||
+ | objects.latest("Op_en7749", code_name="surveyjsp") # jsp ovariable directly based on survey data (N=2217) | ||
+ | openv.setN(nrow(jsp@data)) | ||
+ | } | ||
+ | |||
+ | amount <- EvalOutput(amount) | ||
+ | |||
+ | if(usesurvey) { | ||
+ | oprint(summary(amount, marginals=c("Gender", "Country", "Fish","Ages"))) | ||
+ | |||
+ | print(ggplot(amount@output, aes(x=amountResult+0.1, colour=Country))+stat_ecdf()+scale_x_log10()+facet_wrap(~ Fish)+ | ||
+ | labs(x="Fish consumption (g /d)", y="Cumulative frequency")+theme_gray(base_size=24)) | ||
+ | print(ggplot(amount@output, aes(x=amountResult+0.1, colour=Ages))+stat_ecdf()+scale_x_log10()+facet_grid(Country ~ Fish)+ | ||
+ | labs(x="Fish consumption (g /d)", y="Cumulative frequency")+theme_gray(base_size=24)) | ||
+ | print(ggplot(amount@output, aes(x=amountResult+0.1, colour=Gender))+stat_ecdf()+scale_x_log10()+facet_grid(Country ~ Fish)+ | ||
+ | labs(x="Fish consumption (g /d)", y="Cumulative frequency")+theme_gray(base_size=24)) | ||
+ | |||
+ | print(ggplot(often@output, aes(x=oftenResult+0.1, colour=Country))+stat_ecdf()+scale_x_log10()+facet_wrap(~ Fish)) | ||
+ | print(ggplot(oftenside@output, aes(x=oftensideResult+0.1, colour=Country))+stat_ecdf()+scale_x_log10()+facet_wrap(~ Fish)) | ||
+ | print(ggplot(much@output, aes(x=muchResult+0.1, colour=Country))+stat_ecdf()+scale_x_log10()+facet_wrap(~ Fish)) | ||
+ | print(ggplot(muchside@output, aes(x=muchsideResult+0.1, colour=Country))+stat_ecdf()+scale_x_log10()+facet_wrap(~ Fish)) | ||
+ | |||
+ | } else { | ||
+ | oprint(summary(amount, marginals=c("Fish"))) | ||
+ | |||
+ | print(ggplot(amount@output, aes(x=amountResult+0.1, colour=Fish))+stat_ecdf()+scale_x_log10()+ | ||
+ | labs(x="Fish consumption (g /d)", y="Cumulative frequency")+theme_gray(base_size=24)) | ||
+ | |||
+ | print(ggplot(often@output, aes(x=oftenResult+0.1, colour=Fish))+stat_ecdf()+scale_x_log10()) | ||
+ | print(ggplot(oftenside@output, aes(x=oftensideResult+0.1, colour=Fish))+stat_ecdf()+scale_x_log10()) | ||
+ | print(ggplot(much@output, aes(x=muchResult+0.1, colour=Fish))+stat_ecdf()+scale_x_log10()) | ||
+ | print(ggplot(muchside@output, aes(x=muchsideResult+0.1, colour=Fish))+stat_ecdf()+scale_x_log10()) | ||
+ | } | ||
+ | </rcode> | ||
== Rationale == | == Rationale == | ||
Line 212: | Line 263: | ||
* Model run 13.4.2017 [http://en.opasnet.org/en-opwiki/index.php?title=Special:RTools&id=1QsyOMpBHrvY0H2o] | * Model run 13.4.2017 [http://en.opasnet.org/en-opwiki/index.php?title=Special:RTools&id=1QsyOMpBHrvY0H2o] | ||
* Model run 20.4.2017 [http://en.opasnet.org/en-opwiki/index.php?title=Special:RTools&id=JuLynAzoCuvu0U3g] (contains surv and helping vectors) | * Model run 20.4.2017 [http://en.opasnet.org/en-opwiki/index.php?title=Special:RTools&id=JuLynAzoCuvu0U3g] (contains surv and helping vectors) | ||
− | * Model run 21.4.2017 [http://en.opasnet.org/en-opwiki/index.php?title=Special:RTools&id= | + | * Model run 21.4.2017 [http://en.opasnet.org/en-opwiki/index.php?title=Special:RTools&id=D9zGDNIqaUV26nP6] surv contains Eatfish, Eatherr and Eatsalm as columns. |
<rcode name="preprocess2" label="Preprocess (only for developers)"> | <rcode name="preprocess2" label="Preprocess (only for developers)"> | ||
Line 218: | Line 269: | ||
library(OpasnetUtils) | library(OpasnetUtils) | ||
+ | |||
objects.latest("Op_en6007", code_name = "answer") # [[OpasnetUtils/Drafts]] webropol.convert, merge.questions | objects.latest("Op_en6007", code_name = "answer") # [[OpasnetUtils/Drafts]] webropol.convert, merge.questions | ||
Line 331: | Line 383: | ||
# Row numbers for respondents that have eaten fish, Baltic salmon, and Baltic herring | # Row numbers for respondents that have eaten fish, Baltic salmon, and Baltic herring | ||
− | surv$Eatfish <- surv[[4]] %in% | + | surv$Eatfish <- surv[[4]] %in% 2 |
− | surv$Eatsalm <- | + | surv$Eatsalm <- surv[[7]] %in% 2 & !is.na(rowSums(surv[7:11])) |
surv$Eatherr <- surv[[12]] %in% 2 & !is.na(rowSums(surv[13:16])) | surv$Eatherr <- surv[[12]] %in% 2 & !is.na(rowSums(surv[13:16])) | ||
+ | |||
+ | oprint(table(surv[c("Eatsalm", "Eatherr", "Eatfish")], useNA = "ifany")) | ||
# Oletetaan, että covarianssimatriisi on vakio kaikille maille ja sukupuolille yms | # Oletetaan, että covarianssimatriisi on vakio kaikille maille ja sukupuolille yms | ||
Line 351: | Line 405: | ||
=== Analyses === | === Analyses === | ||
+ | |||
+ | ==== Descriptive statistics ==== | ||
[[File:Goherr survey correlations.png|thumb|300px|Correlation matrix of all questions in the survey (answers converted to numbers).]] | [[File:Goherr survey correlations.png|thumb|300px|Correlation matrix of all questions in the survey (answers converted to numbers).]] | ||
Line 386: | Line 442: | ||
Model runs | Model runs | ||
* [http://en.opasnet.org/en-opwiki/index.php?title=Special:RTools&id=QaMJZqUX0cPaTfOF Model run 13.3.2017] | * [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 | + | <rcode label="Descriptive statistics" graphics=1> |
− | # This is code Op_en7749/ | + | # This is code Op_en7749/ on page [[Goherr: Fish consumption study]] |
library(OpasnetUtils) | library(OpasnetUtils) | ||
Line 402: | Line 459: | ||
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() + | |
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 412: | Line 469: | ||
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)) + | + | 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 418: | Line 475: | ||
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)) + | + | ggplot(temp, aes(x = Value, fill = Country)) + geom_bar(position = "dodge") + facet_wrap(~ Variable)+ |
− | + | theme_gray(base_size = 24) + labs(title = "Baltic salmon sources") | |
temp <- melt(surveytemp, measure.vars = 50:59, variable.name = "Variable", value.name = "Value") | temp <- melt(surveytemp, measure.vars = 50:59, variable.name = "Variable", value.name = "Value") | ||
− | ggplot(temp, aes(x = Value, fill = Country)) + | + | ggplot(temp, aes(x = Value, fill = Country)) + geom_bar(position = "dodge") + facet_wrap(~ Variable)+ |
− | + | theme_gray(base_size = 24) + labs(title = "Reasons to eat Baltic salmon") | |
temp <- melt(surveytemp, measure.vars = 73:82, variable.name = "Variable", value.name = "Value") | temp <- melt(surveytemp, measure.vars = 73:82, variable.name = "Variable", value.name = "Value") | ||
− | ggplot(temp, aes(x = Value, fill = Country)) + | + | ggplot(temp, aes(x = Value, fill = Country)) + geom_bar(position = "dodge") + facet_wrap(~ Variable)+ |
− | + | theme_gray(base_size = 24) + theme(axis.text.x=element_text(angle=90,hjust=1,vjust=0.4)) + labs(title = "Baltic salmon actions") | |
surveytemp <- subset(survey, survey[[31]] == "No") | 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)) + | + | 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") | |
Line 439: | Line 496: | ||
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)) + | + | ggplot(temp, aes(x = Value, fill = Country)) + geom_bar(position = "dodge") + facet_wrap(~ Variable)+ |
− | + | theme_gray(base_size = 24) + labs(title = "Baltic herring sources") | |
temp <- melt(surveytemp, measure.vars = 99:108, variable.name = "Variable", value.name = "Value") | temp <- melt(surveytemp, measure.vars = 99:108, variable.name = "Variable", value.name = "Value") | ||
− | ggplot(temp, aes(x = Value, fill = Country)) + | + | ggplot(temp, aes(x = Value, fill = Country)) + geom_bar(position = "dodge") + facet_wrap(~ Variable)+ |
− | + | theme_gray(base_size = 24) + labs(title = "Reasons to eat Baltic herring") | |
temp <- melt(surveytemp, measure.vars = 123:132, variable.name = "Variable", value.name = "Value") | temp <- melt(surveytemp, measure.vars = 123:132, variable.name = "Variable", value.name = "Value") | ||
− | ggplot(temp, aes(x = Value, fill = Country)) + | + | ggplot(temp, aes(x = Value, fill = Country)) + geom_bar(position = "dodge") + facet_wrap(~ Variable)+ |
− | + | theme_gray(base_size = 24) + theme(axis.text.x=element_text(angle=90,hjust=1,vjust=0.4)) + labs(title = "Baltic herring actions") | |
surveytemp <- subset(survey, survey[[86]] == "No") | 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)) + | + | ggplot(temp, aes(x = Value, fill = Country)) + geom_bar(position = "dodge") + facet_wrap(~ Variable)+ |
− | + | theme_gray(base_size = 24) + labs(title = "Reasons not to eat Baltic herring") | |
#####################################3 | #####################################3 | ||
Line 485: | Line 542: | ||
############################# Plot original data | ############################# Plot original data | ||
− | + | # Eating frequencies of fish and Baltic salmon and herring with random noise, all | |
pl <- surv[surv$Eatfish,c(5,8,10,13,15)] | pl <- surv[surv$Eatfish,c(5,8,10,13,15)] | ||
scatterplotMatrix( | scatterplotMatrix( | ||
Line 571: | Line 628: | ||
## Kuva koko hypoteeseista | ## Kuva koko hypoteeseista | ||
− | |||
− | |||
colstr <- c("palevioletred1","royalblue1","seagreen1","violet","khaki2","skyblue", "orange") | colstr <- c("palevioletred1","royalblue1","seagreen1","violet","khaki2","skyblue", "orange") | ||
− | |||
− | hypo_sizes <- (5 - colMeans(answ)) | + | #hypo_sizes <- (5 - colMeans(answ)) |
− | leg_sizes <- c(4, 3, 2, 1, 0.01) | + | #leg_sizes <- c(4, 3, 2, 1, 0.01) |
#pdf(file="pcoa_plot.pdf", height=6, width=7.5) | #pdf(file="pcoa_plot.pdf", height=6, width=7.5) | ||
Line 602: | Line 656: | ||
* 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 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 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 | ||
− | <rcode name="bayes" label="Initiate Bayes model (for developers only)" graphics=1 | + | <rcode name="bayes" label="Initiate Bayes model (for developers only)" graphics=1> |
− | |||
− | |||
− | |||
− | |||
# This is code Op_en7749/bayes on page [[Goherr: Fish consumption study]] | # This is code Op_en7749/bayes on page [[Goherr: Fish consumption study]] | ||
Line 625: | Line 678: | ||
cat("Version with multivariate normal.\n") | cat("Version with multivariate normal.\n") | ||
+ | |||
+ | # Development needs: | ||
+ | ## Correlation between salmon.often and herring.often needs to be estimated. | ||
+ | ## Gender, country and age-spesific values should be estimated. | ||
mod <- textConnection(" | mod <- textConnection(" | ||
Line 688: | Line 745: | ||
) | ) | ||
− | + | # Mu for all questions about salmon | |
− | + | scatterplotMatrix(t(js[,,1,1])) | |
− | + | # All parameters for question 1 about salmon | |
− | + | scatterplotMatrix(js[1,,,1]) | |
− | + | # Same for herring | |
+ | scatterplotMatrix(js[1,,,2]) | ||
− | + | jsd <- melt(js) | |
− | + | #ggplot(jsd, aes(x=value, colour=Question))+geom_density()+facet_grid(Parameter ~ Fish) | |
− | + | #ggplot(as.data.frame(js), aes(x = anss.pred, y = Sampled))+geom_point()+stat_ellipse() | |
− | + | coda.j <- coda.samples( | |
− | + | jags, | |
− | + | c('mus', 'Omegas', 'anss.pred'), | |
− | + | 1000 | |
+ | ) | ||
+ | |||
+ | plot(coda.j) | ||
+ | |||
+ | ######## fish.param contains expected values of the distribution parameters from the model | ||
+ | |||
+ | fish.param <- list( | ||
+ | mu = apply(js[,,1,], MARGIN = c(1,3), FUN = mean), | ||
+ | Omega = lapply( | ||
+ | 1:2, | ||
+ | FUN = function(x) { | ||
+ | solve(apply(js[,,2:5,], MARGIN = c(1,3,4), FUN = mean)[,,x]) | ||
+ | } # solve matrix: precision->covariace | ||
) | ) | ||
+ | ) | ||
− | + | objects.store(fish.param) | |
+ | cat("List fish.param stored.\n") | ||
+ | </rcode> | ||
− | + | ==== Initiate ovariables ==== | |
+ | |||
+ | '''Amount estimated from a bayesian model. | ||
+ | |||
+ | * Model run 24.5.2017 [http://en.opasnet.org/en-opwiki/index.php?title=Special:RTools&id=3UORzPwospQxp82h] | ||
+ | |||
+ | <rcode name="modeljsp" label="Initiate jsp from model (for developers only)"> | ||
+ | # This is code Op_en7749/modeljsp on page [[Goherr: Fish consumption study]] | ||
− | + | library(OpasnetUtils) | |
− | + | jsp <- Ovariable( | |
− | + | "jsp", | |
− | + | dependencies = data.frame(Name = "fish.param", Ident = "Op_en7749/bayes"), | |
+ | formula = function(...) { | ||
+ | require(MASS) | ||
+ | require(reshape2) | ||
+ | jsp <- lapply( | ||
1:2, | 1:2, | ||
FUN = function(x) { | 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) | ||
+ | } | ||
+ | ) | ||
+ | |||
+ | objects.store(jsp) | ||
+ | cat("Ovariable jsp stored.\n") | ||
+ | </rcode> | ||
+ | |||
+ | '''Amount estimates directly from data rather than from a bayesian model. | ||
+ | |||
+ | * Initiation run 18.5.2017 [http://en.opasnet.org/en-opwiki/index.php?title=Special:RTools&id=crW1kboP72BN1JbK] | ||
+ | |||
+ | <rcode name="surveyjsp" label="Initiate jsp from survey (for developers only)"> | ||
+ | # 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. | ||
+ | |||
+ | library(OpasnetUtils) | ||
+ | library(reshape2) | ||
+ | |||
+ | objects.latest("Op_en7749", code_name="preprocess2") # original survey data (surv) | ||
+ | |||
+ | sur <- survey[c(157,1,3,158,16,29,30,31,46:49,86,95:98)] | ||
+ | |||
+ | #colnames(sur) | ||
+ | #[1] "Row" "Country" "Gender" "Ages" | ||
+ | #[5] "Eat.fish" "How.often.fish" "Eat.salmon" "Baltic.salmon" | ||
+ | #[9] "How.often.BS" "How.much.BS" "How.often.side.BS" "How.much.side.BS" | ||
+ | #[13] "Eat.BH" "How.often.BH" "How.much.BH" "How.often.side.BH" | ||
+ | #[17] "How.much.side.BH" | ||
+ | |||
+ | colnames(sur)[c(1,8:17)] <- c("Iter",rep(as.character(c(5,1:4)),2)) | ||
+ | sur[8:17] <- sapply(sur[8:17], as.numeric) | ||
+ | sur <- rbind(cbind(Fish="Herring", sur[-(8:12)]), | ||
+ | cbind(Fish="Salmon", sur[-(13:17)]) | ||
+ | ) | ||
+ | sur <- melt( | ||
+ | sur, | ||
+ | measure.vars=as.character(1:5), | ||
+ | variable.name="Question", | ||
+ | value.name="Result" | ||
+ | ) | ||
+ | sur$Result[is.na(sur$Result)] <- 1 # Ovariable often becomes never -> amount becomes 0. | ||
+ | |||
+ | jsp <- Ovariable( | ||
+ | "jsp", | ||
+ | output = sur, | ||
+ | marginal = colnames(sur) %in% c("Fish", "Iter", "Question") | ||
+ | ) | ||
+ | |||
+ | objects.store(jsp) | ||
+ | cat("Ovariable jsp with actual survey data: each respondent is an iteration.\n") | ||
+ | </rcode> | ||
+ | |||
+ | '''Initiate other ovariables | ||
+ | |||
+ | * Code stores ovariables assump, often, much, oftenside, muchside, amount. | ||
+ | * Model run 19.5.2017 [http://en.opasnet.org/en-opwiki/index.php?title=Special:RTools&id=FauP3x6hviC4xWCD] | ||
+ | * Initiation run 24.5.2017 without jsp [http://en.opasnet.org/en-opwiki/index.php?title=Special:RTools&id=6U3FWqVRaNumPcok] | ||
+ | * Model run 8.6.2017 [http://en.opasnet.org/en-opwiki/index.php?title=Special:RTools&id=euGolhOQvPqzQDvf] | ||
+ | |||
+ | <rcode name="initiate" label="Initiate ovariables (for developers only)"> | ||
+ | # This is code Op_en7749/initiate on page [[Goherr: Fish consumption study]] | ||
− | + | library(OpasnetUtils) | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | # Combine modelled survey answers with estimated amounts and frequencies by: | |
− | + | # Rounding the modelled result and merging that with value in ovariable assump | |
often <- Ovariable( | often <- Ovariable( | ||
Line 762: | Line 896: | ||
out@output | out@output | ||
) | ) | ||
+ | out <- out[!colnames(out) %in% c("Value", "Variable", "Result")] | ||
colnames(out)[colnames(out) == "assumpResult"] <- "Result" | colnames(out)[colnames(out) == "assumpResult"] <- "Result" | ||
− | return(out | + | return(out) |
} | } | ||
) | ) | ||
Line 777: | Line 912: | ||
out@output | out@output | ||
) | ) | ||
+ | out <- out[!colnames(out) %in% c("Value", "Variable", "Result")] | ||
colnames(out)[colnames(out) == "assumpResult"] <- "Result" | colnames(out)[colnames(out) == "assumpResult"] <- "Result" | ||
− | return(out | + | return(out) |
} | } | ||
) | ) | ||
Line 792: | Line 928: | ||
out@output | out@output | ||
) | ) | ||
+ | out <- out[!colnames(out) %in% c("Value", "Variable", "Result")] | ||
colnames(out)[colnames(out) == "assumpResult"] <- "Result" | colnames(out)[colnames(out) == "assumpResult"] <- "Result" | ||
− | return(out | + | return(out) |
} | } | ||
) | ) | ||
Line 807: | Line 944: | ||
out@output | out@output | ||
) | ) | ||
+ | out <- out[!colnames(out) %in% c("Value", "Variable", "Result")] | ||
colnames(out)[colnames(out) == "assumpResult"] <- "Result" | colnames(out)[colnames(out) == "assumpResult"] <- "Result" | ||
− | return(out | + | return(out) |
} | } | ||
) | ) | ||
Line 825: | Line 963: | ||
"muchside", | "muchside", | ||
"assump" | "assump" | ||
− | )) | + | )), |
− | + | formula = function(...) { | |
− | often | + | away <- c( |
− | much | + | "assumpUnit", |
− | oftenside | + | "Eat.fish", |
− | muchside | + | "How.often.fish", |
− | assump <- assump[assump$Variable == "ingredient", !colnames(assump@output) %in% c("Variable", "Value", "Explanation")] | + | "Eat.salmon" |
− | out <- often * much + oftenside * muchside * assump | + | ) |
+ | 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% | ||
+ | c("Variable", "Value", "Explanation", "assumpUnit")] | ||
+ | |||
+ | out <- (often * much + oftenside * muchside * assump)/365 # g /d | ||
+ | return(out) | ||
} | } | ||
) | ) | ||
− | + | objects.store(assump, often, much, oftenside, muchside, amount) | |
− | + | cat("Ovariables assump, often, much, oftenside, muchside, amount stored.\n") | |
− | |||
</rcode> | </rcode> | ||
Line 859: | Line 1,005: | ||
==Related files== | ==Related files== | ||
− | |||
− | |||
{{publication | {{publication |
Latest revision as of 10:12, 8 June 2017
This page is a study.
The page identifier is Op_en7749 |
---|
Moderator:Arja (see all) |
This page is a stub. You may improve it into a full page, and then a rating bar will appear here. |
Upload data
|
Contents
Question
How Baltic herring and salmon are used as human food in Baltic sea countries? Which determinants affect on people’s eating habits of these fish species?
Answer
Original questionnaire analysis results
Consumption amount estimates
- Model run 21.4.2017 [1] first distribution
- Model run 18.5.2017 with modelled data; 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 Google drive. The actual data can be found from the link below (see Data).
Data
Questionnaire
Original datafile File:Goherr fish consumption.csv.
Show details | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Assumptions
The following assumptions are used:
Obs | Variable | Value | Unit | Result | Description |
---|---|---|---|---|---|
1 | freq | 1 | times /a | 0 | Never |
2 | freq | 2 | times /a | 0.5 - 0.9 | less than once a year |
3 | freq | 3 | times /a | 2 - 5 | A few times a year |
4 | freq | 4 | times /a | 12 - 36 | 1 - 3 times per month |
5 | freq | 5 | times /a | 52 | once a week |
6 | freq | 6 | times /a | 104 - 208 | 2 - 4 times per week |
7 | freq | 7 | times /a | 260 - 364 | 5 or more times per week |
8 | amdish | 1 | g /serving | 20 - 70 | 1/6 plate or below (50 grams) |
9 | amdish | 2 | g /serving | 70 - 130 | 1/3 plate (100 grams) |
10 | amdish | 3 | g /serving | 120 - 180 | 1/2 plate (150 grams) |
11 | amdish | 4 | g /serving | 170 - 230 | 2/3 plate (200 grams) |
12 | amdish | 5 | g /serving | 220 - 280 | 5/6 plate (250 grams) |
13 | amdish | 6 | g /serving | 270 - 400 | full plate (300 grams) |
14 | amdish | 7 | g /serving | 400 - 550 | overly full plate (500 grams) |
15 | ingredient | fraction | 0.1 - 0.3 | Fraction of fish in the dish | |
16 | amside | 1 | g /serving | 20 - 70 | 1/6 plate or below (50 grams) |
17 | amside | 2 | g /serving | 70 - 130 | 1/4 plate (100 grams) |
18 | amside | 3 | g /serving | 120 - 180 | 1/2 plate (150 grams) |
19 | amside | 4 | g /serving | 170 - 230 | 2/3 plate (200 grams) |
20 | amside | 5 | g /serving | 220 - 280 | 5/6 plate (250 grams) |
Preprocessing
This code is used to preprocess the original questionnaire data from the above .csv file and to store the data as a usable variable to Opasnet base. The code stores a data.frame named survey.
- Model run 13.4.2017 [2]
- Model run 20.4.2017 [3] (contains surv and helping vectors)
- Model run 21.4.2017 [4] surv contains Eatfish, Eatherr and Eatsalm as columns.
Analyses
Descriptive statistics
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
- Model run 13.3.2017
- Model run 21.4.2017 [5] old code from Answer merged to this code and debugged
Bayes model
- Model run 3.3.2017. All variables assumed independent. [6]
- Model run 3.3.2017. p has more dimensions. [7]
- Model run 25.3.2017. Several model versions: strange binomial+multivarnormal, binomial, fractalised multivarnormal [8]
- Model run 27.3.2017 [9]
- Other models except multivariate normal were archived and removed from active code 29.3.2017.
- Model run 29.3.2017 with raw data graphs [10]
- Model run 29.3.2017 with salmon and herring ovariables stored [11]
- Model run 13.4.2017 with first version of coordinate matrix and principal coordinate analysis [12]
- Model run 20.4.2017 [13] code works but needs a safety check against outliers
- Model run 21.4.2017 [14] some model results plotted
- Model run 21.4.2017 [15] ovariables produced by the model stored.
- Model run 18.5.2017 [16] small updates
Initiate ovariables
Amount estimated from a bayesian model.
- Model run 24.5.2017 [17]
Amount estimates directly from data rather than from a bayesian model.
- Initiation run 18.5.2017 [18]
Initiate other ovariables
- Code stores ovariables assump, often, much, oftenside, muchside, amount.
- Model run 19.5.2017 [19]
- Initiation run 24.5.2017 without jsp [20]
- Model run 8.6.2017 [21]
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
- Useful information about Wishart distribution and related topics:
Keywords
References
Related files