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
Row | t | ersstv5a | HadEN4a | ya |
---|---|---|---|---|
Float64 | Measurem… | Measurem… | Measurem… | |
1 | 1950.12 | 28.43±0.32 | 33.94±0.17 | -5.601±0.051 |
2 | 1950.21 | 28.63±0.27 | 33.92±0.17 | -5.618±0.051 |
3 | 1950.29 | 29.2±0.29 | 33.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
Row | Dist | b₀ | b₁ | b₂ |
---|---|---|---|---|
String | Measurem… | Measurem… | Measurem… | |
1 | Bprior | -8.4±37.0 | -0.22±0.02 | 0.26±0.15 |
2 | Bpost1 | -22.0±1.6 | -0.189±0.011 | 0.635±0.042 |
3 | Bpost2 | -15.4±2.2 | -0.248±0.017 | 0.492±0.061 |