Skip to contents

For a regressor entered through a spline or polynomial basis whose span contains the linear function (true for splines::ns(), splines::bs() and poly()), linearity means the basis coefficients are proportional to the coefficients a that reproduce x itself (x = c + B a). The test is the joint Wald test of the q - 1 restrictions that the coefficient vector is orthogonal to the complement of a, so it accepts any covariance type, including cluster-robust ones. For a test of whether the regressor matters at all, use jointtest() on its columns.

Usage

lineartest(object, variable, vcov = NULL)

Arguments

object

a "panglm" fit

variable

name of the regressor

vcov

NULL (the covariance stored on the fit) or a type passed to vcov.panglm()

Value

an object of class "panglm_jointtest", as returned by jointtest().

Validation

The package tests check that the test rejects a nonlinear curve and keeps its size under linearity, and the fixed-effects likelihood-ratio statistic against the Wald statistic.

See also

Examples

data(copd)
fit <- panglm(fev1 ~ splines::ns(crp, 3), data = copd,
              index = c("id", "visit"), model = "within", vcov = "cluster")
lineartest(fit, "crp")
#> 
#> Joint Wald test (vcov: cluster)
#> H0: the effect of crp is linear 
#> Chi-squared = 1.338, df = 2, p-value = 0.5122
#>