Skip to content

Commit

Permalink
update idsa s3 methods
Browse files Browse the repository at this point in the history
  • Loading branch information
SpatLyu committed Nov 5, 2024
1 parent 9e09984 commit f27c41a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 31 deletions.
4 changes: 2 additions & 2 deletions R/idsa.R
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ print.idsa_result = \(x, ...) {
"* Percentage of finely divided zones : ",x$percentage_finely_divided_zones,"\n",
"* Number of individual explanatory variables : ",x$number_individual_explanatory_variables,"\n",
"\n ## Different of response variable between a pair of overlay zones:")
x = dplyr::select(x$risk1,zone1st,zone2nd,Risk)
x = dplyr::select(x$risk,zone1st,zone2nd,Risk)
print(knitr::kable(utils::head(x,5), format = "markdown", align = 'c', ...))
cat("\n #### Only the first five pairs of interactions and overlay zones are displayed! ####")
}
Expand All @@ -184,7 +184,7 @@ print.idsa_result = \(x, ...) {
#' @export
#'
plot.idsa_result = \(x, ...) {
grd = dplyr::select(x$risk1,zone1st,zone2nd,Risk) %>%
grd = dplyr::select(x$risk,zone1st,zone2nd,Risk) %>%
dplyr::mutate(risk = forcats::fct_recode(Risk,"Y" = "Yes", "N" = "No"))
fig_rd = ggplot2::ggplot(data = grd,
ggplot2::aes(x = zone1st, y = zone2nd, fill = risk)) +
Expand Down
Binary file removed man/figures/idsa/idsa_map-1.png
Binary file not shown.
32 changes: 3 additions & 29 deletions vignettes/idsa.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ idsa.model = idsa(Depression_prevelence ~ .,
data = depression,
wt = wt, cores = 12)
tictoc::toc()
## 58.55 sec elapsed
## 59.78 sec elapsed
idsa.model
## *** Interactive Detector For Spatial Associations
##
Expand All @@ -84,33 +84,7 @@ idsa.model
## * Number of individual explanatory variables : 8
##
## ## Different of response variable between a pair of overlay zones:
##
## | zone1st | zone2nd | Risk |
## |:----------:|:-------------:|:----:|
## | zoneBeer_3 | zoneBeer_4 | No |
## | zoneBeer_3 | zoneBeer_5 | No |
## | zoneBeer_3 | zoneBeer_6 | No |
## | zoneBeer_3 | zoneCasinos_2 | No |
## | zoneBeer_3 | zoneCasinos_3 | No |
##
## #### Only the first five pairs of interactions and overlay zones are displayed! ####
## Error in UseMethod("select"): no applicable method for 'select' applied to an object of class "NULL"
plot(idsa.model)
## Error in UseMethod("select"): no applicable method for 'select' applied to an object of class "NULL"
```

![plot of chunk idsa_modeling](man/figures/idsa/idsa_modeling-1.png)

The risk detection outcomes, as determined by IDSA, can be graphically represented on a map.


``` r
idsa_risk = idsa.model$risk2
depression$risk = idsa_risk

ggplot(data = depression) +
ggplot2::geom_sf(aes(color = risk), alpha = .65) +
ggplot2::scale_color_manual(values = c("No" = "#7fdbff",
"Yes" = "#ffa500")) +
theme_bw()
```

![plot of chunk idsa_map](man/figures/idsa/idsa_map-1.png)

0 comments on commit f27c41a

Please sign in to comment.