55- LinearRegression model
66
77Models are intended to be used from inside an experiment
8- class (see `pymc_experiments.py
8+ class (see :py:mod:`pymc_experiments.py<.pymc_experiments.py>` old
9+ link `pymc_experiments.py
910<https://causalpy.readthedocs.io/en/latest/api_pymc_experiments.html>`_).
1011This is why the examples require some extra
1112manipulation input data, often to ensure `y` has the correct shape.
@@ -31,7 +32,7 @@ class ModelBuilder(pm.Model):
3132 - build_model: must be implemented by subclasses
3233 - fit: populates idata attribute
3334 - predict: returns predictions on new data
34- - score: returns Bayesian R^2
35+ - score: returns Bayesian :math: ` R^2`
3536 """
3637
3738 def __init__ (self , sample_kwargs : Optional [Dict [str , Any ]] = None ):
@@ -208,10 +209,15 @@ class WeightedSumFitter(ModelBuilder):
208209
209210 Defines the PyMC model:
210211
211- - y ~ Normal(mu, sigma)
212- - sigma ~ HalfNormal(1)
213- - mu = X * beta
214- - beta ~ Dirichlet(1,...,1)
212+ .. math::
213+
214+ sigma \sim HalfNormal(1)
215+
216+ beta \sim Dirichlet(1,...,1)
217+
218+ mu = X * beta
219+
220+ y \sim Normal(mu, sigma)
215221
216222 Example
217223 --------
@@ -224,18 +230,23 @@ class WeightedSumFitter(ModelBuilder):
224230 >>> wsf = WeightedSumFitter(sample_kwargs={"progressbar": False})
225231 >>> wsf.fit(X,y)
226232 Inference ...
227- """
233+ """ # noqa: W605
228234
229235 def build_model (self , X , y , coords ):
230236 """
231237 Defines the PyMC model:
232238
233- - y ~ Normal(mu, sigma)
234- - sigma ~ HalfNormal(1)
235- - mu = X * beta
236- - beta ~ Dirichlet(1,...,1)
239+ .. math::
237240
238- """
241+ sigma \sim HalfNormal(1)
242+
243+ beta \sim Dirichlet(1,...,1)
244+
245+ mu = X * beta
246+
247+ y \sim Normal(mu, sigma)
248+
249+ """ # noqa: W605
239250 with self :
240251 self .add_coords (coords )
241252 n_predictors = X .shape [1 ]
@@ -261,10 +272,14 @@ class LinearRegression(ModelBuilder):
261272
262273 Defines the PyMC model
263274
264- - y ~ Normal(mu, sigma)
265- - mu = X * beta
266- - beta ~ Normal(0, 50)
267- - sigma ~ HalfNormal(1)
275+ .. math::
276+ beta \sim Normal(0, 50)
277+
278+ sigma \sim HalfNormal(1)
279+
280+ mu = X * beta
281+
282+ y \sim Normal(mu, sigma)
268283
269284 Example
270285 --------
@@ -281,17 +296,22 @@ class LinearRegression(ModelBuilder):
281296 ... },
282297 ... )
283298 Inference...
284- """
299+ """ # noqa: W605
285300
286301 def build_model (self , X , y , coords ):
287302 """
288303 Defines the PyMC model
289304
290- - y ~ Normal(mu, sigma)
291- - mu = X * beta
292- - beta ~ Normal(0, 50)
293- - sigma ~ HalfNormal(1)
294- """
305+ .. math::
306+ beta \sim Normal(0, 50)
307+
308+ sigma \sim HalfNormal(1)
309+
310+ mu = X * beta
311+
312+ y \sim Normal(mu, sigma)
313+
314+ """ # noqa: W605
295315 with self :
296316 self .add_coords (coords )
297317 X = pm .MutableData ("X" , X , dims = ["obs_ind" , "coeffs" ])
0 commit comments