Search code examples
rlaglmhypothesis-test

Passing hypothesis in wald.test in R


Please forgive as i am new to this forum. The study requires to check the sum of coefficients=0. The test can be conducted using eviews like c(2)+c(3)+c(4)=0, where 2 is the coefficient of 2nd term and hence forth. The code for the same using R is

    require(Hmisc)#this package is used to generate lags
    require(aod)#this package is used to conduct wald test
    output<-lm(formula = s_dep ~ m_dep + Lag(m_dep,-1) + Lag(m_dep,-2) + s_rtn, data = qs_eq_comm)
    wald.test(b=coef(object=output),Sigma=vcov(object=output), Terms=2:4, H0=2+3+4)
#H0=2+3+4 checks if the sum is zero

This gives error : Error in wald.test(b = coef(object = output), Sigma = vcov(object = output), : Vectors of tested coefficients and of null hypothesis have different lengths. As per the aod package the documentation specifies the format as

wald.test(Sigma, b, Terms = NULL, L = NULL, H0 = NULL,df = NULL, verbose = FALSE)

Please help to conduct this test.


Solution

  • In wald.test function either T or L can passed as the parameter. L is a matrix conformable to b, such as its product with b i.e., L %*% b gives the linear combinations of the coefficients to be tested. Create L matrix first and then conduct wald test.

    l<-cbind(0,+1,+1,+1,0)
    wald.test(b=coef(object=output),Sigma=vcov(object=output), L=l)