Omega.WLS.ROImatchMatLab: Weighing Matrix for ROI-WLS (WREG)

Description Usage Arguments Details Value Examples

Description

Omega.WLS.ROImatchMatLab calculates the weighting function for a weighted least-squares regression using regions-of-influence. This is largely legacy code to match WREG v. 1.05 idiosyncrasies.

Usage

1
Omega.WLS.ROImatchMatLab(Y.all, X.all, LP3.all, RecordLengths.all, NDX)

Arguments

Y.all

The dependent variable of interest at all sites in the network, with any transformations already applied.

X.all

The independent variables at all sites in the network, with any transformations already applied. Each row represents a site and each column represents a particular independent variable. The rows must be in the same order as the dependent variables in Y.

LP3.all

A dataframe containing the fitted Log-Pearson Type III standard deviate, standard deviation and skew for all sites in the network. The names of this data frame are S, K and G. The order of the rows must be the same as Y.

RecordLengths.all

RecordLengths.all may be a matrix whose rows and columns are in the same order as Y. Each (r,c) element represents the length of concurrent record between sites r and c. The diagonal elements therefore represent each site's full record length. For “WLS”, only the at-site record lengths are needed. In this case, RecordLengths can be a vector or a matrix. Here, this should only include sites in the current region of influence.

NDX

A vector listing the indices of the sites that comprise the region of influence.

Details

This is a legacy function that matches the idiosyncrasies of WREG v. 1.05. This includes using all sites to implement the sigma regression, averaging across all record lengths, using arbitrary record lengths to estimate weights and using a new function for estimating the MSE of the basic OLS model.

This function will become obsolete once all idiosyncrasies are assessed.

Value

Omega.WLS.ROImatchMatLab returns a list with three elements:

Omega

The estimated weighting matrix.

var.modelerror.0

The estimated model error variance for a constant-value model.

var.modelerror.k

The estimated model error variance for a k-variable model.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# 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
lp3Data <- importedData$LP3f
lp3Data$K <- importedData$LP3k$AEP_0.5
Y <- importedData$Y$AEP_0.5
X <- importedData$X[c("Sand", "OutletElev", "Slope")]

#### Geographic Region-of-Influence
i <- 1 # Site of interest
n <- 10 # size of region of influence
Gdist <- vector(length=length(Y)) # Empty vector for geographic distances
for (j in 1:length(Y)) {
  if (i!=j) {
    #### Geographic distance
    Gdist[j] <- Dist.WREG(Lat1 = importedData$BasChars$Lat[i],
      Long1 = importedData$BasChars$Long[i],
      Lat2 = importedData$BasChars$Lat[j],
      Long2 = importedData$BasChars$Long[j]) # Intersite distance, miles
  } else {
    Gdist[j] <- Inf # To block self identification.
  }
}
temp <- sort.int(Gdist,index.return=TRUE)
NDX <- temp$ix[1:n] # Sites to use in this regression

# Compute weighting matrix
weightingResult <- Omega.WLS.ROImatchMatLab(Y.all = Y, X.all = X,
  LP3.all = lp3Data, RecordLengths.all = importedData$recLen, NDX = NDX)

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