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 = 12
thirdAge = 22
peaksAt = c(firstAge, secondAge, thirdAge)
ageLabels = c(0, 2, 5, 10, 20, 40, 80)
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] "3 peak synthetic"
Generate a sample of nS
nS <- sampleNs(synthetic_LambdaS$lambdaS)
The values of nS are: 6, 1, 1, 0, 1, 5, 0, 3, 4, 0, 5, 0, 18, 5, 0, 2, 2, 12, 1, 3, 2, 2, 1, 6, 9, 3, 1, 0, 4, 3, 8, 19, 3, 0, 2, 4, 0, 1, 4, 17, 4, 2, 4, 19, 4, 1, 3, 31, 10, 11, 0, 0, 1, 4, 3, 2, 10, 0, 0, 5, 1, 8, 0, 4, 0, 0, 4, 1, 2, 2, 1, 1, 1, 1, 4, 4, 3, 7, 0, 5, 7, 6, 3, 11, 0, 2, 2, 0, 4, 16, 43, 6, 0, 0, 5, 4, 2, 10, 43, 10, 3, 2
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
– 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)
BINOMFIT_CentralAge(FTdataset)
## $centralAge
## [1] 12.53
##
## $centralAgeStError
## [1] 1.003
##
## $ChiSquared
## [1] 236.2
##
## $degFreedom
## [1] 101
##
## $eta
## [1] 0.05021 0.04917 0.04893 0.04894 0.04899 0.04902 0.04904 0.04905
## [9] 0.04905 0.04905 0.04905 0.04905 0.04905 0.04905 0.04905 0.04905
## [17] 0.04905 0.04905 0.04905 0.04905
##
## $dispersion
## [1] 53.29
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)
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 | -255.00 | 514.63 | 69.12 |
| 2 | 2.00 | -215.82 | 445.51 | 0.00 |
| 3 | 3.00 | -213.89 | 450.91 | 5.40 |
| 4 | 4.00 | -213.91 | 460.20 | 14.69 |
| 5 | 5.00 | -213.91 | 469.44 | 23.93 |
| 6 | 6.00 | -213.88 | 478.64 | 33.13 |
BICmodelComparisonPlot
n = which(BICarray == min(BICarray))
favouredBIC_nPeaks <- resultsList[[n]]$PkNum
favouredBIC_ages <- resultsList[[n]]$PeakAgeResults
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 | 0.00 |
| 2 | 2 | 3 | 0.03 |
| 3 | 3 | 4 | 2.11 |
| 4 | 4 | 5 | 0.69 |
| 5 | 5 | 6 | 2.20 |
ggplot(df, aes(x = Model2, y = Prob_F_ByChanceAlone)) + geom_point(color = "blue") +
geom_line()
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 83 rows containing missing values (geom_path).
## Warning: Removed 83 rows containing missing values (geom_path).
## Warning: Removed 83 rows containing missing values (geom_path).
## Warning: Removed 83 rows containing missing values (geom_path).
# makeBinomfitSummaryPlot_6AgeModels(FTdataset, resultsOutput1,
# resultsOutput2, resultsOutput3, resultsOutput4, resultsOutput5,
# resultsOutput6, ageLabels, dataTrasformStyle='arcsinTransformation')
Bimodal Ages: The input ages are at 5, 12, 22 FTanalysis: 2 peaks fitted at 6.1523, 19.717
comparisonPlot <- compareModelSolutions(resultsList, favouredBIC_nPeaks)
comparisonPlot <- comparisonPlot + geom_vline(xintercept = peaksAt, colour = "blue") +
xlim(0, 60)
comparisonPlot