impute: Imputes CRHM obs values

View source: R/impute.R

imputeR Documentation

Imputes CRHM obs values

Description

This function fills in missing (NA) values in a CRHMr obs data frame by imputation. The primary values are the data that will be infilled. The secondary values are those used to fill in the gaps. The secondary values are adjusted using the specified multipliers (regression slopes) and offsets (regression intercepts).

Usage

impute(
  primaryObs,
  primaryCols = 1,
  secondaryObs,
  secondaryCols = 1,
  multipliers = 1,
  offsets = 0,
  quiet = TRUE,
  logfile = ""
)

Arguments

primaryObs

Required. The primary CRHMr data frame of obs values.

primaryCols

Optional. A vector containing the columns to be imputed in the primary data frame, not including the datetime. If not specified, defaults to the first column.

secondaryObs

Required. The secondary CRHM obs data frame.

secondaryCols

Optional. A vector containing the columns to be imputed in the secondary data frame, not including the datetime. If not specified, defaults to the first column.

multipliers

Optional. A vector of multipliers applied to secondary observations. These may be obtained using the regress function. The default value is 1.

offsets

Optional. A vector of offsets added to secondary observations. These may be obtained using the regress function. The default value is 0.

quiet

Optional. Suppresses display of messages, except for errors. If you are calling this function in an R script, you will usually leave quiet=TRUE (i.e. the default). If you are working interactively, you will probably want to set quiet=FALSE.

logfile

Optional. Name of the file to be used for logging the action. Normally not used.

Value

If successful returns a modified version of the primaryObs data frame. The missing values in the primary data frame are replaced by corresponding values from the secondary data frame, after adjustment using the specified multipliers and offsets. If unsuccessful, returns an error.

Note

In addition to the usual notation in the logfile, this function also writes a separate logfile which summarizes the primaryObs data frame, and the new infilled data frame. The summaries are also printed to the screen, if quiet=FALSE. The logfile also contains a complete listing of the source of each value in the infilled data frame. Each value is listed as being original (unmodified from the primaryObs data frame), imputed (derived from the adjusted values of the secondaryObs data frame) or NA (missing).

Author(s)

Kevin Shook

See Also

interpolate regress distributeP

Examples

## Not run: 
v.filled <- impute(
  veg, c(1, 2, 3), st,
  c(2, 3, 1), c(0.895, 0.708, 1.1209), c(-0.8128, 0.0607, 9.005)
)

## End(Not run)

CentreForHydrology/CRHMr documentation built on April 6, 2024, 5:27 p.m.