make_ntspmat: NT Spatial Weights Matrix for Unbalanced TSCS Samples.

View source: R/ntspmat.R

make_ntspmatR Documentation

NT Spatial Weights Matrix for Unbalanced TSCS Samples.

Description

make_ntspmat generates a nearest neighbor spatial weights matrix for an unbalanced TSCS sample used to estimate a linear regression model.

Usage

make_ntspmat(lmobj, ci, yi, k)

Arguments

lmobj

An object created by the lm function.

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.

Value

The output will be a list.

Examples

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)


judechays/STADL documentation built on May 12, 2022, 10:50 p.m.