Learn R Programming

lfe (version 2.3-1709)

waldtest: Compute Wald test for joint linear restrictions

Description

Compute a Wald test for a linear hypothesis on some coefficients.

Usage

waldtest(object, R, r, type=c('default','iid','robust','cluster'),
lhs=NULL, df1, df2)

Arguments

object
object of class "felm", a result of a call to felm.
R
matrix, character, formula, integer or logical. Specification of which exclusions to test.
r
numerical vector.
type
character. Error structure type.
lhs
character. Name of left hand side if multiple left hand sides.
df1
integer. If you know better than the default df, specify it here.
df2
integer. If you know better than the default df, specify it here.

Value

  • The function waldtest computes and returns a named numeric vector containing the following elements.

    • pis the p-value for the Chi^2-test
    • chi2is the Chi^2-distributed statistic.
    • df1is the degrees of freedom for the Chi^2 statistic.
    • p.Fis the p-value for the F statistics
    • Fis the F-distributed statistic.
    • df2is the additional degrees of freedom for the F statistic.

    The return value has an attribute 'formula' which encodes the restrictions.

Details

The function waldtest computes a Wald test for the H0: R beta = r, where beta is the estimated vector coef(object).

If R is a character, integer, or logical vector it is assumed to specify a matrix which merely picks out a subset of the coefficients for joint testing. If r is not specified, it is assumed to be a zero vector of the appropriate length. R can also be a formula which is linear in the estimated coefficients, e.g. of the type ~Q-2|x-2*z which will test the joint hypothesis Q=2 and x=2*z. In case of an IV-estimation, the names for the endogenous variables in coef(object) are of the type "`Q(fit)`" which is a bit dull to type; if all the endogenous variables are to be tested they can be specified as "endovars". It is also possible to specify an endogenous variable simply as "Q", and waldtest will add the other syntactic sugar to obtain "`Q(fit)`".

The type argument works as follows. If type=='default' it is assumed that the residuals are i.i.d., unless a cluster structure was specified to felm. If type=='robust', a heteroscedastic structure is assumed, even if a cluster structure was specified in felm.

Examples

Run this code
x <- rnorm(10000)
x2 <- rnorm(length(x))
y <- x - 0.2*x2 + rnorm(length(x))
#Also works for lm
summary(est <- lm(y ~ x + x2  ))
# We do not reject the true values
waldtest(est, ~ x-1|x2+0.2|`(Intercept)`)

Run the code above in your browser using DataLab