Skip to contents

Estimate GWR model coefficients

Usage

gwr_betas(
  formula,
  data,
  bw = "AIC",
  adaptive = TRUE,
  kernel = "gaussian",
  intercept = FALSE
)

Arguments

formula

A formula.

data

An sf object of observation data

bw

(optional) The bandwidth used in selecting models. The optimal bandwidth can be selected using one of two methods: AIC, and CV. Default will use AIC.

adaptive

(optional) Whether the bandwidth value is adaptive or not. Default is TRUE.

kernel

(optional) Kernel function. Default is gaussian.

intercept

(optional) Whether to include the intercept term in the coefficient tibble. Default is FALSE`.

Value

A tibble

Examples

# \donttest{
depression = system.file('extdata/Depression.csv',package = 'gdverse') |>
  readr::read_csv() |>
  sf::st_as_sf(coords = c('X','Y'), crs = 4326)
#> Rows: 1072 Columns: 13
#> ── Column specification ────────────────────────────────────────────────────────
#> Delimiter: ","
#> dbl (13): X, Y, Depression_prevelence, PopulationDensity, Population65, NoHe...
#> 
#>  Use `spec()` to retrieve the full column specification for this data.
#>  Specify the column types or set `show_col_types = FALSE` to quiet this message.
gwr_betas(Depression_prevelence ~ ., data = depression)
#> # A tibble: 1,072 × 10
#>    PopulationDensity Population65 NoHealthInsurance Neighbor_Disadvantage
#>                <dbl>        <dbl>             <dbl>                 <dbl>
#>  1         -0.00117       -0.0746            0.0681                 0.493
#>  2         -0.00123       -0.0861            0.0826                 0.546
#>  3         -0.00124       -0.0963            0.0999                 0.816
#>  4         -0.00120       -0.102             0.0882                 0.334
#>  5         -0.00116       -0.105             0.0931                 0.271
#>  6         -0.00121       -0.103             0.0919                 0.611
#>  7         -0.000301      -0.122             0.0801                 0.248
#>  8         -0.000261      -0.104             0.113                  0.394
#>  9         -0.000608      -0.0873            0.133                  0.851
#> 10         -0.000668      -0.0831            0.139                  0.812
#> # ℹ 1,062 more rows
#> # ℹ 6 more variables: Beer <dbl>, MentalHealthPati <dbl>, NatureParks <dbl>,
#> #   Casinos <dbl>, DrinkingPlaces <dbl>, X.HouseRent <dbl>
gwr_betas(Depression_prevelence ~ ., data = depression, intercept = TRUE)
#> # A tibble: 1,072 × 11
#>    Intercept PopulationDensity Population65 NoHealthInsurance
#>        <dbl>             <dbl>        <dbl>             <dbl>
#>  1      24.0         -0.00117       -0.0746            0.0681
#>  2      23.7         -0.00123       -0.0861            0.0826
#>  3      23.4         -0.00124       -0.0963            0.0999
#>  4      23.7         -0.00120       -0.102             0.0882
#>  5      23.4         -0.00116       -0.105             0.0931
#>  6      23.4         -0.00121       -0.103             0.0919
#>  7      22.6         -0.000301      -0.122             0.0801
#>  8      22.0         -0.000261      -0.104             0.113 
#>  9      20.5         -0.000608      -0.0873            0.133 
#> 10      20.6         -0.000668      -0.0831            0.139 
#> # ℹ 1,062 more rows
#> # ℹ 7 more variables: Neighbor_Disadvantage <dbl>, Beer <dbl>,
#> #   MentalHealthPati <dbl>, NatureParks <dbl>, Casinos <dbl>,
#> #   DrinkingPlaces <dbl>, X.HouseRent <dbl>
# }