stscl / gdverse

Analysis of Spatial Stratified Heterogeneity
https://stscl.github.io/gdverse/
23 stars 3 forks source link

The rationality of the marginal contribution q value (shap power of determinant) estimated by `isp()` #18

Closed SpatLyu closed 1 week ago

SpatLyu commented 1 week ago
library(sf)
#> Linking to GEOS 3.12.1, GDAL 3.8.4, PROJ 9.3.1; sf_use_s2() is TRUE
library(tidyverse)
library(gdverse)

g = isp(NDVIchange ~ ., data = GD::ndvi_40, 
         discvar = c("Tempchange","Precipitation","GDP","Popdensity"),
         discnum = 3:8, cores = 8)
g1 = isp(H1N1 ~ ., data = GD::h1n1_100[,1:10],
          discnum = 3:8, cores = 8)
g
#> ***     Interpretable Stratified Power Model     
#> 
#>  ---------- Global SHAP Power of Determinant: ------------
#> 
#> |   variable    |     spd      |
#> |:-------------:|:------------:|
#> | Precipitation | 0.195412774  |
#> |  Climatezone  | 0.188196658  |
#> |  Tempchange   | 0.007902234  |
#> |  Popdensity   | -0.005876675 |
#> |      GDP      | -0.006493870 |
#> |    Mining     | -0.011805851 |
#> 
#>  ---------- Global Variable Interaction: ------------
#> 
#> |                        variable                         |    rpd    |    qv    |
#> |:-------------------------------------------------------:|:---------:|:--------:|
#> |               Climatezone ∩ Precipitation               | 0.8979666 | 3.85e-10 |
#> |                      Precipitation                      | 0.8883955 | 4.77e-10 |
#> |            Climatezone ∩ Precipitation ∩ GDP            | 0.8538100 | 2.72e-10 |
#> |        Climatezone ∩ Tempchange ∩ Precipitation         | 0.8455546 | 7.73e-10 |
#> |     Climatezone ∩ Precipitation ∩ GDP ∩ Popdensity      | 0.8438789 | 4.05e-10 |
#> |               Tempchange ∩ Precipitation                | 0.8434547 | 4.07e-10 |
#> |          Climatezone ∩ Mining ∩ Precipitation           | 0.8433285 | 8.40e-10 |
#> |        Climatezone ∩ Precipitation ∩ Popdensity         | 0.8430741 | 6.10e-10 |
#> |       Climatezone ∩ Mining ∩ Precipitation ∩ GDP        | 0.8376126 | 4.98e-10 |
#> | Climatezone ∩ Mining ∩ Precipitation ∩ GDP ∩ Popdensity | 0.8282964 | 4.69e-10 |
#> 
#>  ---------- ISP Model Performance Evaluation: ---------
#>  * Number of overlay zones :  11 
#>  * Percentage of finely divided zones :  0 
#>  * Number of individual explanatory variables :  2 
#>  
#>  ## Different of response variable between a pair of overlay zones:
#> 
#> |       zone1st       |         zone2nd          | Risk |
#> |:-------------------:|:------------------------:|:----:|
#> | zoneClimatezone_Bsk |   zoneClimatezone_Bwk    | Yes  |
#> | zoneClimatezone_Bsk |   zoneClimatezone_Dwa    | Yes  |
#> | zoneClimatezone_Bsk |   zoneClimatezone_Dwb    | Yes  |
#> | zoneClimatezone_Bsk | zonePrecipitation_group1 | Yes  |
#> | zoneClimatezone_Bsk | zonePrecipitation_group3 | Yes  |
#> 
#>  #### Only the first ten pairs of interactions and overlay zones are displayed! ####
g1
#> ***     Interpretable Stratified Power Model     
#> 
#>  ---------- Global SHAP Power of Determinant: ------------
#> 
#> | variable |     spd      |
#> |:--------:|:------------:|
#> | medicost | 0.139584758  |
#> | urbanpop | 0.107327202  |
#> | sensepop | 0.105895690  |
#> |   temp   | 0.053365783  |
#> |   prec   | 0.018090904  |
#> |   gdpd   | -0.003416306 |
#> |   humi   | -0.007036088 |
#> |   rdds   | -0.008745928 |
#> |   popd   | -0.009232736 |
#> 
#>  ---------- Global Variable Interaction: ------------
#> 
#> |                          variable                          |    rpd    |    qv    |
#> |:----------------------------------------------------------:|:---------:|:--------:|
#> |           prec ∩ sensepop ∩ urbanpop ∩ medicost            | 0.8923305 | 8.87e-10 |
#> |           temp ∩ sensepop ∩ urbanpop ∩ medicost            | 0.8884778 | 6.91e-10 |
#> |        temp ∩ prec ∩ sensepop ∩ urbanpop ∩ medicost        | 0.8831352 | 5.51e-10 |
#> |        temp ∩ gdpd ∩ sensepop ∩ urbanpop ∩ medicost        | 0.8764631 | 4.40e-10 |
#> |    temp ∩ gdpd ∩ rdds ∩ sensepop ∩ urbanpop ∩ medicost     | 0.8747409 | 6.61e-10 |
#> |    temp ∩ popd ∩ gdpd ∩ sensepop ∩ urbanpop ∩ medicost     | 0.8740162 | 4.73e-10 |
#> | temp ∩ popd ∩ gdpd ∩ rdds ∩ sensepop ∩ urbanpop ∩ medicost | 0.8713610 | 6.91e-10 |
#> |    temp ∩ prec ∩ gdpd ∩ sensepop ∩ urbanpop ∩ medicost     | 0.8706325 | 8.13e-10 |
#> | temp ∩ prec ∩ popd ∩ gdpd ∩ sensepop ∩ urbanpop ∩ medicost | 0.8692532 | 5.63e-10 |
#> |    temp ∩ popd ∩ rdds ∩ sensepop ∩ urbanpop ∩ medicost     | 0.8658830 | 5.85e-10 |
#> 
#>  ---------- ISP Model Performance Evaluation: ---------
#>  * Number of overlay zones :  18 
#>  * Percentage of finely divided zones :  0 
#>  * Number of individual explanatory variables :  4 
#>  
#>  ## Different of response variable between a pair of overlay zones:
#> 
#> |       zone1st       |       zone2nd       | Risk |
#> |:-------------------:|:-------------------:|:----:|
#> | zonemedicost_group1 | zonemedicost_group2 |  No  |
#> | zonemedicost_group1 | zonemedicost_group4 |  No  |
#> | zonemedicost_group1 | zonemedicost_group6 | Yes  |
#> | zonemedicost_group1 | zonemedicost_group7 | Yes  |
#> | zonemedicost_group1 | zonemedicost_group8 | Yes  |
#> 
#>  #### Only the first ten pairs of interactions and overlay zones are displayed! ####
g$spd
#> # A tibble: 6 × 2
#>   variable           spd
#>   <chr>            <dbl>
#> 1 Precipitation  0.195  
#> 2 Climatezone    0.188  
#> 3 Tempchange     0.00790
#> 4 Popdensity    -0.00588
#> 5 GDP           -0.00649
#> 6 Mining        -0.0118
g1$spd
#> # A tibble: 9 × 2
#>   variable      spd
#>   <chr>       <dbl>
#> 1 medicost  0.140  
#> 2 urbanpop  0.107  
#> 3 sensepop  0.106  
#> 4 temp      0.0534 
#> 5 prec      0.0181 
#> 6 gdpd     -0.00342
#> 7 humi     -0.00704
#> 8 rdds     -0.00875
#> 9 popd     -0.00923

Created on 2024-11-12 with reprex v2.1.1

SpatLyu commented 1 week ago

Now transfer isp-related concepts and functions to the cisp package.