Learn R Programming

segmented (version 0.2-5)

davies.test: Testing for a change in the slope

Description

Given a generalized linear model, the Davies' test can be employed to test for a non-constant regression parameter in the linear predictor.

Usage

davies.test(ogg, term, k = 10,
  alternative = c("two.sided", "less", "greater"))

Arguments

ogg
a fitted model returned by glm or lm.
term
a character string to mean the segmented variable being tested.
k
number of points where the test should be evaluated. See details.
alternative
a character string specifying the alternative hypothesis.

Value

  • A list with class 'htest' containing the following components:
  • methodtitle (character)
  • data.namethe regression model and the segmented variable being tested
  • statisticthe point at which the maximum (or the minimum if alternative="less") occurs
  • parameternumber of evaluation points
  • p.valuethe adjusted p-value

Warning

Currently davies.test does not work if the fitted model ogg has been built without the argument data.

Details

davies.test tests for a non zero difference-in-slope parameter of a segmented relationship. Roughtly speaking, the procedure computes k `naive' (i.e. assuming fixed and known the breakpoint) Wald statistics for the difference-in-slope, seeks the `best' value (according to the alternative hypothesis), and then corrects the selected (minimum) p-value. The k evaluation points are the quantiles of the variable term.

References

Davies, R.B. (1987) Hypothesis testing when a nuisance parameter is present only under the alternative. Biometrika 74, 33--43.

Examples

Run this code
set.seed(20)
z<-runif(100)
x<-rnorm(100,2)
y<-2+10*pmax(z-.5,0)+rnorm(100,0,2)
o<-lm(y~z+x)

davies.test(o,"z")
davies.test(o,"x")

Run the code above in your browser using DataLab