Description Usage Arguments Details Value Examples
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.
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)
|
alpha |
A number, required only for “GLS” and “GLSskew”.
|
theta |
A number, required only for “GLS” and “GLSskew”.
|
Independent |
A dataframe containing three variables: |
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 |
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”,
|
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 |
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 |
Peak |
A logical. Indicates if the event being modeled is a Peak flow
event or 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 |
DistMeth |
Required for “GLS” and “GLSskew”. A value of
|
regSkew |
A logical vector indicating if regional skews are provided with
an adjustment required for uncertainty therein ( |
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.
Omega.GLS.ROImatchMatLab
returns a list with two elements:
GSQ |
The estimated model error variance. |
Omega |
The estimated weighting matrix. |
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.