Learn R Programming

spsur (version 1.0.0.4)

lr_betas_spsur: Likelihood ratio for testing homogeneity constraints on beta coefficients of the SUR equations.

Description

Function lr_betas_spsur obtains a Likelihood Ratio test, LR in what follows, with the purpose of testing if some of the \(\beta\) coefficients in the G equations of the SUR model are equal. This function has a straightforward application, especially when \(G=1\), to the case of testing for the existence of structural breaks in the \(\beta\) parameters.

The function can test for the homogeneity of only one coefficient, of a few of them or even the homogeneity of all the slope terms. The testing procedure implies, first, the estimation of both a constrained and a unconstrained model and, second, the comparison of the log-likelihoods to compute the LR statistics.

Usage

lr_betas_spsur(
  Form = NULL,
  data = NULL,
  R = NULL,
  b = NULL,
  W = NULL,
  time = NULL,
  X = NULL,
  Y = NULL,
  G = NULL,
  N = NULL,
  Tm = NULL,
  p = NULL,
  type = "sim",
  printmodels = FALSE,
  cov = FALSE,
  trace = FALSE
)

Arguments

Form

An object created with the package Formula that describes the model to be estimated. This model may contain several responses (explained variables) and a varying number of regressors in each equation.

data

An object of class data.frame or a matrix.

R

A row vector of order (1xpr) with the set of r linear constraints on the beta parameters. The first restriction appears in the first p terms, the second restriction in the next p terms and so on. Default = NULL.

b

A column vector of order (rx1) with the values of the linear restrictions on the beta parameters. Default = NULL.

W

A spatial weighting matrix of order (NxN), assumed to be the same for all equations and time periods.

time

Time variable.

X

A data matrix of order (NTmGxp) with the observations of the regressors The number of covariates in the SUR model is p = \(sum(p_{g})\) where \(p_{g}\) is the number of regressors (including the intercept) in the g-th equation, g = 1,...,G). The specification of X is only necessary if not available a Formula and a data frame. Default = NULL.

Y

A column vector of order (NTmGx1), with the observations of the explained variables. The ordering of the data must be (first) equation, (second) time dimension and (third) Cross-sectional/spatial units. The specification of Y is only necessary if not available a Formula and a data frame. Default = NULL.

G

Number of equations.

N

Number of cross-section or spatial units

Tm

Number of time periods.

p

Number of regressors by equation, including the intercept. p can be a row vector of order (1xG), if the number of regressors is not the same for all the equations, or a scalar, if the G equations have the same number of regressors. The specification of p is only necessary if not available a Formula and a data frame.

type

Type of spatial model specification: "sim","slx", "slm", "sem", "sdm", "sdem" or "sarar". Default = "sim".

printmodels

Logical value: prints constrained and unconstrained models. Default = FALSE. models. Default = FALSE.

cov

Logical value to show the covariance matrix of the beta coefficients. Default = TRUE.

trace

Logical value to show intermediate results during estimation. Default = FALSE.

Value

The function estimates two variants of the same SUR model, namely, a restricted and a unrestricted version. The purpose, as indicated above, is testing homogeneity constraints between the \(\beta\) parameters of the different equations of the SUR. The output of lr_betas_spsur shows, in first place, the iteration sequence of the maximum-likelihood algorithm. Then appears the Likelihood Ratio, LR, test. The output also includes the maximum-likelihood estimation of the two models.

statistic The Values of the LR test.
p_val The p-value of the LR test.
df Degrees of freedom.
llik_unr The Log-likelihood of the unrestricted model.
llik_res The Log-likelihood of the restricted model.

References

  • Mur, J., L<U+00F3>pez, F., and Herrera, M. (2010). Testing for spatial effects in seemingly unrelated regressions. Spatial Economic Analysis, 5(4), 399-440.

See Also

spsurml, spsurtime, wald_betas

Examples

Run this code
# NOT RUN {
#################################################
######## CROSS SECTION DATA (G>1; Tm=1)  ########
#################################################

#### Example 1: Spatial Phillips-Curve. Anselin (1988, p. 203)
rm(list = ls()) # Clean memory
data(spc)
Tformula <- WAGE83 | WAGE81 ~ UN83 + NMR83 + SMSA | UN80 + NMR80 + SMSA
## H0: equal beta for SMSA in both equations.
R <- matrix(c(0,0,0,1,0,0,0,-1),nrow=1)
b <- matrix(0,ncol=1)
LR_SMSA <-  lr_betas_spsur(Form = Tformula, data = spc, W = Wspc,
                           type = "sim", R = R, b = b, trace = TRUE,
                           printmodels = TRUE)

################################################
####### PANEL DATA (G>1; Tm>1)          ########
################################################

#### Example 2: Homicides + Socio-Economics (1960-90)
# Homicides and selected socio-economic characteristics for continental
# U.S. counties.
# Data for four decennial census years: 1960, 1970, 1980 and 1990.
# \url{https://geodacenter.github.io/data-and-lab/ncovr/}
# }
# NOT RUN {
## It usually requires 1-2 minutes maximum
rm(list = ls()) # Clean memory
data(NCOVR)
Tformula <- HR80  | HR90 ~ PS80 + UE80 | PS90 + UE90
## H0: equal beta for PS80 and PS90 in both equations.
R <- matrix(c(0,1,0,0,-1,0),nrow=1)
b <- matrix(0,ncol=1)
LR_PS <-  lr_betas_spsur(Form = Tformula, data = NCOVR, W = W,
                        type = 'slm', R = R, b = b, printmodels = FALSE)

# }
# NOT RUN {
################################################################
######## PANEL DATA: TEMPORAL CORRELATIONS (nG=1; nT>1) ########
################################################################
## Example 3: with classical panel data set. Database is
##            a spatio-temporal panel
# }
# NOT RUN {
### Only execute if you have enough memory...
rm(list = ls()) # Clean memory
data(NCOVR)
N <- nrow(NCOVR)
Tm <- 4
index_time <- rep(1:Tm, each = N)
index_indiv <- rep(1:N, Tm)
pHR <- c(NCOVR$HR60, NCOVR$HR70, NCOVR$HR80, NCOVR$HR90)
pPS <- c(NCOVR$PS60, NCOVR$PS70, NCOVR$PS80, NCOVR$PS90)
pUE <- c(NCOVR$UE60, NCOVR$UE70, NCOVR$UE80, NCOVR$UE90)
pNCOVR <- data.frame(indiv = index_indiv, time = index_time,
                     HR = pHR, PS = pPS, UE = pUE)
rm(NCOVR,pHR,pPS,pUE,index_time,index_indiv)
form_pHR <- HR ~ PS + UE
# H0: equal PS beta coefficient in equations 1, 3, and 4
R <- matrix(0,nrow=2,ncol=12) # nrow = number of restrictions ; ncol = number of beta parameters
R[1,2] <- 1; R[1,8] <- -1 # PS beta coefficient in equations 1 equal to 3
R[2,2] <- 1; R[2,11] <- -1 # PS beta coefficient in equations 1 equal to 4
b <- matrix(0,nrow=2,ncol=1)
lr_partrate <-  lr_betas_spsur(Form = form_pHR, data = pNCOVR,
                               time = pNCOVR$time, W = W,
                               type = "slm", R = R, b = b, trace = TRUE,
                               printmodels = FALSE)
# }

Run the code above in your browser using DataLab