Skip to content

Commit

Permalink
Merge pull request #156 from 4DModeller/Iss155/ChangePriorsName
Browse files Browse the repository at this point in the history
Update the parameter labels and help descriptions for Shiny app
  • Loading branch information
gareth-j authored Oct 8, 2023
2 parents 7cf5682 + 8cf637f commit 9492626
Showing 1 changed file with 15 additions and 16 deletions.
31 changes: 15 additions & 16 deletions R/shiny_priors.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,17 @@ priors_shiny <- function(spatial_data,
}

# Text for priors help
prior_range_text <- "A length 2 vector, with (range0, Prange) specifying that P(ρ < ρ_0)=p_ρ,
where ρ is the spatial range of the random field."
prior_range_text <- "A length 2 vector, with (range0, Prange) specifying that P(ρ < ρ_0)=p_ρ,
where ρ is the spatial range of the random field. P(ρ < ρ_0)=p_ρ indicates that the probability of ρ smaller than ρ_0 (range0) is p_ρ (Prange)."

prior_sigma_text <- "A length 2 vector, with (sigma0, Psigma) specifying that P(σ > σ_0)=p_σ,
where σ is the marginal standard deviation of the field."

control_group_text <- "Temporal priors are set using alpha and PG alpha. These are passed used to create alphaprior.
We use pass this to the control.group argument, control.group = list(model = 'ar1', hyper = alphaprior). This specifies that across time,
the process evolves according to an AR(1) process where the prior for the autocorrelation
parameter α is given by alphaprior. We define alphaprior with the prior 'pccor1' which is a PC
prior for the autocorrelation parameter a where α=1 is the base model."
prior_sigma_text <- "A length 2 vector, with (sigma0, Psigma) specifying that P(σ > σ_0)=p_σ,
where σ is the marginal standard deviation of the field. P(σ > σ_0)=p_σ indicates that the probability of σ greater than σ_0 (sigma0) is p_σ (Psigma)."

control_group_text <- "Temporal priors for the temporal autocorrelation parameter α are set using prior_alpha and pg_alpha, in the relation that P(α > prior_alpha) = pg_alpha, indicating that the probability of α greater than prior_alpha is pg_alpha.
These values are used to create alphaprior, which is then passed to the control.group argument, control.group = list(model = 'ar1', hyper = alphaprior).
It specifies that across time, the process evolves according to an AR(1) process where the prior for the autocorrelation parameter α is given by alphaprior.
We define alphaprior with the prior 'pccor1', which is a Penalised Complexity (PC) prior for the temporal autocorrelation parameter α, with α = 1 indicating strong temporal dependence, and α = 0 indicating independence across time."

citation_priors <- "Spatial and field prior explanation taken from https://rdrr.io/github/INBO-BMK/INLA/man/inla.spde2.pcmatern.html"
citation_control_group <- "Prior explanation text modified from https://www.paulamoraga.com/book-geospatial/sec-geostatisticaldataexamplest.html"

Expand Down Expand Up @@ -78,33 +77,33 @@ priors_shiny <- function(spatial_data,
shiny::h3("Priors"),
shiny::sliderInput(
inputId = "prior_range",
label = "Spatial range:",
label = "range0:",
min = 0.05, value = 0.05, max = 1
),
shiny::sliderInput(
inputId = "ps_range",
label = "Range probabilty:",
label = "Prange:",
min = 0.1, value = 0.1, max = 1
),
shiny::sliderInput(
inputId = "prior_sigma",
label = "Standard deviation:",
label = "sigma0:",
min = 0.05, value = 0.05, max = 2
),
shiny::sliderInput(
inputId = "pg_sigma",
label = "Standard dev. probability:",
label = "Psigma:",
min = 0.1, value = 0.2, max = 1
),
shiny::h3("Temporal priors"),
shiny::sliderInput(
inputId = "prior_ar1",
label = "Alpha:",
label = "prior_alpha:",
min = -1, value = -0.2, max = 1.0, step = 0.1,
),
shiny::sliderInput(
inputId = "pg_ar1",
label = "PG Alpha:",
label = "pg_alpha:",
min = 0, value = 0.8, max = 1
),
shiny::textOutput(outputId = "status")
Expand Down

0 comments on commit 9492626

Please sign in to comment.