Skip to contents

Create Age Plot

Usage

plot_Ages(
  object,
  sample_names = NULL,
  sample_order = NULL,
  plot_mode = "ages",
  model = "Baylum",
  ...
)

Arguments

object

list or data.frame (required): Output as created by functions like AgeC14_Computation, which is a list of class BayLum.list. Alternatively the function supports a data.frame as input, however, in such a case the data.frame must resemble the ages data.frame created by the computation functions otherwise the input will be silently ignored.

sample_names

character (optional): alternative sample names used for the plotting. If the length of the provided character vector is shorter than the real number of samples, the names are recycled.

sample_order

numeric (optional): argument to rearrange the sample order, e.g., sample_order = c(4:1) plots the last sample first.

plot_mode

character (with default): allows to switch from displaying ages as points with lines ("ages") for the credible intervals to densities ("density")

...

further arguments to control the plot output, standard arguments are: cex, xlim, main, xlab, col further (non-standard) arguments are: grid (TRUE/FALSE), legend (TRUE/FALSE), legend.text (character input needed), legend.pos graphics::legend, legend.cex. Additional arguments: d_scale (scales density plots), show_ages (add ages to density plots)

Value

The function returns a plot and the data.frame used to display the data

Details

This function creates an age plot showing the mean ages along with the credible intervals. The function provides various arguments to modify the plot output, however, for an ultimate control the function returns the data.frame extracted from the input object for own plots.

Function version

0.1.5

Author

Sebastian Kreutzer, Institute of Geography, Ruprecht-Karl-University of Heidelberg (Germany), based on code written by Claire Christophe

Examples

## load data
data(DATA_C14,envir = environment())
C14Cal <- DATA_C14$C14[,1]
SigmaC14Cal <- DATA_C14$C14[,2]
Names <- DATA_C14$Names
nb_sample <- length(Names)

## Age computation
Age <- AgeC14_Computation(
   Data_C14Cal = C14Cal,
   Data_SigmaC14Cal = SigmaC14Cal,
   SampleNames = Names,
   Nb_sample = nb_sample,
   PriorAge = rep(c(20,60),nb_sample),
   Iter = 500,
   quiet = TRUE)
#> Warning: [plot_MCMC()] 'n.iter' out of range, reset to number of observations




#> 
#> 
#> >> MCMC Convergence of Age parameters <<
#> ----------------------------------------------
#> Sample name   Bayes estimate   Uppers credible interval
#> A_S-EVA-26510 	 1.001 		 1.011 
#> A_S-EVA-26506 	 1.036 		 1.114 
#> A_S-EVA-26507 	 1.015 		 1.048 
#> A_S-EVA-26508 	 0.997 		 0.998 
#> 
#> 
#> ---------------------------------------------------------------------------------------------------
#>  *** WARNING: The following information are only valid if the MCMC chains have converged  ***
#> ---------------------------------------------------------------------------------------------------
#> 
#> 
#> 
#> >> Bayes estimates of Age for each sample and credible interval <<
#> ------------------------------------------------------
#> Sample name 	 Bayes estimate  Credible interval: 
#> A_S-EVA-26510 	 41.9693848586014 
#> 						 lower bound 	 upper bound
#> 				 at level 95% 	 41.487 		 42.297 
#> 				 at level 68% 	 41.867 		 42.254 
#> ------------------------------------------------------
#> Sample name 	 Bayes estimate  Credible interval: 
#> A_S-EVA-26506 	 45.69900971696 
#> 						 lower bound 	 upper bound
#> 				 at level 95% 	 44.971 		 46.213 
#> 				 at level 68% 	 45.509 		 45.997 
#> ------------------------------------------------------
#> Sample name 	 Bayes estimate  Credible interval: 
#> A_S-EVA-26507 	 44.914309326316 
#> 						 lower bound 	 upper bound
#> 				 at level 95% 	 43.936 		 45.925 
#> 				 at level 68% 	 44.404 		 45.262 
#> ------------------------------------------------------
#> Sample name 	 Bayes estimate  Credible interval: 
#> A_S-EVA-26508 	 45.0432908333532 
#> 						 lower bound 	 upper bound
#> 				 at level 95% 	 43.944 		 46.046 
#> 				 at level 68% 	 44.54 		 45.541 
#> 
#> ------------------------------------------------------



## plot output
plot_Ages(Age)

#>        SAMPLE      AGE HPD68.MIN HPD68.MAX HPD95.MIN HPD95.MAX ALT_SAMPLE_NAME
#> 1 S-EVA-26510 41.96938    41.867    42.254    41.487    42.297              NA
#> 2 S-EVA-26506 45.69901    45.509    45.997    44.971    46.213              NA
#> 3 S-EVA-26507 44.91431    44.404    45.262    43.936    45.925              NA
#> 4 S-EVA-26508 45.04329    44.540    45.541    43.944    46.046              NA
#>   AT
#> 1  4
#> 2  3
#> 3  2
#> 4  1

## plot output
plot_Ages(Age, plot_mode = "density", legend.pos = "topright")

#>        SAMPLE      AGE HPD68.MIN HPD68.MAX HPD95.MIN HPD95.MAX ALT_SAMPLE_NAME
#> 1 S-EVA-26510 41.96938    41.867    42.254    41.487    42.297              NA
#> 2 S-EVA-26506 45.69901    45.509    45.997    44.971    46.213              NA
#> 3 S-EVA-26507 44.91431    44.404    45.262    43.936    45.925              NA
#> 4 S-EVA-26508 45.04329    44.540    45.541    43.944    46.046              NA
#>   AT
#> 1  4
#> 2  3
#> 3  2
#> 4  1