strm: strm: Spatio-temporal regression model

Description Usage Arguments Details Examples

View source: R/strm.R

Description

The strm function provides maximum likelihood estimation of a spatio-temporal simultaneous autoregressive lag error model. This package is built on the errorsarlm() function from the spatialreg package.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
strm(
  formula,
  id,
  data,
  listw,
  time = 2,
  wide = FALSE,
  filter_options = NULL,
  returndf = FALSE,
  ...
)

Arguments

formula

Model formula specified by user (without lags). Any transformed variables, such as logged-variables, should be specified in the model formula.

id

Group identifier (example: state).

data

Name of dataframe.

listw

Spatial weights list object.

time

Number of time periods in the dataset. Lags will be taken for each time period. Default is 2 time periods. For a spatial-only regression model, set time=1.

wide

Boolean indicator. Takes TRUE if data is in wide format and FALSE if data is in long format. If data is in wide format, it is assumed that the user is including the temporal lags for the explanatory variables and response variable manually. Default is FALSE.

filter_options

Additional arguments to be passed to dplyr::filter(). Default is NULL.

returndf

Logical. If modified dataframe should be returned. Default is FALSE.

...

Additional arguments to be passed to spatialreg::errorsarlm().

Details

Spatio-temporal regression model

Any transformed variables should be included in the formula statement. For example, to request gdp natural log-transformed, you would build the model formula as log(gdp).

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
library(spdep)
library(dplyr)
data("Produc", package="Ecdat")
data("usaww")
usalw <- mat2listw(usaww)
formula <- as.formula( log(gsp)  ~ log(pcap) + log(pc) + log(emp) + unemp)
out1 <- strm(formula, id="state", data=Produc, 
listw = usalw, time=2,wide=FALSE,
filter_options="year==1970 | year==1971")
out2 <- strm(formula, id="state", data=Produc, 
listw= usalw, time=2, wide = FALSE, 
filter_options="year==1970 | year==1971",
 method="Chebyshev")

strm documentation built on Jan. 19, 2022, 9:06 a.m.