impacts.ols_sphet: Generate impacts for objects of class ols_sphet created in...

Description Usage Arguments Value Examples

View source: R/impacts.R

Description

Generate impacts for objects of class ols_sphet created in sphet

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
## S3 method for class 'ols_sphet'
impacts(
  obj,
  ...,
  tr = NULL,
  R = NULL,
  listw = NULL,
  evalues = NULL,
  tol = 1e-06,
  empirical = FALSE,
  Q = NULL
)

Arguments

obj

A spreg spatial regression object created by spreg with model ="lag"

...

Arguments passed through to methods in the coda package

tr

A vector of traces of powers of the spatial weights matrix created using trW, for approximate impact measures; if not given, listw must be given for exact measures (for small to moderate spatial weights matrices); the traces must be for the same spatial weights as were used in fitting the spatial regression

R

If given, simulations are used to compute distributions for the impact measures, returned as mcmc objects

listw

a listw object

evalues

vector of eigenvalues of spatial weights matrix for impacts calculations

tol

Argument passed to mvrnorm: tolerance (relative to largest variance) for numerical lack of positive-definiteness in the coefficient covariance matrix

empirical

Argument passed to mvrnorm (default FALSE): if true, the coefficients and their covariance matrix specify the empirical not population mean and covariance matrix

Q

default NULL, else an integer number of cumulative power series impacts to calculate if tr is given

Value

Estimate of the Average Total, Average Direct, and Average Indirect Effects

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
data(boston, package="spData")
Wb <- as(spdep::nb2listw(boston.soi), "CsparseMatrix") 
ev <- eigen(Wb)$values
trMatb <- spatialreg::trW(Wb, type="mult")

lm.D <- spreg(log(CMEDV) ~ CRIM + ZN + INDUS + CHAS + I(NOX^2) + I(RM^2) +  AGE + log(DIS), 
          data = boston.c, listw = Wb, model = "ols", Durbin =  TRUE)
summary(lm.D)
impacts(lm.D)
summary(impacts(lm.D))

lm.D2 <- spreg(log(CMEDV) ~ CRIM + ZN + INDUS + CHAS + I(NOX^2) + I(RM^2) +  AGE + log(DIS), 
               data = boston.c, listw = Wb, model = "ols", Durbin =  ~AGE)
summary(lm.D2)
impacts(lm.D2)
summary(impacts(lm.D2))

lm.D3 <- spreg(log(CMEDV) ~ CRIM + ZN +  CHAS + I(NOX^2) + I(RM^2) +  AGE, 
               data = boston.c, listw = Wb, model = "ols", Durbin =  ~AGE + INDUS )
summary(lm.D3)
impacts(lm.D3)
summary(impacts(lm.D3))

require("sf", quietly=TRUE)
columbus <- st_read(system.file("shapes/columbus.shp", package="spData")[1], quiet=TRUE)
col.gal.nb <- spdep::read.gal(system.file("weights/columbus.gal", package="spData")[1])
listw <- spdep::nb2listw(col.gal.nb)
knear <- spdep::knearneigh(cbind(columbus$X, columbus$Y), 5)
knb <- spdep::knn2nb(knear)
dist <- spdep::nbdists(knb, cbind(columbus$X, columbus$Y))
k5d <- spdep::nb2listw(knb, glist = dist, style = "B")
class(k5d) <- c("listw", "nb", "distance")
lm.D4 <- spreg(CRIME ~ INC + HOVAL, columbus, listw, Durbin=TRUE,
               model = "ols")
summary(lm.D4)
impacts(lm.D4)

lm.D5 <- spreg(CRIME ~ INC + HOVAL, columbus, listw, Durbin= ~ INC,
               model = "ols")
summary(lm.D5)
impacts(lm.D5)
summary(impacts(lm.D5))

lm.D6 <- spreg(CRIME ~ HOVAL, columbus, listw, Durbin= ~ INC,
               model = "ols")
summary(lm.D6)
summary(impacts(lm.D6))
## Not run: 
lm.D7 <- spreg(CRIME ~ INC + HOVAL, columbus, listw,
                 model = "ols", HAC = TRUE, distance = k5d, 
                                  type = "Triangular")
summary(lm.D7)
impacts(lm.D7)
summary(impacts(lm.D7))

## End(Not run)
lm.D8 <- spreg(CRIME ~ INC + HOVAL, data = columbus, listw = listw, Durbin=TRUE,
               model = "ols", distance = k5d, type = "Triangular")
summary(lm.D8)
impacts(lm.D8)
summary(impacts(lm.D8))


lmD.9 <- spreg(CRIME ~ INC + HOVAL, data = columbus, listw = listw, Durbin= ~ INC,
               model = "ols", distance = k5d, type = "Parzen")
               
impacts(lmD.9)

lmD.10 <- spreg(CRIME ~ HOVAL, columbus, listw, Durbin= ~ INC,
                model = "ols", distance = k5d, type = "Bisquare")
summary(lmD.10)
summary(impacts(lmD.10))

sphet documentation built on Jan. 6, 2022, 1:06 a.m.