-
Notifications
You must be signed in to change notification settings - Fork 4
/
bayes_05_get_MCMC_diagnostics.R
109 lines (82 loc) · 2.81 KB
/
bayes_05_get_MCMC_diagnostics.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# Author: Kelvin Gorospe
# Get convergence diagnostics
rm(list=ls())
library(tidyverse)
library(bayesplot)
datadir <- "/Volumes/jgephart/BFA Environment 2/Data"
outdir <- "/Volumes/jgephart/BFA Environment 2/Outputs"
# Set filenames:
# Mass allocation
c_results <- "Nature-submitted-2021-08/RERUN-GHG-and-Water-Bayesian-Means-Edible-Weight/PRIORS/2021-08-17_full-model-posterior_Global warming potential_Mass-allocation.RData"
n_results <- "Nature-submitted-2021-05/Bayesian-Means-Edible-Weight/PRIORS/Nitrogen/2021-04-28_full-model-posterior_Marine eutrophication_Mass-allocation.RData"
p_results <- "Nature-submitted-2021-05/Bayesian-Means-Edible-Weight/PRIORS/Phosphorus/2021-04-28_full-model-posterior_Freshwater eutrophication_Mass-allocation.RData"
land_results <- "Nature-submitted-2021-05/Bayesian-Means-Edible-Weight/PRIORS/Land-FCR-priors-only/2021-04-28_full-model-posterior_Land Use_Mass-allocation.RData"
water_results <- "Nature-submitted-2021-08/RERUN-GHG-and-Water-Bayesian-Means-Edible-Weight/PRIORS/2021-08-17_full-model-posterior_Water Consumption_Mass-allocation.RData"
wild_results <- "Nature-submitted-2021-05/Bayesian-Means-Edible-Weight/PRIORS/Wild/2021-04-27_full-model-posterior_Wild-capture-ghg.RData"
# Update filepaths as needed for various model outputs (i.e., allocation method, priors vs no priors, edible weight vs live weight)
####################################################
# Carbon
load(file.path(outdir, c_results))
# Get neff ratios:
mod_neff <- neff_ratio(fit_no_na)
min(mod_neff)
# Get Rhat:
mod_rhat <- rhat(fit_no_na)
min(mod_rhat)
max(mod_rhat)
rm(fit_no_na)
####################################################
# Nitrogen
load(file.path(outdir, n_results))
# Get neff ratios:
mod_neff <- neff_ratio(fit_no_na)
min(mod_neff)
# Get Rhat:
mod_rhat <- rhat(fit_no_na)
min(mod_rhat)
max(mod_rhat)
rm(fit_no_na)
####################################################
# Phosphorus
load(file.path(outdir, p_results))
# Get neff ratios:
mod_neff <- neff_ratio(fit_no_na)
min(mod_neff)
# Get Rhat:
mod_rhat <- rhat(fit_no_na)
min(mod_rhat)
max(mod_rhat)
rm(fit_no_na)
####################################################
# Water
load(file.path(outdir, water_results))
# Get neff ratios:
mod_neff <- neff_ratio(fit_no_na)
min(mod_neff)
# Get Rhat:
mod_rhat <- rhat(fit_no_na)
min(mod_rhat)
max(mod_rhat)
rm(fit_no_na)
####################################################
# Land
load(file.path(outdir, land_results))
# Get neff ratios:
mod_neff <- neff_ratio(fit_no_na)
min(mod_neff)
# Get Rhat:
mod_rhat <- rhat(fit_no_na)
min(mod_rhat)
max(mod_rhat)
rm(fit_no_na)
####################################################
# Wild capture
load(file.path(outdir, wild_results))
# Get neff ratios:
mod_neff <- neff_ratio(fit_no_na)
min(mod_neff)
# Get Rhat:
mod_rhat <- rhat(fit_no_na)
min(mod_rhat)
max(mod_rhat)
rm(fit_no_na)