breuschGodfrey: Breusch-Godfrey Statistic In colin-olito/LoLinR: Local Linear Regression for Estimating Biological Rates From Time-Series & Trace Data

Description

Modified Breusch-Godfrey Statistic \frac{n * R^2}{n}.

Usage

 1 breuschGodfrey(y, x, order = FALSE, fill = 0) 

Arguments

 y A numeric vector. x A numeric vector. order Order to which residuals are lagged. Defaults to order <- (n - k - 1), where n is the number of observations, and k is the number of parameters in the regression (2 by default). This represents the highest possible order given n. fill Defaults to fill = 0, used to fill model matrix for lagged residuals in the auxiliary regression.

Details

NOTE: This function is a (very slightly) modified version of bgtest from the lmtest package (available at https://github.com/cran/lmtest/blob/master/R/bgtest.R). We have stripped it down to minimal functionality for our purposes. All development credit goes to the authors of lmtest.

This function is a dependency for rankLocReg where it is used to calculate bgN (Breusch-Godfrey Statistic) divided by the number of observations \frac{n * R^2}{n}. For the purposes of rankLocReg, only the relative variance explained by the fitted values from the auxiliary regression and the residuals of the original regression is of interest. Calculating \frac{n * R^2}{n} preserves this information, while avoiding the introduction of strong covariance between bgN and n; an undesirable behaviour for the linearity metric L. If desired, users can reproduce a standard Breusch-Godfrey Chi-squared test of significance by running qchisq with the output bgN and df. However, we would recommend using the function bgtest from the package lmtest, as it is specifically designed for this purpose.

Value

A list with: the standard BG statistic (bg), BG/n (bgN), and d.f. (df).

Author(s)

Colin Olito.

colin-olito/LoLinR documentation built on May 13, 2019, 9:54 p.m.