Learn R Programming

spdgp (version 0.1.0)

make_wxg: Calculate the effect of spatially lagged X variables

Description

This function computes the contribution of spatially lagged X variables based on provided coefficients. The function takes the spatially lagged variables (wx, see make_wx()) and multiplies them by their corresponding regression coefficients (gamma), returning the predicted influence of the spatial lags. Only spatial lags are considered; the original X variables are not included in this calculation.

Usage

make_wxg(wx, gamma)

Value

A numeric vector

Arguments

wx

a matrix of spatially lagged x variables.

gamma

a vector of coefficients for the spatially lagged x variables. Its length must match the number of columns in wx.

Examples

Run this code
grid <- make_square_grid(5)
listw <- spdep::nb2listw(spdep::poly2nb(grid))
x <- make_x(25, c(0,1), c(1,4))
wx <- make_wx(x, listw)
gamma <- c(1.75, 0.4)
make_wxg(wx, gamma) 

Run the code above in your browser using DataLab