Example 2

In this example, the first posterior (Bpost1 in the table below) "approaches" the basic ML solution (see Example 3), except the prior has $λ=1.0$. The final posterior (Bpost2) includes the full auto- and cross-correlation in $Σ_A$, so is different from the basic ML solution.

using CSV, DataFrames, Distributions, LinearAlgebra
import Measurements as Mm
using Measurements: ±
using MeasurementErrorModels

Munit =  Mm.Measurement{Float64}
f1 = joinpath(dirname(pathof(MeasurementErrorModels)), "../docs/src/assets/")
D2 = CSV.read(f1*"Palaui.csv", DataFrame, types=Dict([2,3,4].=>Munit))
first(D2, 3)
3×4 DataFrame
Rowtersstv5aHadEN4aya
Float64Measurem…Measurem…Measurem…
11950.1228.43±0.3233.94±0.17-5.601±0.051
21950.2128.63±0.2733.92±0.17-5.618±0.051
31950.2929.2±0.2933.9±0.17-5.842±0.051
function marginals(D::AbstractVector)
    z = mean(D[1]) .± sqrt.(var(D[1]))
    return (b₀=z[1], b₁=z[2], b₂=z[3])
end

μ₀, Σ₀ = [-0.22, 0.97*0.27], Diagonal([0.02^2, 0.15^2])
Bprior = Priors.makeprior(D2[:,2:4], MvNormal(μ₀, Σ₀), ip=1000.0)

Dbs = Bout(D2[:,2:end], Bprior=Bprior, lags=0:100)
D3 = combine(groupby(Dbs, :Dist), :value=>marginals=>AsTable)
D3
3×4 DataFrame
RowDistb₀b₁b₂
StringMeasurem…Measurem…Measurem…
1Bprior-8.4±37.0-0.22±0.020.26±0.15
2Bpost1-22.0±1.6-0.189±0.0110.635±0.042
3Bpost2-15.4±2.2-0.248±0.0170.492±0.061