Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1. Priors Shiny App #57

Merged
merged 64 commits into from
Aug 22, 2023
Merged
Show file tree
Hide file tree
Changes from 37 commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
0867dec
WIP: First pass at a priors app
gareth-j Jun 26, 2023
3586184
WIP: Priors vignette to work on Shiny priors interface
gareth-j Jun 27, 2023
3f9a1af
Basic model running but crashes, looking at causes
gareth-j Jun 27, 2023
4f10a63
Basic shiny app working and outputting model summary
gareth-j Jun 27, 2023
641614e
Improved layout of app, basic functionality working, added busy spinner
gareth-j Jun 28, 2023
31120ca
Small subset of data working with new mesh
gareth-j Jun 28, 2023
bce9574
Added sliders for other priors, looking at SPDE error
gareth-j Jul 3, 2023
e20a913
Converted app to use tabset. New sliders working with (hopefully) sen…
gareth-j Jul 3, 2023
b1d1c50
Merge branch 'main' into Iss54/ShinyPriors
gareth-j Jul 4, 2023
ddec081
Added eval=FALSE to temporary vignette
gareth-j Jul 4, 2023
ee80c90
Merge branch 'main' into Iss54/ShinyPriors
gareth-j Jul 21, 2023
71e133a
Merge branch 'Prior_Tut' into Iss54/ShinyPriors
gareth-j Jul 21, 2023
5a0072a
WIP: Updating prior values, adding in storage of model_output for com…
gareth-j Jul 21, 2023
87dddbd
Merge branch 'main' into Iss54/ShinyPriors
gareth-j Jul 24, 2023
6904b6d
Adding in storage of model out
gareth-j Jul 24, 2023
1f65a18
Model output save working
gareth-j Jul 24, 2023
8fe7cae
Adding function to parse output of inlabru::bru
gareth-j Jul 24, 2023
d686c65
Adding functions to parse inlabru model output
gareth-j Jul 25, 2023
b9333a9
Looking into cause of INLA crashes, currently running with alphaprior…
gareth-j Jul 25, 2023
2e8c2ef
spde and alphaprior with input$ working
gareth-j Jul 25, 2023
702866b
Save each run
gareth-j Jul 25, 2023
6a16279
WIP: Adding f-string customisation back in
gareth-j Jul 25, 2023
409cdb8
Custom fstring working
gareth-j Jul 25, 2023
a9b3f0f
Adding in status text
gareth-j Jul 25, 2023
618f95b
Models running correctly and their outputs parsed
gareth-j Jul 25, 2023
160a74d
Adding in documentation files
gareth-j Jul 25, 2023
7783dad
Plotting comparison boxplots working
gareth-j Jul 26, 2023
f74e5e8
Adding code output for code tab
gareth-j Jul 26, 2023
8861598
Prior values shown correctly in code tab
gareth-j Jul 31, 2023
02b9e3c
Adding the four plots to app, updating handling code
gareth-j Aug 9, 2023
a7bc7a5
All 5 plot types working and able to compare different runs
gareth-j Aug 9, 2023
f57f630
Increased text size on axes
gareth-j Aug 9, 2023
7eafcd3
functional priors app working
gareth-j Aug 9, 2023
15ef968
Adding todo note for group variables
gareth-j Aug 9, 2023
51ad7f1
Merge branch 'main' into Iss54/ShinyPriors
gareth-j Aug 9, 2023
a00e0e4
WIP: Adding loading gif
gareth-j Aug 9, 2023
fb25ee7
Fix for duplicate cell name
gareth-j Aug 9, 2023
01ddbce
Ensure correct stepping of temporal prior
gareth-j Aug 10, 2023
b646b3c
Added fdmr logo busy gif, added model summary output to model run window
gareth-j Aug 10, 2023
885d67c
WIP: Adding writing of model summary and priors to logfile [skip ci]
gareth-j Aug 10, 2023
a4a88d1
Adding help tab to app
gareth-j Aug 18, 2023
af68477
Split out plotting functions for priors app, update app to pass in ti…
gareth-j Aug 18, 2023
2f0c7dd
Adding async libraries to description
gareth-j Aug 18, 2023
60ff706
WIP: Move to async promise for model run
gareth-j Aug 18, 2023
8fcb7f4
WIP: Moving variables back to reactive components
gareth-j Aug 21, 2023
973c84e
Check if model output is correct
gareth-j Aug 21, 2023
ab0b0c0
Remove unused gif component
gareth-j Aug 21, 2023
7f51c4f
Merge branch 'Iss54+/async' into Iss54/ShinyPriors
gareth-j Aug 21, 2023
188874a
Disable eval of final mesh build step
gareth-j Aug 21, 2023
ac3ec41
Separate lines for packages
gareth-j Aug 21, 2023
6b62a0a
Does using loadNamespace work?
gareth-j Aug 21, 2023
d9d0ccd
Move to require for INLA loads
gareth-j Aug 22, 2023
d270bc6
Remove INLA load calls
gareth-j Aug 22, 2023
d7383d9
Add require of INLA back in
gareth-j Aug 22, 2023
df05517
Install INLA first
gareth-j Aug 22, 2023
1657bdc
Correct caching steps
gareth-j Aug 22, 2023
5471490
Ensure docstrings are up to date and added INLA to imports and remote
gareth-j Aug 22, 2023
277f59f
Reduce number of requires, updated logging to create cleaner files
gareth-j Aug 22, 2023
6560d5c
Put back delete log folder path
gareth-j Aug 22, 2023
3377a1c
Add missing words for file explanation
gareth-j Aug 22, 2023
5eb3291
Update text to use alpha symbol instead of a as per Xueqing's suggestion
gareth-j Aug 22, 2023
f16b693
Make sure vignette name is synced
gareth-j Aug 22, 2023
4bef5f5
Remove explicit INLA install
gareth-j Aug 22, 2023
5c04319
Add check for coordinates on spatial data object
gareth-j Aug 22, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ Imports:
leaflet,
archive,
shiny,
stringr
stringr,
shinybusy
Suggests:
bookdown,
knitr,
Expand Down
3 changes: 3 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@

export(clear_caches)
export(get_tutorial_datapath)
export(interactive_priors)
export(latlong_to_utm)
export(load_tutorial_data)
export(mesh_builder)
export(mesh_checker)
export(mesh_to_spatial)
export(numbers_only)
export(parse_model_output)
export(plot_barchart)
export(plot_boxplot)
export(plot_interactive_map)
Expand All @@ -17,4 +19,5 @@ export(plot_mesh)
export(plot_timeseries)
export(retrieve_tutorial_data)
export(to_dates)
importFrom(INLA,f)
importFrom(magrittr,"%>%")
45 changes: 45 additions & 0 deletions R/model_parse.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#' Parses inlabru::bru model output
#'
#' @param model_output Output from running inlabru::bru
#' @param measurement_data Measurement data
#'
#' @return list
#' @keywords internal
parse_model_output_bru <- function(model_output, measurement_data) {
fitted_mean_post <- model_output$summary.fitted.values$mean[seq_len(nrow(measurement_data))]
fitted_sd_post <- model_output$summary.fitted.values$mean[seq_len(nrow(measurement_data))]

mean_post <- model_output$summary.random$f$mean
sd_post <- model_output$summary.random$f$sd
fixed_mean <- model_output$summary.fixed$mean

dic <- model_output$dic$dic
pars <- model_output$marginals.hyperpar

parsed_output <- list(
fitted_mean_post = fitted_mean_post,
fitted_sd_post = fitted_sd_post,
mean_post = mean_post,
sd_post = sd_post,
fixed_mean = fixed_mean,
dic = dic,
pars = pars
)

return(parsed_output)
}


#' Parse model output
#'
#' @param model_output Data returned by model
#' @param measurement_data Measurement data
#' @param model_type Type of model, we currently support inlabru
#'
#' @return list
#' @export
parse_model_output <- function(model_output, measurement_data, model_type = "inlabru") {
if (model_type == "inlabru") {
return(parse_model_output_bru(model_output = model_output, measurement_data = measurement_data))
}
}
1 change: 1 addition & 0 deletions R/plot_mapping.R
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ plot_map <- function(polygon_data = NULL,
title = legend_title
)
}

m <- leaflet::addPolygons(m,
data = polygon_data,
fillColor = polygon_fill_colour,
Expand Down
Loading
Loading