## Example using Northern American countries and ntrade simulated data
data("datatrade_NorthAm")
# Extract country IDs and simulate ntrade data
IDs <- datatrade_NorthAm$internal_production$reporter
df <- data.frame(IDs = IDs,
ntrade_values = abs(rnorm(length(IDs), 10000, 2000)))
# Expression for the pathway model using 3 parameters
eq <- "(1/P1)*P2*P3"
# Distribution for each parameter
parameters <- list(
P1 = list(dist = "beta", shape1 = 0.5, shape2 = 1),
P2 = list(dist = "gamma", shape = 1.5, scale = 100),
P3 = list(dist = "lnorm", mean = 5, sd = 2)
)
# Run pathway_model()
res_pathway <- pathway_model(ntrade_data = df,
IDs_col = "IDs",
values_col = "ntrade_values",
expression = eq,
parameters = parameters,
niter = 100)
head(res_pathway)
# summary of the total for all countries
res_pathway[res_pathway$IDs == "Total",]
# plot
plot_countries(res_pathway, "IDs", "Median")
Run the code above in your browser using DataLab