resFun {spsh}R Documentation

Calculation of the Objective Function Value

Description

Contains the objective functions to calculate (weighted) sum of squared residuals or likelihoods. The assumption made is that the residuals are identically, independantly and normally distributed. The normal distribution of the model residuals is standardly given with mean = 0, and variance = 1.if weighting is not considered. There are three methods to consider weights: a) fixed skalar values for each data type, b) a vector of weights for each data type. The vector has to have the same length as the vector of the data type. c) It is possible to estimate the

Usage

resFun(
  p,
  shpmodel = "01110",
  retdata = NULL,
  condata = NULL,
  pretrans = NULL,
  weight = NULL,
  method = "rss",
  trim.query = FALSE,
  ivap.query = NULL,
  hclip.query = FALSE,
  parL = NULL
)

Arguments

p

Vector of model parameters handed used to calculate the soil hydraulic property model values in shypFun. Depends on shpmodel and the pressure head values specified in retdata and condata

shpmodel

Character identifying the soil hydraulic property model. See shypFun.

retdata

A dataframe or matrix with 2 columns. The first with pressure head values in [cm] and the second with volumetric water contents in [cm cm-3].

condata

A dataframe or matrix with 2 columns. The first with pressure head values in [cm] and the second with hydraulic conductivity values in log10[cm d-1].

pretrans

A vector to back transform the parameters before the soil hydraulic property function values calculated.

weight

Specification of weight method. See weightFun.

method
rssDefault for the optimisation algortihm DEoptim. resFun returns skalar sum of squared (weighted) residuals.
resWeighted residuals are computed and returnd. Required for post hoc analyses.
-2logLik-2 * log-likelihood is returned.
trim.query

Default FALSE. If a trimodal soil hydraulic property function is used, this has to be specified by setting the argument to (TRUE) which ensures the sum of modal weights == 1.

ivap.query

Default is FALSE, and no ivap method is specified. See KvapFun

hclip.query

Implemented purely for future compatability.

parL

Defaults to NULL, only inserted for compatbility with modMCMC used in shypEstFun. modMCMC, only handled parameters which are estimated, other model parameters need to be passed through parL. See Details of shypEstFun.

Details

Model errors may be specified or estimated as nuisance parameters weighting the data classes. In case the model error !=1, the output statistics are weighted accordingly.

Value

Returns scalar of sum of squared (weighted) residuals or vector of weighted residuals, as specified by

useruser defined weights
noneno weights are considered, i.e. no measurement error assumed
rangerescaling (normalization of observations to the intervall [0,1]
fix1fixed scalar weight for THETA is 1/0.05^2 and weight for log10K is 1
est1Two scalar model weights 1/sigma_i^2 are treated as free parameters to be estimated by inversion, one for THETA and one for log10K. Only simultaneously estimateable

Examples

# load data
data("shpdata1")

# observations
retdata <- shpdata1$LFH1$wrc[!is.na(shpdata1$LFH1$wrc[,1]),]
condata <- shpdata1$LFH1$hcc

# 7 - resFun ------------------------------------------------------------
# soil hydraulic property model parameters, van Genuchten-Mualem
p <- c("thr" = 0.16, "ths" = 0.46, "alf1" = 0.03, "n1" = 1.42, "Ks" = 26, "tau" = .5)

# calculate weighted residuals
wres <- resFun(p, retdata = retdata, condata = condata, pretrans = NULL,
               weight = list("wth" = 0.0025, "wKh" = 1), method = "res", trim = FALSE)

## residuals of the soil water retention curve [-]
theta.wres <- wres[1:dim(retdata)[1]]

## residuals of the log10 hydraulic conductivity curve [cm/d]
log10K.wres <- wres[(dim(retdata)[1]+1) : length(wres)]


[Package spsh version 1.1.0 Index]