WREG.UW: Weighted-Multiple-Linear Regression Program (WREG)

Description Usage Arguments Details Value Examples

View source: R/WREG.UW.R

Description

The WREG.UW function executes the multiple linear regression analysis using a user-provided weighting matrix.

Usage

1
WREG.UW(Y, X, customWeight, transY, x0 = NA)

Arguments

Y

The dependent variable of interest, with any transformations already applied.

X

The independent variables in the regression, with any transformations already applied. Each row represents a site and each column represents a particular independe variable. (If a leading constant is used, it should be included here as a leading column of ones.) The rows must be in the same order as the dependent variables in Y.

customWeight

This allows the user to enter a custom weighting matrix. It is included also to provide legacy code for WREG v. 1.05. customWeight can either be a square matrix of weights with a length equal to length(Y) or a list containing three elements. The elements of the list include (1) Omega as the square weighting matrix, (2) var.modelerror.k as the estimated variance of the model errors from the k-variable model (k=ncol(X)), and (3) var.modelerror.0 as the variance of the model errors from a consant-only regression.

transY

A required character string indicating if the the dependentvariable was transformed by the common logarithm ('log10'), transformed by the natural logarithm ('ln') or untransformed ('none').

x0

A vector containing the independent variables (as above) for a particular target site. This variable is only used for ROI analysis.

Details

This function allows users to develop weights outside of the WREG program and observe the resultant regressions. Note that the weighting matrix must be invertible.

Value

All outputs are returned as part of a list. The elements of the list depend on the type of regression performed. The elements of the list may include:

Coefs

A data frame composed of four variables: (1) Coefficient contains the regression coefficeints estimated for the model, (2) Standard Error contains the standard errors of each regression coefficient, (3) tStatistic contains the Student's T-statistic of each regression coefficient and (4) pValue contains the significance probability of each regression coefficient.

ResLevInf

A data frame composed of three variables for each site in the regression. Residual contains the model residuals. Leverage contains the leverage of each site. Influence contains the influence of each site.

LevLim

The critical value of leverage. See Leverage

InflLim

The critical value of influence. See Influence

LevInf.Sig

A logical matrix indicating if the leverage (column 1) is significant and the influence (column 2) is significant for each site in the regression.

PerformanceMetrics

A list of not more than ten elements. All regression types return the mean squared error of residuals (MSE), the coefficient of determination (R2), the adjusted coefficient of determination (R2_adj) and the root mean squared error (RMSE, in percent). If customWeight contains model error variances, then the pseudo coefficient of regression (R2_pseudo), the average variance of prediction (AVP), the standard error of prediction (Sp, in percent), a vector of the individual variances of prediction for each site (VP.PredVar), the model-error variance (ModErrVar) and the standardized model error variance (StanModErr, in percent) are also returned. Details on the appropriateness and applicability of performance metrics can be found in the WREG manual.

X

The input predictors.

Y

The input observations.

fitted.values

A vector of model estimates from the regression model.

residuals

A vector of model residuals.

Weighting

The weighting matrix used to develop regression estimates.

Input

A list of input parameters for error searching. Currently empty.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
# 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)

# Organizing input data
Y <- importedData$Y$AEP_0.5
X <- importedData$X[c("Sand", "OutletElev", "Slope")]
transY <- "none"

# Make simple weighting using inverse record lengths
inverseRecLen <- diag(1 / diag(importedData$recLen))

# Run user-weights regression
result <- WREG.UW(Y, X, customWeight = inverseRecLen, transY)

wfarmer-usgs/WREG documentation built on July 24, 2020, 1:28 a.m.