greta-dev / greta-dev/greta

enable mixture of well-defined continuous distributions with point masses

Open
#761 6 comments 0 reactions 0 assignees View on GitHub
distributions
Dominant language
C++
Stars
607
Forks
67
Avg merge
3d 8h
Merged PRs (30d)
1

Description

the `mixture` function is currently intended to mix well-defined continuous distributions, but it errors out when mixing continuous distributions with point masses as belwo

``` r
library(greta)
#>
#> Attaching package: 'greta'
#> The following objects are masked from 'package:stats':
#>
#> binomial, cov2cor, poisson
#> The following objects are masked from 'package:base':
#>
#> %*%, apply, backsolve, beta, chol2inv, colMeans, colSums, diag,
#> eigen, forwardsolve, gamma, identity, rowMeans, rowSums, sweep,
#> tapply
weights <- uniform(0,1,dim = 2)
#> ℹ Initialising python and checking dependencies, this may take a moment.
#> ✔ Initialising python and checking dependencies ... done!
#>
# mixing a normal with another normal
testa <- mixture(
normal(0,1),
normal(0,0.5),
weights = weights
)
# mixing a normal distribution with point mass
a <- normal(0,1,1)
b <- 0
testb <- mixture(a,b,weights = weights)
#> Error in FUN(X[[i]], ...): attempt to apply non-function
# errors out
```
however mixing distributions with point masses is useful for hurdle models (e.g., zero-inflation models) and for specifying spike-and-slab priors, we may need to enable this?

Created on 2025-01-23 with [reprex v2.0.2](https://reprex.tidyverse.org)

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the supplied R example and then trace the mixture function entry point and its handling of point masses. Compare it with the existing continuous-distribution case; done means continuous distributions can be mixed with point masses for hurdle or spike-and-slab models without the reported error, with regression coverage for the example.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
data
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.