Description Usage Arguments Value Examples
SAR estimation using Aproximate Bayesian Computation
1 2 3 |
y |
Numeric vector of length n. Dependent variable. |
X |
Numeric matrix of size n*k. Covariates. |
W |
Square matrix of class |
rho |
Numeric vector of length N. Prior of rho. |
beta |
Numeric matrix of size N*k. Prior of beta. |
sweights |
Numeric vector of length 3. Weights for the distance. |
N |
Integer scalar. Number of simulations to run. |
p |
Integer scalar. See |
no_inv |
Logical scalar. When |
no_moran |
Logical scalar. When |
keep |
Numeric scalar between (0,1]. Sets what proportion of the simulated data to keep after ranking according to distances. |
cl |
An object generated by |
... |
Ignored. |
An object of class sar_abc
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 | # Simple example ------------------------------------------------------------
set.seed(133)
# Parameters
n <- 200
rho <- .25
beta <- -.6
# Dataset
W <- netdiffuseR::rgraph_ws(n, 6, .15)
W <- W/(Matrix::rowSums(W) + 1e-15)
X <- matrix(rnorm(n*1), ncol=1)
y <- sim_sar(W, X, rho, beta)
# Estimating
res <- sar_abc(y, X, W, N=1e4)
res
# Comparing with OLS
lm(y~0+I(as.matrix(W %*% y)) +X , data.frame(y,X))
# Comparing with sphet
## Not run:
library(sphet)
spreg(y~X, data.frame(y,X), listw = mat2listw(W), model = 'lag')
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.