加入新推出的
Discord 社区,展开实时讨论,获得同行支持,并直接与 Meridian 团队互动!
贝叶斯推理
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
Meridian 采用贝叶斯回归模型,将先验知识与从数据中获得的信号相结合,以估计媒体效应并量化不确定性。先验知识通过先验分布纳入模型中,而先验分布可以通过实验数据、行业经验或以前的媒体组合模型获得。
贝叶斯马尔可夫链蒙特卡洛 (MCMC) 抽样方法用于联合估计所有模型系数和形参。这包括非线性媒体转换函数的形参,例如 Adstock 和回报递减曲线。在为投资回报率和其他关键数据洞见计算点估计值和可信区间时,系统会考虑到所有形参和相应的不确定性。
贝叶斯定理
贝叶斯定理说明了如何使用可观测数据对不可观测形参进行推理,可用以下等式表示:
$$
P(\theta|data)\ =\ \dfrac{
P(data|\theta)P(\theta)
}{
\int \! P(data|\theta)P(\theta) \, \mathrm{d}\theta
}
$$
其中:
- \(\theta\) 是不可观测的相关形参
- \(P(\theta|data)\) 是后验,是贝叶斯方程的输出结果
- \(P(data|\theta)\) 是似然
- \(P(\theta)\) 是先验
必须指定似然和先验,才能对后验执行推理。
似然、先验和后验
似然是模型规范。它是一种分布,规定了在给定的模型形参值\(\theta\)条件下数据值出现的概率。进行贝叶斯分析后,系统会对形参 \(\theta\)进行推理和估计。似然的复杂度范围很广。Meridian 的似然基于分层回归模型。如需详细了解 Meridian 似然,请参阅模型规范。
先验表示在考虑数据之前,对形参概率分布的信念。贝叶斯量化不确定性的方法需要纳入先验知识。在 Meridian 中,先验分布表示在看到数据之前对营销渠道效果的信念。信息量充足的先验表示对 \(\theta\)有高度的确定性,这需要大量数据证据来改变这种信念。信息量较少的先验表示对 \(\theta\) 的值知之甚少,因此该先验的影响很小。Meridian 模型提供了具有默认值的合理先验。您可以自定义先验,例如用于投资回报率校准的先验。
后验是一种分布,表示在考虑数据后,对 \(\theta\) 的不同可能值的信念强度。根据贝叶斯定理,后验基于先验、数据和似然。如果数据中的信息很少,后验会更偏重于先验。如果数据中包含大量信息,后验则更偏重于数据。
Meridian 模型会生成所有模型形参的联合后验分布,以及每个估计指标,例如投资回报率、边际投资回报率和响应曲线。后验分布表示在观察到数据的情况下,对营销渠道效果的最新信念。
MCMC 收敛
利用马尔可夫链蒙特卡洛 (MCMC) 方法,后验抽样会收敛到目标分布。若要评估模型收敛性,可以运行多个 MCMC 链,并检查所有链是否达到相同的目标分布。
Meridian 采用 MCMC No U-Turn Sampler (NUTS) 抽样方法。形参值从概率分布中抽取,其中当前值的分布取决于前一次迭代的值。这些值形成一条链,其中每次迭代都是一组完整的模型形参值。多条链独立运行,以评估收敛性。当达到收敛时,每条链都代表目标后验分布的一个样本。然后,这些链可以合并,以进行后验推理。
检查 R-hat 值以评估 MCMC 收敛性至关重要。这些值作为模型输出的一部分提供。我们建议为所有形参获取小于 1.2 的 R-hat 值,但这并非严格的阈值。如果 R-hat 值略大于 1.2,通常可以通过运行更长的链来实现收敛。如果 R-hat 值大得多(如 2.0 或更大),或许可以通过运行更长的链来实现收敛。不过,计算时间和内存限制可能会成为障碍,因此可能有必要调整模型才能实现收敛。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-08。
[null,null,["最后更新时间 (UTC):2025-08-08。"],[[["\u003cp\u003eMeridian employs a Bayesian regression model that integrates prior knowledge and data signals to estimate media effects and quantify uncertainty.\u003c/p\u003e\n"],["\u003cp\u003eBayesian Markov Chain Monte Carlo (MCMC) methods are utilized to estimate model parameters, including those of nonlinear media transformation functions, enabling calculation of point estimates and credible intervals for ROI.\u003c/p\u003e\n"],["\u003cp\u003eThe model incorporates prior distributions, likelihood, and posterior distributions, allowing for the integration of prior knowledge and updating of beliefs based on observed data.\u003c/p\u003e\n"],["\u003cp\u003eModel convergence is assessed using MCMC chains and R-hat values, ensuring the reliability and accuracy of the results.\u003c/p\u003e\n"]]],[],null,["# Bayesian inference\n\nMeridian uses a Bayesian regression model, which combines prior\nknowledge with signals learned from data to estimate media effects and quantify\nuncertainty. Prior knowledge is incorporated into the model using prior\ndistributions, which can be informed by experiment data, industry experience, or\nprevious media mix models.\n\nBayesian Markov Chain Monte Carlo (MCMC) sampling methods are used to jointly\nestimate all model coefficients and parameters. This includes parameters of the\nnonlinear media transformation functions, such as Adstock and diminishing\nreturns curves. All parameters and corresponding uncertainty are taken into\nconsideration when calculating point estimates and credible intervals for ROI\nand other key insights.\n\nBayes' theorem\n--------------\n\nBayes' theorem tells how you can use observable data to make inferences about\nunobservable parameters, which can be expressed as the following equation: \n$$ P(\\\\theta\\|data)\\\\ =\\\\ \\\\dfrac{ P(data\\|\\\\theta)P(\\\\theta) }{ \\\\int \\\\! P(data\\|\\\\theta)P(\\\\theta) \\\\, \\\\mathrm{d}\\\\theta } $$\n\nWhere:\n\n- \\\\(\\\\theta\\\\) is the unobservable parameter of interest\n- \\\\(P(\\\\theta\\|data)\\\\) is the posterior, and is the output of the Bayesian equation\n- \\\\(P(data\\|\\\\theta)\\\\) is the likelihood\n- \\\\(P(\\\\theta)\\\\) is the prior\n\nThe likelihood and prior must be specified to perform inference on the\nposterior.\n\nLikelihood, priors, and posteriors\n----------------------------------\n\nThe likelihood is the model specification. It is a distribution that specifies\nthe probability of the data values given the model's parameter values\n\\\\(\\\\theta\\\\). After the Bayesian analysis is performed, inferences and estimates\nare made on the parameters \\\\(\\\\theta\\\\). Likelihoods can have a wide range of\ncomplexity. Meridian's likelihood is based on a hierarchical regression\nmodel. For more information about Meridian likelihood, see [Model\nspecification](/meridian/docs/basics/model-spec).\n\nA prior represents the belief about the probability distribution of a parameter\nbefore data has been taken into account. Incorporating prior knowledge is\nrequired for the Bayesian approach of quantifying uncertainty. In\nMeridian, the prior distribution represents the beliefs about the\neffects of marketing channels before the data is seen. Informative priors\nexpress a high certainty in \\\\(\\\\theta\\\\), which requires a large amount of data\nevidence to overcome the belief. An uninformative prior is an expression of very\nlittle idea of what the value of \\\\(\\\\theta\\\\) is, and so the prior has little\ninfluence. The Meridian model provides well-reasoned [priors with\ndefault values](/meridian/docs/advanced-modeling/default-prior-distributions).\nYou can customize the priors, such as for ROI calibration.\n\nThe posterior is a distribution that represents the strength of the belief in\nthe different possible values of \\\\(\\\\theta\\\\) after the data has been taken into\naccount. The posterior is based on the prior, the data, and the likelihood\naccording to Bayes' Theorem. If there is little information in the data, the\nposterior is weighted more towards the priors. If there is extensive information\nin the data, the posterior is weighted more towards the data.\n\nThe Meridian model generates the joint posterior distribution for all\nmodel parameters, as well as every metric that is estimated, such as ROI, mROI,\nand response curves. The posterior distribution represents the updated beliefs\nabout the effects of marketing channels, given the observed data.\n\nMCMC convergence\n----------------\n\nUsing Markov Chain Monte Carlo (MCMC), the posterior sampling converges to a\ntarget distribution. Model convergence can be assessed by running multiple MCMC\nchains and checking that all chains reach the same target distribution.\n\nMeridian uses the MCMC [No U-Turn Sampler\n(NUTS)](https://www.tensorflow.org/probability/api_docs/python/tfp/experimental/mcmc/NoUTurnSampler)\nsampling method. Parameter values are drawn from a probability distribution\nwhere the distribution of the current value depends on the values of the\nprevious iteration. The values form a chain, where each iteration is a complete\nset of model parameter values. Multiple chains are run independently to assess\nconvergence. When convergence is reached, each chain represents a sample from\nthe target posterior distribution. The chains can then be merged for posterior\ninference.\n\nIt is critical that you examine R-hat values to assess MCMC convergence. These\nvalues are provided as part of the model output. We recommend obtaining an R-hat\nless than 1.2 for all parameters, although this is not a strict threshold. If\nR-hat values are slightly larger than 1.2, convergence is usually achievable by\nrunning longer chains. If R-hat values are much larger (such as 2.0 or greater),\nit might be possible to obtain convergence by running longer chains. However,\ncomputational time and memory constraints can be prohibitive, so it might be\nnecessary to adjust the model to obtain convergence."]]