Leverage: Leverage Statistics (WREG)

Description Usage Arguments Details Value Examples

Description

The Leverage function calculates the leverage statistics for each observation in the regression.

Usage

1
Leverage(X, Omega, Ch = NA, x0 = NA, ROI = FALSE)

Arguments

X

contains independent variables. A leading constant of one is included if a constant is included in the regression. Each row represents a unique observation.

Omega

is the weighting matrix used for regression fitting

Ch

allows the user to specify a custom criteria for testing. If not specified, the default is 4 for region-of-influence regression and 2 elsewise.

x0

is used only in the case of region-of-influence regression. It contains the independent variables of a specific site against which to calculate the leverage.

ROI

is a logical vector specifying if the regression is or is not region-of-influence regression

Details

Leverage is a measure of how far way the independent variables of an observation are from the other observations in the regression set. A leverage is considered significant if the absolute value of the leverage is greater than the critical value. These calculations are based on equations 40, 41 and 42 of the WREG v. 1.0 manual.

Value

The function returns a list as output. This list contains:

Leverage

A vector indicating the leverage of each observation. This is a vector whose length equals the number of rows in X.

Limit

A number indicating the critical value of leverage for this data set.

Significant

A logical vector the same size as Leverage. It indicates if the leverage is significant for each observation.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
# Import some example data
peakFQdir <- paste0(
  file.path(system.file("exampleDirectory", package = "WREG"),
    "pfqImport"))
gisFilePath <- file.path(peakFQdir, "pfqSiteInfo.txt")
importedData <- importPeakFQ(pfqPath = peakFQdir, gisFile = gisFilePath)

# Run a simple regression
Y <- importedData$Y$AEP_0.5
X <- importedData$X[c("Sand", "OutletElev", "Slope")]
transY <- "none"
result <- WREG.OLS(Y, X, transY)

# calculate leverage of each point
leverageResult <- Leverage(X = X, 
  Omega = result$Weighting)

USGS-R/WREG documentation built on May 9, 2019, 6:48 p.m.