istdx: Inverse Standarization

Description Usage Arguments Author(s) See Also Examples

View source: R/istdx.R

Description

This function back transforms a standarized vector/matrix z into their original values, i.e., re-scales all the values in the [0,1] interval to the original range of values z = re-scale(x) = x*[ xmax - xmin ] + xmin.

Usage

1
2
3
istdx(x, ...)
## Default S3 method:
istdx(x, xmin, xrange, ...)

Arguments

x

standarized vector or matrix to be re-scaled, all the values have to be in the range [0,1]

xmin

numeric with the minimum value(s) in the original x
-) if x is a vector, xmin has to be a real
-) if x is a matrix/data.frame, xmin has to be a vector, with the minimum values for each column of the original x. In this case, the vector of minimums can be obtained as: xmin <- apply(x, 2, min, na.rm=TRUE)

xrange

numeric with the range of value(s) in the original x
-) if x is a vector, xrange has to be a real
-) if x is a matrix/data.frame, xrange has to be a vector, with the range of values for each column of the original x. In this case, the vector of ranges can be obtained as:
xrange <- apply(x, 2,range, na.rm=TRUE)
xrange <- apply(xrange, 2, diff, na.rm=TRUE)

...

further arguments passed to or from other methods

Author(s)

Mauricio Zambrano-Bigiarini, mzb.devel@gmail

See Also

stdx, scale

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
## Loading daily streamflows at the station Oca en Ona (Ebro River basin, Spain) ##
data(OcaEnOnaQts)
x <- OcaEnOnaQts

## Computing xmin and the range of 'x'
xmin <- min(x, na.rm=TRUE)
r <- diff(range(x, na.rm=TRUE))

## Standarized variable
s <- stdx(x)

## Inverse of the standarized variable
si <- istdx(s, xmin, xrange=r)

## 'si' and 'x' should be the same
summary(x-si)

###########
### Standarizing a subset of the stations 9 to 12 in 'EbroPPtsMonthly'

## Loading the monthly time series of precipitation within the Ebro River basin.
data(EbroPPtsMonthly)

pp <- EbroPPtsMonthly[1:70,10:13]
xmin   <- apply(pp, 2, min, na.rm=TRUE)
xrange <- apply(pp, 2, range, na.rm=TRUE)
xrange <- apply(xrange, 2, diff, na.rm=TRUE)

## Standarized variable
s <- stdx(as.matrix(pp))

## Inverse of the standarized variable
si <- istdx(s, xmin, xrange)

## 'si' and 'pp' should be the same
summary(pp - si)

hydroTSM documentation built on March 13, 2020, 2:23 a.m.