Title: | Bayesian Analysis of the Network Autocorrelation Model |
---|---|
Description: | The network autocorrelation model (NAM) can be used for studying the degree of social influence regarding an outcome variable based on one or more known networks. The degree of social influence is quantified via the network autocorrelation parameters. In case of a single network, the Bayesian methods of Dittrich, Leenders, and Mulder (2017) <DOI:10.1016/j.socnet.2016.09.002> and Dittrich, Leenders, and Mulder (2019) <DOI:10.1177/0049124117729712> are implemented using a normal, flat, or independence Jeffreys prior for the network autocorrelation. In the case of multiple networks, the Bayesian methods of Dittrich, Leenders, and Mulder (2020) <DOI:10.1177/0081175020913899> are implemented using a multivariate normal prior for the network autocorrelation parameters. Flat priors are implemented for estimating the coefficients. For Bayesian testing of equality and order-constrained hypotheses, the default Bayes factor of Gu, Mulder, and Hoijtink, (2018) <DOI:10.1111/bmsp.12110> is used with the posterior mean and posterior covariance matrix of the NAM parameters based on flat priors as input. |
Authors: | Joris Mulder [aut, cre], Dino Dittrich [aut, ctb], Roger Leenders [aut, ctb] |
Maintainer: | Joris Mulder <[email protected]> |
License: | GPL (>= 3) |
Version: | 0.2.2 |
Built: | 2024-12-03 14:03:44 UTC |
Source: | CRAN |
The banam
function can be used for Bayesian estimation of the
network autocorrelation model (NAM). In the case of a single weight matrix, a flat prior,
the independence Jeffreys prior, and a normal prior can be specified for the network autocorrelation
parameter. In the case of multiple weight matrices, a multivariate normal prior can be specified.
banam( y, X, W, prior = "flat", prior.mean = NULL, prior.Sigma = NULL, postdraws = 5000, burnin = 1000 )
banam( y, X, W, prior = "flat", prior.mean = NULL, prior.Sigma = NULL, postdraws = 5000, burnin = 1000 )
y |
A numeric vector containing the observations of the outcome variable. |
X |
The design matrix of the predictor variables. If absent a column of ones is automatically to model the intercept. |
W |
A weight matrix (in the case of a NAM with a single weight matrix) or a list of weight matrices (in the case of a NAM with multiple weight matrices). |
prior |
A character string specifying which prior to use in the case of a NAM with a single weight matrix. The options are 'flat', 'IJ', and 'normal', for a flat prior, the independence Jeffreys prior, and a normal prior, respectively. |
prior.mean |
A scalar (or vector) specifying the prior mean(s) of the network autocorrelation(s). The default prior mean is 0. |
prior.Sigma |
A scalar (or matrix) specifying the prior variance (or prior covariance matrix) of the network autocorrelation(s). In the univariate case, the default prior variance is 1e6. In the multivariate case, the default prior covariance matrix is the identity matrix times 1e6. |
postdraws |
An integer specifying the number of posterior draws after burn-in. |
burnin |
An integer specifying the number of draws for burn-in. |
The output is an object of class banam
. For users of BANAM
, the following
are the useful objects:
rho.draws
Matrix of posterior draws for the network autocorrelation parameter(s).
beta.draws
Matrix of posterior draws for the coefficients.
sigma2.draws
Matrix of posterior draws for the error variance.
summarystats
Table with summary statistics of the posterior.
residuals
Residuals based on all posterior draws.
fitted.values
Fitted values based on all posterior draws.
Dittrich, D., Leenders, R.Th.A.J., & Mulder, J. (2017). Bayesian estimation of the network autocorrelation model. Social Network, 48, 213–236. <doi:10.1016/j.socnet.2016.09.002>
Dittrich, D., Leenders, R.Th.A.J., & Mulder, J. (2019). Network autocorrelation modeling: A Bayes factor approach for testing (multiple) precise and interval hypotheses. Sociological Methods & Research, 48, 642-676. <doi:10.1177/0049124117729712>
Dittrich, D., Leenders, R.Th.A.J., & Mulder, J. (2020). Network Autocorrelation Modeling: Bayesian Techniques for Estimating and Testing Multiple Network Autocorrelations. Sociological Methodology, 50, 168-214. <doi:10.1177/0081175020913899>
#example analyses #generate example data set.seed(234) n <- 50 d1 <- .2 Wadj1 <- sna::rgraph(n, tprob=d1, mode="graph") W1 <- sna::make.stochastic(Wadj1, mode="row") d2 <- .4 Wadj2 <- sna::rgraph(n, tprob=d2, mode="graph") W2 <- sna::make.stochastic(Wadj2, mode="row") # set rho, beta, sigma2, and generate y rho1 <- .3 K <- 3 beta <- rnorm(K) sigma2 <- 1 X <- matrix(c(rep(1, n), rnorm(n*(K-1))), nrow=n, ncol=K) y <- c((solve(diag(n) - rho1*W1))%*%(X%*%beta + rnorm(n))) #Bayesian estimation of NAM with a single weight matrix using a flat prior for rho best1 <- banam(y,X,W1) print(best1) #Bayesian estimation of NAM with two weight matrices using standard normal priors best2 <- banam(y,X,W=list(W1,W2)) print(best2) #Bayes factor testing of equality/order hypotheses using environment of package 'BFpack' BFbest2 <- BF(best2,hypothesis="rho1>rho2>0; rho1=rho2>0; rho1=rho2=0")
#example analyses #generate example data set.seed(234) n <- 50 d1 <- .2 Wadj1 <- sna::rgraph(n, tprob=d1, mode="graph") W1 <- sna::make.stochastic(Wadj1, mode="row") d2 <- .4 Wadj2 <- sna::rgraph(n, tprob=d2, mode="graph") W2 <- sna::make.stochastic(Wadj2, mode="row") # set rho, beta, sigma2, and generate y rho1 <- .3 K <- 3 beta <- rnorm(K) sigma2 <- 1 X <- matrix(c(rep(1, n), rnorm(n*(K-1))), nrow=n, ncol=K) y <- c((solve(diag(n) - rho1*W1))%*%(X%*%beta + rnorm(n))) #Bayesian estimation of NAM with a single weight matrix using a flat prior for rho best1 <- banam(y,X,W1) print(best1) #Bayesian estimation of NAM with two weight matrices using standard normal priors best2 <- banam(y,X,W=list(W1,W2)) print(best2) #Bayes factor testing of equality/order hypotheses using environment of package 'BFpack' BFbest2 <- BF(best2,hypothesis="rho1>rho2>0; rho1=rho2>0; rho1=rho2=0")
This dataset specifies the four nearest neighboring counties of 67 counties in Alabama, US. All counties that satisfy this criteria were assigned a weight of 0.25.
data(W_votes)
data(W_votes)
A matrix with 67 rows and 67 columns
Pace, R. K. and R. Barry. 1997. Quick Computation of Spatial Autoregressive Estimators. Geographical Analysis, 29, 232-47. Data can be downloaded from http://www.spatial-econometrics.com/html/jplv7.zip
This data.frame includes logarithmized data on population casting votes, of the population that is 25 years and older who completed 12th grade or higher education, on the number of owner-occupied housing units, and of aggregate income per county in Alabama, US. This data.frame can be specified as covariate matrix in the network autocorrelation model to predict the voter turnout in Alabama.
data(X_votes)
data(X_votes)
A data.frame with 67 rows and 4 columns
pop_eligible | numeric |
Logarithm of the population casting votes |
pop_college | numeric |
Logarithm of the population that is 25 years and older who completed 12th grade or higher education |
homeownership | numeric |
Logarithm of the number of owner-occupied housing units |
income | numeric |
Logarithmized aggregate income per county |
Pace, R. K. and R. Barry. 1997. Quick Computation of Spatial Autoregressive Estimators. Geographical Analysis, 29, 232-47. Data can be downloaded from http://www.spatial-econometrics.com/html/jplv7.zip
This vector contains the logarithmized voter turnout of 67 counties in Alabama, US.
data(y_votes)
data(y_votes)
A vector of the length 67
Pace, R. K. and R. Barry. 1997. Quick Computation of Spatial Autoregressive Estimators. Geographical Analysis, 29, 232-47. Data can be downloaded from http://www.spatial-econometrics.com/html/jplv7.zip