gamma_test {sr} | R Documentation |
Estimate Smoothness in an Input/output Dataset
Description
The gamma test measures mean squared error in an input/output data set, relative to an arbitrary, unknown smooth function. This can usually be interpreted as testing for the existence of a causal relationship, and estimating the expected error of the best smooth model that could be built on that relationship.
Usage
gamma_test(
predictors,
target,
n_neighbors = 10,
eps = 0,
plot = FALSE,
caption = "",
verbose = FALSE
)
Arguments
predictors |
A Numeric vector or matrix whose columns are proposed inputs to a predictive function. |
target |
A Numeric vector, the output variable that is to be predicted |
n_neighbors |
An Integer, the number of near neighbors to use in calculating gamma |
eps |
The error term passed to the approximate near neighbor search. The default value of zero means that exact near neighbors will be found, but time will be O(M^2), where an approximate search can run in O(M*log(M)) |
plot |
A Logical variable, whether to plot the delta/gamma graph. |
caption |
A character string which will be the caption for the plot if plot = TRUE |
verbose |
A Logical variable, whether to return details of the computation |
Value
If verbose == FALSE, a list containing Gamma and the vratio, If verbose == TRUE, that list plus the distances from each point to its near neighbors, the average of squared distances, and the value returned by lm on the delta and gamma averages. Gamma is Coefficient 1 of lm.
References
https://royalsocietypublishing.org/doi/10.1098/rspa.2002.1010, https://link.springer.com/article/10.1007/s10287-003-0006-1, https://smoothregression.com
Examples
he <- embed(henon_x, 3)
t <- he[ , 1]
p <- he[ ,2:3]
gamma_test(predictors = p, target = t)