Skip to contents

Local spatial heteroscedacity

Usage

losh(x, nb, wt, a = 2, ...)

losh_perm(x, nb, wt, a = 2, nsim = 499, ...)

Arguments

x

a numeric vector.

nb

a neighbor list for example created by st_contiguity()

wt

a weights list for example created by st_weights()

a

the exponent applied to the local residuals

...

methods passed to spdep::LOSH

nsim

number of simulations to run

Value

a data.frame with columns

  • hi: the observed statistic

  • e_hi: the sample average

  • var_hi: the sample variance

  • z_hi the approximately Chi-square distributed test statistic

  • x_bar_i: the local spatially weight mean for observation i

  • ei: residuals

Examples

nb <- st_contiguity(guerry)
wt <- st_weights(nb)
x <- guerry$crime_pers
losh(x, nb, wt)
#>            hi e_hi    var_hi       z_hi  x_bar_i           ei
#> 1  0.42563150    1 0.3894939  2.1855618 23047.50 3.390151e+07
#> 2  2.07958219    1 0.2532512 16.4230798 26919.67 4.811734e+05
#> 3  1.84873198    1 0.2532512 14.5999870 26195.50 3.041522e+05
#> 4  0.06131293    1 0.3894939  0.3148338 14401.25 2.149889e+06
#> 5  0.03499988    1 0.5257366  0.1331461 15038.67 5.999234e+06
#> 6  0.43681771    1 0.2143247  4.0762239 15749.00 3.937563e+07
#> 7  1.02195445    1 0.5257366  3.8877049 22111.67 1.713830e+08
#> 8  0.62524134    1 0.5257366  2.3785344 13672.33 5.624000e+07
#> 9  1.38724561    1 0.3077483  9.0154567 22859.20 1.060935e+07
#> 10 0.61603841    1 0.3077483  4.0035215 11475.20 1.740392e+07
#> 11 0.83487574    1 0.2143247  7.7907566 12200.14 1.571443e+07
#> 12 0.06091759    1 0.5257366  0.2317418 13278.67 1.698678e+04
#> 13 1.02979145    1 0.5257366  3.9175184 24734.00 5.122265e+07
#> 14 1.09853046    1 0.2532512  8.6754221 11752.83 3.990659e+07
#> 15 1.02984407    1 0.3077483  6.6927691 17992.60 4.860042e+07
#> 16 0.52205384    1 0.3077483  3.3927328 21974.40 1.064325e+07
#> 17 1.84431404    1 0.2532512 14.5650971 26711.00 2.281973e+07
#> 18 2.56737439    1 0.2532512 20.2753201 19344.00 1.666272e+07
#> 19 0.27138661    1 0.2143247  2.5324810 23696.71 7.326137e+07
#> 20 0.39291206    1 0.5257366  1.4947106 25108.67 1.223834e+07
#> 21 1.29241253    1 0.2532512 10.2065666 21643.17 2.362625e+08
#> 22 1.33769567    1 0.2143247 12.4828892 18306.00 1.075184e+07
#> 23 0.04265707    1 0.7982221  0.1068802 24280.00 1.617984e+08
#> 24 0.29390902    1 0.3077483  1.9100612 14451.60 1.114291e+06
#> 25 1.09084664    1 0.2532512  8.6147407 21047.67 3.909584e+07
#> 26 1.04281881    1 0.2532512  8.2354506 21421.33 2.844444e+03
#> 27 0.22639201    1 0.7982221  0.5672407 25961.50 1.529201e+07
#> 28 0.42373924    1 0.2532512  3.3463949 10869.83 5.040773e+06
#> 29 0.55413216    1 0.2532512  4.3761467 13415.67 2.731456e+07
#> 30 0.52195360    1 0.2532512  4.1220230 17172.17 2.160410e+06
#> 31 0.48399476    1 0.3894939  2.4852494 20238.25 1.488224e+07
#> 32 0.29529066    1 0.3894939  1.5162787 12504.25 9.594506e+04
#> 33 0.72023929    1 0.2532512  5.6879442 26723.00 2.102222e+07
#> 34 2.31220222    1 0.2532512 18.2601494 21772.83 1.130217e+08
#> 35 2.02985746    1 0.3077483 13.1916741 26462.20 5.374649e+07
#> 36 0.98783506    1 0.2532512  7.8012276 19252.00 2.180890e+05
#> 37 1.64645940    1 0.3077483 10.7000399 24683.20 2.364829e+06
#> 38 0.38908276    1 0.3894939  1.9978888 20607.25 8.527860e+06
#> 39 1.41460149    1 0.2532512 11.1715292 24412.00 9.734400e+06
#> 40 0.56981855    1 0.2143247  5.3173393 19373.71 6.589033e+07
#> 41 1.27709481    1 0.3077483  8.2996067 16000.20 2.883204e+04
#> 42 0.61384968    1 0.3894939  3.1520374 23993.25 2.189538e+07
#> 43 0.53773204    1 0.2143247  5.0179197 20337.86 6.842709e+06
#> 44 0.58983165    1 0.2532512  4.6580762 16818.67 1.195888e+08
#> 45 0.78377645    1 0.2532512  6.1897160 17113.83 3.428298e+07
#> 46 0.60345256    1 0.3077483  3.9217283 13013.00 2.812181e+07
#> 47 1.00328782    1 0.1851298 10.8387489 22133.00 5.713848e+07
#> 48 0.65819988    1 0.3894939  3.3797698 24093.75 4.877975e+07
#> 49 1.05152963    1 0.2532512  8.3042426 25661.67 1.011969e+08
#> 50 0.93808660    1 0.2532512  7.4083492 22190.17 1.632833e+07
#> 51 1.36638049    1 0.3077483  8.8798580 29030.00 4.886010e+05
#> 52 0.53166821    1 0.3894939  2.7300463 16951.00 9.453673e+07
#> 53 2.31922282    1 0.3077483 15.0722069 24509.00 4.000000e+00
#> 54 0.53104812    1 0.3894939  2.7268623 24982.75 2.778056e+06
#> 55 1.65957271    1 0.7982221  4.1581729 19491.50 5.385358e+07
#> 56 0.68162031    1 0.2532512  5.3829585 24176.00 8.299210e+05
#> 57 1.33364496    1 0.5257366  5.0734336 27639.67 8.094001e+05
#> 58 1.18539711    1 0.2532512  9.3614340 21274.33 4.768823e+07
#> 59 1.12893629    1 0.2532512  8.9155461 24510.33 1.458222e+07
#> 60 1.25289279    1 0.7982221  3.1392085 30166.00 4.991422e+07
#> 61 1.80441074    1 0.2532512 14.2499689 23459.00 3.847721e+07
#> 62 0.44309432    1 0.5257366  1.6856133 16184.00 2.894440e+05
#> 63 0.29915866    1 0.5257366  1.1380552 18002.00 3.339684e+07
#> 64 1.11027963    1 0.7982221  2.7818815 10910.00 1.748912e+07
#> 65 1.63760586    1 0.3894939  8.4088907 16251.25 1.554134e+07
#> 66 0.25142223    1 0.7982221  0.6299556 15572.00 6.771644e+07
#> 67 0.78098937    1 0.3894939  4.0102777 25884.25 5.028583e+07
#> 68 1.53711112    1 0.3077483  9.9894054 23020.60 4.645786e+05
#> 69 0.97710928    1 0.2143247  9.1180282 26495.00 3.594816e+06
#> 70 0.68191745    1 0.2532512  5.3853051 24690.50 8.505451e+07
#> 71 0.94434450    1 0.7982221  2.3661197 17339.00 1.151924e+07
#> 72 1.69938328    1 0.5257366  6.4647703 25522.33 5.137067e+07
#> 73 0.97749972    1 0.1851298 10.5601541 18970.00 1.043936e+07
#> 74 0.58088188    1 0.2532512  4.5873972 19701.83 5.219822e+07
#> 75 1.13689616    1 0.3077483  7.3884812 21841.00 1.184048e+07
#> 76 0.90616976    1 0.3077483  5.8890323 24520.40 8.229393e+07
#> 77 0.36532589    1 0.3077483  2.3741865 14025.80 1.013646e+06
#> 78 1.00546440    1 0.2532512  7.9404517 14565.17 5.055003e+04
#> 79 0.03176969    1 0.5257366  0.1208578 13306.67 2.613611e+04
#> 80 0.23983268    1 0.2532512  1.8940301 12579.00 9.940090e+05
#> 81 0.76525616    1 0.3894939  3.9294897 21529.50 4.935062e+05
#> 82 1.76009049    1 0.2532512 13.8999587 23474.50 7.164776e+07
#> 83 2.49737804    1 0.2532512 19.7225381 24373.17 6.588839e+07
#> 84 0.97788776    1 0.2532512  7.7226708 19900.50 1.135290e+06
#> 85 0.61500983    1 0.3077483  3.9968369 23373.60 2.881113e+07
losh(x, nb, wt, var_hi = FALSE)
#>            hi  x_bar_i           ei
#> 1  0.42563150 23047.50 3.390151e+07
#> 2  2.07958219 26919.67 4.811734e+05
#> 3  1.84873198 26195.50 3.041522e+05
#> 4  0.06131293 14401.25 2.149889e+06
#> 5  0.03499988 15038.67 5.999234e+06
#> 6  0.43681771 15749.00 3.937563e+07
#> 7  1.02195445 22111.67 1.713830e+08
#> 8  0.62524134 13672.33 5.624000e+07
#> 9  1.38724561 22859.20 1.060935e+07
#> 10 0.61603841 11475.20 1.740392e+07
#> 11 0.83487574 12200.14 1.571443e+07
#> 12 0.06091759 13278.67 1.698678e+04
#> 13 1.02979145 24734.00 5.122265e+07
#> 14 1.09853046 11752.83 3.990659e+07
#> 15 1.02984407 17992.60 4.860042e+07
#> 16 0.52205384 21974.40 1.064325e+07
#> 17 1.84431404 26711.00 2.281973e+07
#> 18 2.56737439 19344.00 1.666272e+07
#> 19 0.27138661 23696.71 7.326137e+07
#> 20 0.39291206 25108.67 1.223834e+07
#> 21 1.29241253 21643.17 2.362625e+08
#> 22 1.33769567 18306.00 1.075184e+07
#> 23 0.04265707 24280.00 1.617984e+08
#> 24 0.29390902 14451.60 1.114291e+06
#> 25 1.09084664 21047.67 3.909584e+07
#> 26 1.04281881 21421.33 2.844444e+03
#> 27 0.22639201 25961.50 1.529201e+07
#> 28 0.42373924 10869.83 5.040773e+06
#> 29 0.55413216 13415.67 2.731456e+07
#> 30 0.52195360 17172.17 2.160410e+06
#> 31 0.48399476 20238.25 1.488224e+07
#> 32 0.29529066 12504.25 9.594506e+04
#> 33 0.72023929 26723.00 2.102222e+07
#> 34 2.31220222 21772.83 1.130217e+08
#> 35 2.02985746 26462.20 5.374649e+07
#> 36 0.98783506 19252.00 2.180890e+05
#> 37 1.64645940 24683.20 2.364829e+06
#> 38 0.38908276 20607.25 8.527860e+06
#> 39 1.41460149 24412.00 9.734400e+06
#> 40 0.56981855 19373.71 6.589033e+07
#> 41 1.27709481 16000.20 2.883204e+04
#> 42 0.61384968 23993.25 2.189538e+07
#> 43 0.53773204 20337.86 6.842709e+06
#> 44 0.58983165 16818.67 1.195888e+08
#> 45 0.78377645 17113.83 3.428298e+07
#> 46 0.60345256 13013.00 2.812181e+07
#> 47 1.00328782 22133.00 5.713848e+07
#> 48 0.65819988 24093.75 4.877975e+07
#> 49 1.05152963 25661.67 1.011969e+08
#> 50 0.93808660 22190.17 1.632833e+07
#> 51 1.36638049 29030.00 4.886010e+05
#> 52 0.53166821 16951.00 9.453673e+07
#> 53 2.31922282 24509.00 4.000000e+00
#> 54 0.53104812 24982.75 2.778056e+06
#> 55 1.65957271 19491.50 5.385358e+07
#> 56 0.68162031 24176.00 8.299210e+05
#> 57 1.33364496 27639.67 8.094001e+05
#> 58 1.18539711 21274.33 4.768823e+07
#> 59 1.12893629 24510.33 1.458222e+07
#> 60 1.25289279 30166.00 4.991422e+07
#> 61 1.80441074 23459.00 3.847721e+07
#> 62 0.44309432 16184.00 2.894440e+05
#> 63 0.29915866 18002.00 3.339684e+07
#> 64 1.11027963 10910.00 1.748912e+07
#> 65 1.63760586 16251.25 1.554134e+07
#> 66 0.25142223 15572.00 6.771644e+07
#> 67 0.78098937 25884.25 5.028583e+07
#> 68 1.53711112 23020.60 4.645786e+05
#> 69 0.97710928 26495.00 3.594816e+06
#> 70 0.68191745 24690.50 8.505451e+07
#> 71 0.94434450 17339.00 1.151924e+07
#> 72 1.69938328 25522.33 5.137067e+07
#> 73 0.97749972 18970.00 1.043936e+07
#> 74 0.58088188 19701.83 5.219822e+07
#> 75 1.13689616 21841.00 1.184048e+07
#> 76 0.90616976 24520.40 8.229393e+07
#> 77 0.36532589 14025.80 1.013646e+06
#> 78 1.00546440 14565.17 5.055003e+04
#> 79 0.03176969 13306.67 2.613611e+04
#> 80 0.23983268 12579.00 9.940090e+05
#> 81 0.76525616 21529.50 4.935062e+05
#> 82 1.76009049 23474.50 7.164776e+07
#> 83 2.49737804 24373.17 6.588839e+07
#> 84 0.97788776 19900.50 1.135290e+06
#> 85 0.61500983 23373.60 2.881113e+07
losh_perm(x, nb, wt, nsim = 49)
#>            hi  x_bar_i           ei p_sim
#> 1  0.42563150 23047.50 3.390151e+07  0.78
#> 2  2.07958219 26919.67 4.811734e+05  0.04
#> 3  1.84873198 26195.50 3.041522e+05  0.06
#> 4  0.06131293 14401.25 2.149889e+06  0.96
#> 5  0.03499988 15038.67 5.999234e+06  0.98
#> 6  0.43681771 15749.00 3.937563e+07  0.86
#> 7  1.02195445 22111.67 1.713830e+08  0.40
#> 8  0.62524134 13672.33 5.624000e+07  0.66
#> 9  1.38724561 22859.20 1.060935e+07  0.20
#> 10 0.61603841 11475.20 1.740392e+07  0.68
#> 11 0.83487574 12200.14 1.571443e+07  0.60
#> 12 0.06091759 13278.67 1.698678e+04  0.96
#> 13 1.02979145 24734.00 5.122265e+07  0.50
#> 14 1.09853046 11752.83 3.990659e+07  0.28
#> 15 1.02984407 17992.60 4.860042e+07  0.42
#> 16 0.52205384 21974.40 1.064325e+07  0.76
#> 17 1.84431404 26711.00 2.281973e+07  0.08
#> 18 2.56737439 19344.00 1.666272e+07  0.04
#> 19 0.27138661 23696.71 7.326137e+07  0.96
#> 20 0.39291206 25108.67 1.223834e+07  0.80
#> 21 1.29241253 21643.17 2.362625e+08  0.24
#> 22 1.33769567 18306.00 1.075184e+07  0.24
#> 23 0.04265707 24280.00 1.617984e+08  0.92
#> 24 0.29390902 14451.60 1.114291e+06  0.86
#> 25 1.09084664 21047.67 3.909584e+07  0.30
#> 26 1.04281881 21421.33 2.844444e+03  0.32
#> 27 0.22639201 25961.50 1.529201e+07  0.82
#> 28 0.42373924 10869.83 5.040773e+06  0.80
#> 29 0.55413216 13415.67 2.731456e+07  0.68
#> 30 0.52195360 17172.17 2.160410e+06  0.82
#> 31 0.48399476 20238.25 1.488224e+07  0.72
#> 32 0.29529066 12504.25 9.594506e+04  0.82
#> 33 0.72023929 26723.00 2.102222e+07  0.64
#> 34 2.31220222 21772.83 1.130217e+08  0.02
#> 35 2.02985746 26462.20 5.374649e+07  0.02
#> 36 0.98783506 19252.00 2.180890e+05  0.48
#> 37 1.64645940 24683.20 2.364829e+06  0.12
#> 38 0.38908276 20607.25 8.527860e+06  0.84
#> 39 1.41460149 24412.00 9.734400e+06  0.14
#> 40 0.56981855 19373.71 6.589033e+07  0.74
#> 41 1.27709481 16000.20 2.883204e+04  0.30
#> 42 0.61384968 23993.25 2.189538e+07  0.62
#> 43 0.53773204 20337.86 6.842709e+06  0.76
#> 44 0.58983165 16818.67 1.195888e+08  0.82
#> 45 0.78377645 17113.83 3.428298e+07  0.54
#> 46 0.60345256 13013.00 2.812181e+07  0.58
#> 47 1.00328782 22133.00 5.713848e+07  0.44
#> 48 0.65819988 24093.75 4.877975e+07  0.62
#> 49 1.05152963 25661.67 1.011969e+08  0.42
#> 50 0.93808660 22190.17 1.632833e+07  0.38
#> 51 1.36638049 29030.00 4.886010e+05  0.20
#> 52 0.53166821 16951.00 9.453673e+07  0.68
#> 53 2.31922282 24509.00 4.000000e+00  0.02
#> 54 0.53104812 24982.75 2.778056e+06  0.72
#> 55 1.65957271 19491.50 5.385358e+07  0.28
#> 56 0.68162031 24176.00 8.299210e+05  0.58
#> 57 1.33364496 27639.67 8.094001e+05  0.28
#> 58 1.18539711 21274.33 4.768823e+07  0.40
#> 59 1.12893629 24510.33 1.458222e+07  0.44
#> 60 1.25289279 30166.00 4.991422e+07  0.30
#> 61 1.80441074 23459.00 3.847721e+07  0.06
#> 62 0.44309432 16184.00 2.894440e+05  0.76
#> 63 0.29915866 18002.00 3.339684e+07  0.86
#> 64 1.11027963 10910.00 1.748912e+07  0.28
#> 65 1.63760586 16251.25 1.554134e+07  0.38
#> 66 0.25142223 15572.00 6.771644e+07  0.86
#> 67 0.78098937 25884.25 5.028583e+07  0.50
#> 68 1.53711112 23020.60 4.645786e+05  0.18
#> 69 0.97710928 26495.00 3.594816e+06  0.48
#> 70 0.68191745 24690.50 8.505451e+07  0.74
#> 71 0.94434450 17339.00 1.151924e+07  0.30
#> 72 1.69938328 25522.33 5.137067e+07  0.16
#> 73 0.97749972 18970.00 1.043936e+07  0.36
#> 74 0.58088188 19701.83 5.219822e+07  0.82
#> 75 1.13689616 21841.00 1.184048e+07  0.32
#> 76 0.90616976 24520.40 8.229393e+07  0.58
#> 77 0.36532589 14025.80 1.013646e+06  0.82
#> 78 1.00546440 14565.17 5.055003e+04  0.38
#> 79 0.03176969 13306.67 2.613611e+04  0.96
#> 80 0.23983268 12579.00 9.940090e+05  0.96
#> 81 0.76525616 21529.50 4.935062e+05  0.48
#> 82 1.76009049 23474.50 7.164776e+07  0.10
#> 83 2.49737804 24373.17 6.588839e+07  0.02
#> 84 0.97788776 19900.50 1.135290e+06  0.42
#> 85 0.61500983 23373.60 2.881113e+07  0.72