make_ntspmat | R Documentation |
make_ntspmat
generates a nearest neighbor spatial
weights matrix for an unbalanced TSCS sample used to
estimate a linear regression model.
make_ntspmat(lmobj, ci, yi, k)
lmobj |
An object created by the |
ci |
Name of a variable that identifies countries. |
yi |
Name of a variable that identifies years. |
k |
A value that determines the number of nearest neighbors. |
The output will be a list.
df <- data.frame( country = factor(c("United Kingdom","United Kingdom","Ireland","Ireland", "Netherlands","Netherlands", "Belgium","Belgium","France","France","Spain","Spain")), year = c(2018, 2019, 2018, 2019, 2018, 2019, 2018, 2019, 2018, 2019, 2018, 2019), y = rnorm(12), x = rnorm(12)) linmod <- lm(y~x,df) w <- make_ntspmat(linmod,country,year,3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.