Omega.GLS.ROImatchMatLab: Weighing Matrix for ROI-GLS/skew (WREG)

Description Usage Arguments Details Value Examples

Description

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

Usage

1
2
3
Omega.GLS.ROImatchMatLab(alpha = 0.01, theta = 0.98, Independent, X, Y,
  RecordLengths, LP3, MSEGR = NA, TY = 2, Peak = T, X.all, LP3.all,
  DistMeth = 2, regSkew = FALSE)

Arguments

alpha

A number, required only for “GLS” and “GLSskew”. alpha is a parameter used in the estimated cross-correlation between site records. See equation 20 in the WREG v. 1.05 manual. The arbitrary, default value is 0.01. The user should fit a different value as needed.

theta

A number, required only for “GLS” and “GLSskew”. theta is a parameter used in the estimated cross-correlation between site records. See equation 20 in the WREG v. 1.05 manual. The arbitrary, default value is 0.98. The user should fit a different value as needed.

Independent

A dataframe containing three variables: StationID is the numerical identifier (without a leading zero) of each site, Lat is the latitude of the site, in decimal degrees, and Long is the longitude of the site, in decimal degrees. The sites must be presented in the same order as Y. Required only for “GLS” and “GLSskew”. This includes only sites in the current region of influence.

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. This includes only sites in the current region of influence.

Y

The dependent variable of interest, with any transformations already applied. This includes only sites in the current region of influence.

RecordLengths

This input is required for “WLS”, “GLS” and “GLSskew”. For “GLS” and “GLSskew”, RecordLengths should 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”, the only the at-site record lengths are needed. In the case of “WLS”, RecordLengths can be a vector or the matrix described for “GLS” and “GLSskew”. This includes only sites in the current region of influence.

LP3

A dataframe containing the fitted Log-Pearson Type III standard deviate, standard deviation and skew for each site. The names of this data frame are S, K and G. For “GLSskew”, the regional skew value must also be provided in a variable called GR. The order of the rows must be the same as Y. This includes only sites in the current region of influence.

MSEGR

A number. The mean squared error of the regional skew. Required only for “GLSskew”.

TY

A number. The return period of the event being modeled. Required only for “GLSskew”. The default value is 2. (See the Legacy details below.)

Peak

A logical. Indicates if the event being modeled is a Peak flow event or a low-flow event. TRUE indicates a Peak flow, while FALSE indicates a low-flow event.

X.all

The Independent variables for all sites in the network, 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.)

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. For “GLSskew”, the regional skew value must also be provided in a variable called GR. The order of the rows must be the same Y.

DistMeth

Required for “GLS” and “GLSskew”. A value of 1 indicates that the "Nautical Mile" approximation should be used to calculate inter-site distances. A value of 2 designates the Haversine approximation. See Dist.WREG. The default value is 2. (See the Legacy details below.)

regSkew

A logical vector indicating if regional skews are provided with an adjustment required for uncertainty therein (TRUE). The default is FALSE.

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.

See Omega.GLS for more information on the “GLS” weighting estimates.

This function will become obsolete once all idiosyncrasies are assessed.

Value

Omega.GLS.ROImatchMatLab returns a list with two elements:

GSQ

The estimated model error variance.

Omega

The estimated weighting matrix.

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
35
36
37
38
39
40
41
42
43
44
45
# 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

# Pull out characeristics of the region.
Y.i <- Y[NDX] # Predictands from region of influence
X.i <- X[NDX,] # Predictors from region of influence
# Record lengths from region of influence
RecordLengths.i <- importedData$recLen[NDX,NDX] 
# Basin characteristics (IDs, Lat, Long) from region of influence.
BasinChars.i <- importedData$BasChars[NDX,] 
LP3.i <- data.frame(lp3Data)[NDX,] # LP3 parameters from region of influence

# Compute weighting matrix
weightingResult <- Omega.GLS.ROImatchMatLab(alpha = 0.01, theta = 0.98,
  Independent = importedData$BasChars, X = X.i, Y = Y.i,
 RecordLengths = RecordLengths.i, LP3 = LP3.i, TY = 20,
  X.all = X, LP3.all = lp3Data)

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