Last data update: 2014.03.03

R: Function to estimate end-member scores uncertainty
Mqs.uncertaintyR Documentation

Function to estimate end-member scores uncertainty

Description

The function uses either existing assemblages of end-member loadings or specified measures of centrality and dispersion as input for Monte Carlo runs to estimate the influence of different end-member loadings on end-member scores. Likewise, the influence of the weight limit quantiles (l) can be estimated.

Usage

Mqs.uncertainty(X, q, l, c, rotation = "Varimax", Vqn, Vqn.sd, runs, type.l,
  autocorrelation, ...)

Arguments

X

Numeric matrix with m samples (rows) and n variables (columns).

q

Numeric scalar with the number of end-members to include. Only necessary in combination with Vqn as matrix of user-defined end-member loadings.

l

Numeric vector with the weight tranformation limits (i.e. quantiles after Klovan & Imbrie, 1971). If the parameter is of length 1, l is assumed to be a constant, if of length 2, l defines either mean and standard deviation or minimum and maximum, depending on the value of type.l.

c

Numeric scalar specifying the constant sum scaling parameter, e.g. 1, 100, 1000; default is 100.

rotation

Character scalar, rotation type, default is "Varimax" (cf. Dietze et al., 2012). One out of the rotations provided in GPArotation is possible (cf. rotations).

Vqn

Numeric matrix with existing unscaled end-member loadings. These may represent user-defined loadings (or mean loadings if Vqn.sd is specified). See example section for further information.

Vqn.sd

Numeric matrix with standard deviations of the mean unscaled end-member loadings in Vqn.

runs

Logical scalar with the number of Monte Carlo runs to be performed, default is 100.

type.l

Character scalar with type of random l value generation. Either "rnorm" or "runif", default is "runif".

autocorrelation

Numeric scalar optionally specifying the degree of autocorrelation among classes. Autocorrelation is realised as running mean of the specified length. Only odd values are allowed.

...

Further arguments passed to the function.

Value

A list with numeric vector and matrix objects.

l

Randomised weight limit values.

Vqn

Randomised unscaled end-member loadings.

Mqs

Modelled end-member scores.

mean

Modelled end-member score means.

sd

Modelled end-member score standard deviations.

Author(s)

Michael Dietze, Elisabeth Dietze

References

Dietze E, Hartmann K, Diekmann B, IJmker J, Lehmkuhl F, Opitz S, Stauch G, Wuennemann B, Borchers A. 2012. An end-member algorithm for deciphering modern detrital processes from lake sediments of Lake Donggi Cona, NE Tibetan Plateau, China. Sedimentary Geology 243-244: 169-180.
Klovan JE, Imbrie J. 1971. An Algorithm and FORTRAN-IV Program for Large-Scale Q-Mode Factor Analysis and Calculation of Factor Scores. Mathematical Geology 3: 61-77.

See Also

test.robustness, test.parameters

Examples

## load example data set
data(X, envir = environment())

## set model run parameters
q = 3 # set number of end-members, try 4 to see the difference!
Vqn <- EMMA(X, q)$Vqn # assign unscaled end-member loadings
Vqn.sd <- Vqn * 0.2 # assign a relative standard deviation of 20 %
l.1 <- 0.2 # set l to 0.2
l.2 <- c(0.2, 0.08) # set l to mean = 0.2 and sd = 0.08
runs <-  12 # senseless value to increase computation speed

## EXAMPLE 1
## Calculate Mqs uncertainty
M <- Mqs.uncertainty(X = X,
                     q = q,
                     l = l.1,
                     runs = runs,
                     Vqn = Vqn,
                     Vqn.sd = Vqn.sd,
                     type.l = "rnorm",
                     autocorrelation = 3)

## Plot line-point graph with means and standard deviations
plot(NA,
     xlim = c(1, nrow(X)),
     ylim = c(0.5, q + 1),
     main = "End-member scores with uncertainty")
for(i in 1:q) {
  lines(1:nrow(X), M$mean[,i] - M$sd[,i] + i, col = i, lty = 2)
  lines(1:nrow(X), M$mean[,i] + i, col = i, lwd = 2)
  points(1:nrow(X), M$mean[,i] + i, col = i)
  lines(1:nrow(X), M$mean[,i] + M$sd[,i] + i, col = i, lty = 2)
}

## EXAMPLE 2
## Calculate Mqs uncertainty
M <- Mqs.uncertainty(X = X,
                     q = q,
                     l = l.2,
                     runs = runs,
                     Vqn = Vqn,
                     type.l = "rnorm")

## Plot point graph with error bars
plot(NA,
     xlim = c(1, nrow(X)),
     ylim = c(0.5, q + 1),
     main = "End-member scores with uncertainty")
for(i in 1:q) {
  points(1:nrow(X), M$mean[,i] + i, pch = 3, col = i)
  arrows(1:nrow(X), M$mean[,i] - M$sd[,i] + i,
         1:nrow(X), M$mean[,i] + M$sd[,i] + i,
         code = 3, angle = 90, length = 0.05, col = i)
}

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(EMMAgeo)
Loading required package: GPArotation
Loading required package: limSolve
Loading required package: shape
Loading required package: shiny
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/EMMAgeo/Mqs.uncertainty.Rd_%03d_medium.png", width=480, height=480)
> ### Name: Mqs.uncertainty
> ### Title: Function to estimate end-member scores uncertainty
> ### Aliases: Mqs.uncertainty
> ### Keywords: EMMA
> 
> ### ** Examples
> 
> ## load example data set
> data(X, envir = environment())
> 
> ## set model run parameters
> q = 3 # set number of end-members, try 4 to see the difference!
> Vqn <- EMMA(X, q)$Vqn # assign unscaled end-member loadings
> Vqn.sd <- Vqn * 0.2 # assign a relative standard deviation of 20 %
> l.1 <- 0.2 # set l to 0.2
> l.2 <- c(0.2, 0.08) # set l to mean = 0.2 and sd = 0.08
> runs <-  12 # senseless value to increase computation speed
> 
> ## EXAMPLE 1
> ## Calculate Mqs uncertainty
> M <- Mqs.uncertainty(X = X,
+                      q = q,
+                      l = l.1,
+                      runs = runs,
+                      Vqn = Vqn,
+                      Vqn.sd = Vqn.sd,
+                      type.l = "rnorm",
+                      autocorrelation = 3)
> 
> ## Plot line-point graph with means and standard deviations
> plot(NA,
+      xlim = c(1, nrow(X)),
+      ylim = c(0.5, q + 1),
+      main = "End-member scores with uncertainty")
> for(i in 1:q) {
+   lines(1:nrow(X), M$mean[,i] - M$sd[,i] + i, col = i, lty = 2)
+   lines(1:nrow(X), M$mean[,i] + i, col = i, lwd = 2)
+   points(1:nrow(X), M$mean[,i] + i, col = i)
+   lines(1:nrow(X), M$mean[,i] + M$sd[,i] + i, col = i, lty = 2)
+ }
> 
> ## EXAMPLE 2
> ## Calculate Mqs uncertainty
> M <- Mqs.uncertainty(X = X,
+                      q = q,
+                      l = l.2,
+                      runs = runs,
+                      Vqn = Vqn,
+                      type.l = "rnorm")
> 
> ## Plot point graph with error bars
> plot(NA,
+      xlim = c(1, nrow(X)),
+      ylim = c(0.5, q + 1),
+      main = "End-member scores with uncertainty")
> for(i in 1:q) {
+   points(1:nrow(X), M$mean[,i] + i, pch = 3, col = i)
+   arrows(1:nrow(X), M$mean[,i] - M$sd[,i] + i,
+          1:nrow(X), M$mean[,i] + M$sd[,i] + i,
+          code = 3, angle = 90, length = 0.05, col = i)
+ }
There were 32 warnings (use warnings() to see them)
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>