Stochastic Data: Narrow Bimodal (5Ma and 10Ma)

When the peaks are closely spaced, binomfit will sometimes return a single age rather than resolving both components.

library(FTanalysis)
## Loading required package: ggplot2
## Loading required package: scales
## Loading required package: zipfR
## Loading required package: xtable
## Loading required package: grid
b <- 0.037725003875

# Upper and lower age limits for the random uniform age model
firstAge = 5
secondAge = 10
peaksAt = c(firstAge, secondAge)

ageLabels = c(0, 2, 5, 10, 20, 40, 80)

Create synthetic dataset

Induced track data

For the synthetic sample, we need a set of nI to base it on. We choose to set nI using one of the alpine samples.

input = readAlpsFile(i = 2)
## Warning: number of items read is not a multiple of the number of columns
## Warning: number of items read is not a multiple of the number of columns
## Warning: number of items read is not a multiple of the number of columns
## Warning: number of items read is not a multiple of the number of columns
## Warning: number of items read is not a multiple of the number of columns
nI = c(input$nI, input$nI)  # Create list of induced tracks using the Alpine dataset tracks
nGrains = length(nI)

Expected number of spontaneous tracks given the bimodal age model

synthetic_LambdaS <- sampleLambdaS_ClosureAgePeaks(nI, peaksAt, b, plot = FALSE)
## [1] "2 peak synthetic"

Generate a sample of nS

nS <- sampleNs(synthetic_LambdaS$lambdaS)

The values of nS are: 2, 1, 4, 0, 1, 4, 0, 1, 4, 1, 5, 0, 4, 2, 0, 4, 1, 4, 0, 4, 1, 0, 3, 3, 4, 3, 2, 0, 1, 2, 2, 1, 5, 0, 1, 8, 0, 5, 4, 7, 1, 1, 1, 10, 2, 1, 8, 13, 4, 3, 2, 0, 1, 5, 0, 1, 1, 3, 3, 4, 0, 2, 1, 10, 3, 0, 2, 1, 6, 1, 4, 2, 0, 4, 2, 5, 1, 0, 0, 2, 1, 4, 4, 7, 1, 2, 9, 1, 4, 6, 14, 1, 1, 0, 9, 3, 0, 4, 18, 6, 0, 0

The values of nI are: 44, 46, 58, 11, 16, 146, 23, 55, 192, 5, 106, 12, 258, 54, 2, 171, 44, 129, 9, 111, 63, 8, 41, 49, 86, 67, 50, 3, 48, 90, 210, 170, 150, 13, 21, 172, 3, 86, 132, 354, 80, 53, 21, 334, 101, 15, 130, 446, 133, 90, 18, 44, 46, 58, 11, 16, 146, 23, 55, 192, 5, 106, 12, 258, 54, 2, 171, 44, 129, 9, 111, 63, 8, 41, 49, 86, 67, 50, 3, 48, 90, 210, 170, 150, 13, 21, 172, 3, 86, 132, 354, 80, 53, 21, 334, 101, 15, 130, 446, 133, 90, 18

Create the FTdataset object and the data summary plots

– This is what FTanalysis used to hold all the input data and various processed forms of the data.


FTdataset <- makeFTdataset(nS = nS, nI = nI, rhoD = input$RhoD, relErrRhoD = input$RERhoD, 
    c = 1, K = 1, Zeta = input$Zeta, relErrZeta = input$REZeta, SqSize = NULL, 
    geomFactor = 0.5)

trackCountSummaryPlot <- plotTrackCountSummary(FTdataset)
PDplotNoOverlay <- PDplot(FTdataset, resultsOutput, plotType = 1, zeroNsOffset = 0.5)
plot2 <- PDplot(FTdataset, resultsOutput, plotType = 6, zeroNsOffset = 0.5)

layout <- matrix(c(1, 2, 3), nrow = 1, byrow = TRUE)
multiplot(trackCountSummaryPlot, PDplotNoOverlay, plot2, layout = layout)

plot of chunk Make FT dataset object

Calculate the central age

BINOMFIT_CentralAge(FTdataset)
## $centralAge
## [1] 7.692
## 
## $centralAgeStError
## [1] 0.4714
## 
## $ChiSquared
## [1] 100.9
## 
## $degFreedom
## [1] 101
## 
## $eta
##  [1] 0.03064 0.03088 0.03084 0.03081 0.03078 0.03076 0.03075 0.03074
##  [9] 0.03073 0.03072 0.03071 0.03070 0.03070 0.03069 0.03069 0.03069
## [17] 0.03068 0.03068 0.03068 0.03068
## 
## $dispersion
## [1] 6.793

Perform the binomfit analysis

Run Binomfit analysis for different numbers of peaks and hold these results in a list.

resultsOutput1 <- BINOMFIT(FTdataset, peakAgeModel = 2, PkNum = 1, K = input$K, 
    details = input$details, verbose = TRUE)
resultsOutput2 <- BINOMFIT(FTdataset, peakAgeModel = 2, PkNum = 2, K = input$K, 
    details = input$details, verbose = FALSE)
resultsOutput3 <- BINOMFIT(FTdataset, peakAgeModel = 2, PkNum = 3, K = input$K, 
    details = input$details, verbose = FALSE)
resultsOutput4 <- BINOMFIT(FTdataset, peakAgeModel = 2, PkNum = 4, K = input$K, 
    details = input$details, verbose = FALSE)
resultsOutput5 <- BINOMFIT(FTdataset, peakAgeModel = 2, PkNum = 5, K = input$K, 
    details = input$details, verbose = FALSE)
resultsOutput6 <- BINOMFIT(FTdataset, peakAgeModel = 2, PkNum = 6, K = input$K, 
    details = input$details, verbose = FALSE)

resultsList <- list(resultsOutput1, resultsOutput2, resultsOutput3, resultsOutput4, 
    resultsOutput5, resultsOutput6)

Model comparison

BIC model comparison


logLikeArray = c()
for (i in 1:6) {
    logLikeArray <- c(logLikeArray, resultsList[[i]]$logLike)
}

nAgeArray <- c(1, 2, 3, 4, 5, 6)
BICarray <- -2 * logLikeArray + (2 * nAgeArray - 1) * log(FTdataset$nGrain)
deltaBIC <- BICarray - min(BICarray)

BICdf <- data.frame(nAges = nAgeArray, logLike = logLikeArray, BIC = BICarray, 
    deltaBIC = deltaBIC)

xt <- xtable(BICdf)
BICmodelComparisonPlot <- ggplot(BICdf, aes(x = nAges, y = deltaBIC)) + geom_point(color = "blue") + 
    geom_line()

print(xt, type = "html")
nAges logLike BIC deltaBIC
1 1.00 -166.82 338.27 0.00
2 2.00 -166.84 347.55 9.28
3 3.00 -166.87 356.86 18.59
4 4.00 -166.85 366.08 27.80
5 5.00 -166.85 375.33 37.06
6 6.00 -166.86 384.60 46.32
BICmodelComparisonPlot

plot of chunk BIC model comparison


n = which(BICarray == min(BICarray))
favouredBIC_nPeaks <- resultsList[[n]]$PkNum
favouredBIC_ages <- resultsList[[n]]$PeakAgeResults

Chi2 model comparison (needs a little tidying up)

ModelCompProb <- c()
F <- c()

for (i in 1:5) {
    tmp = getChi2Comp(resultsList[[i]]$ChiSq, resultsList[[i]]$degFreedom, resultsList[[i + 
        1]]$ChiSq, resultsList[[i + 1]]$degFreedom)
    ModelCompProb[i] <- tmp$P
}

df = data.frame(Model1 = seq(1, 5), Model2 = seq(2, 6), Prob_F_ByChanceAlone = ModelCompProb * 
    100)
print(xtable(df), type = "html")
Model1 Model2 Prob_F_ByChanceAlone
1 1 2 1.40
2 2 3 0.26
3 3 4 2.11
4 4 5 2.15
5 5 6 1.76
ggplot(df, aes(x = Model2, y = Prob_F_ByChanceAlone)) + geom_point(color = "blue") + 
    geom_line()

plot of chunk unnamed-chunk-5

Summary Plots of the binomfit results

This plot summarises the data in the first 3 figures, and the models fitted by FTanalysis in the remainder. Pairs of PD plots and Radial Plots are shown for models with upto 6 peaks. The prefered model is indicated using the minimum BIC.

makeBinomfitSummaryPlot_4AgeModels(FTdataset, resultsOutput1, resultsOutput2, 
    resultsOutput3, resultsOutput4, ageLabels, dataTrasformStyle = "arcsinTransformation")
## Warning: Removed 88 rows containing missing values (geom_path).
## Warning: Removed 2 rows containing missing values (geom_segment).
## Warning: Removed 2 rows containing missing values (geom_text).
## Warning: Removed 88 rows containing missing values (geom_path).
## Warning: Removed 2 rows containing missing values (geom_segment).
## Warning: Removed 2 rows containing missing values (geom_text).
## Warning: Removed 88 rows containing missing values (geom_path).
## Warning: Removed 2 rows containing missing values (geom_segment).
## Warning: Removed 2 rows containing missing values (geom_text).
## Warning: Removed 88 rows containing missing values (geom_path).
## Warning: Removed 2 rows containing missing values (geom_segment).
## Warning: Removed 2 rows containing missing values (geom_text).

plot of chunk Plot results

# makeBinomfitSummaryPlot_6AgeModels(FTdataset, resultsOutput1,
# resultsOutput2, resultsOutput3, resultsOutput4, resultsOutput5,
# resultsOutput6, ageLabels, dataTrasformStyle='arcsinTransformation')

Compare FTanalysis results with the Bimodal Ages (in blue)

Bimodal Ages: The input ages are at 5, 10 FTanalysis: 1 peaks fitted at 7.6835

comparisonPlot <- compareModelSolutions(resultsList, favouredBIC_nPeaks)
comparisonPlot <- comparisonPlot + geom_vline(xintercept = peaksAt, colour = "blue") + 
    xlim(0, 60)
comparisonPlot
## Warning: Removed 4 rows containing missing values (geom_path).
## Warning: Removed 4 rows containing missing values (geom_path).

plot of chunk unnamed-chunk-6