https://github.com/pymc-devs/pymc-examples/blob/main/examples/samplers/lasso_block_update.ipynb
(lasso_block_update)=
:::{post} Feb 10, 2022 :tags: regression :category: beginner :author: Chris Fonnesbeck, Raul Maldonado, Michael Osthege, Thomas Wiecki, Lorenzo Toniazzi :::
Sometimes, it is very useful to update a set of parameters together. For example, variables that are highly correlated are often good to update together. In PyMC block updating is simple. This will be demonstrated using the parameter step of {class}pymc.sample.
Here we have a LASSO regression model where the two coefficients are strongly correlated. Normally, we would define the coefficient parameters as a single random variable, but here we define them separately to show how to do block updates._
First we generate some fake data.
Then define the random variables.
For most samplers, including {class}pymc.Metropolis and {class}pymc.HamiltonianMC, simply pass a list of variables to sample as a block. This works with both scalar and array parameters.
We conclude by plotting the sampled marginals and the joint distribution of beta1 and beta2.
:::{include} ../page_footer.md :::