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 = 20
thirdAge = 30
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: 1, 11, 1, 1, 4, 22, 5, 2, 22, 0, 13, 2, 36, 0, 0, 17, 7, 9, 0, 7, 6, 0, 0, 1, 7, 2, 1, 0, 5, 0, 2, 23, 27, 0, 4, 24, 0, 2, 2, 26, 11, 3, 1, 46, 14, 4, 3, 3, 11, 2, 3, 0, 3, 5, 3, 1, 22, 6, 4, 13, 0, 2, 1, 8, 1, 0, 1, 3, 20, 2, 2, 9, 0, 4, 14, 16, 6, 6, 0, 7, 8, 23, 4, 12, 3, 4, 4, 0, 2, 5, 21, 14, 1, 1, 8, 2, 3, 13, 50, 2, 13, 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
– 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] 19.89
##
## $centralAgeStError
## [1] 1.655
##
## $ChiSquared
## [1] 384.1
##
## $degFreedom
## [1] 101
##
## $eta
## [1] 0.07302 0.07397 0.07485 0.07540 0.07562 0.07568 0.07570 0.07570
## [9] 0.07570 0.07570 0.07570 0.07570 0.07570 0.07570 0.07570 0.07570
## [17] 0.07570 0.07570 0.07570 0.07570
##
## $dispersion
## [1] 64.37
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 | -346.75 | 698.12 | 175.93 |
| 2 | 2.00 | -254.82 | 523.52 | 1.34 |
| 3 | 3.00 | -249.53 | 522.19 | 0.00 |
| 4 | 4.00 | -249.44 | 531.25 | 9.06 |
| 5 | 5.00 | -249.42 | 540.47 | 18.28 |
| 6 | 6.00 | -249.43 | 549.73 | 27.54 |
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.00 |
| 3 | 3 | 4 | 2.11 |
| 4 | 4 | 5 | 2.15 |
| 5 | 5 | 6 | 1.99 |
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 78 rows containing missing values (geom_path).
## Warning: Removed 78 rows containing missing values (geom_path).
## Warning: Removed 78 rows containing missing values (geom_path).
## Warning: Removed 78 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, 20, 30 FTanalysis: 3 peaks fitted at 4.4726, 16.9674, 31.719
comparisonPlot <- compareModelSolutions(resultsList, favouredBIC_nPeaks)
comparisonPlot <- comparisonPlot + geom_vline(xintercept = peaksAt, colour = "blue") +
xlim(0, 60)
comparisonPlot