greta-dev / greta

simple and scalable statistical modelling in R
https://greta-stats.org
Other
539 stars 63 forks source link

weird error message when trying to initialise a simplex #749

Open goldingn opened 1 week ago

goldingn commented 1 week ago

Different than #748, here we get an R error message about a missing function when try to set initial values for a simplex variable, rather than another object in a model that also contains a simplex variable.

Maybe both issues relate to there not being a function to map back from simplex variables to an appropriate free state?

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
x <- simplex_variable(3)
y <- normal(0, 1)
#> ℹ Initialising python and checking dependencies, this may take a moment.
#> ✔ Initialising python and checking dependencies ... done!
#> 
z <- x * y
m <- model(z)
inits <- initials(x = t(c(0.1, 0.2, 0.7)))
mcmc(m, initial_values = inits)
#> Only one set of initial values was provided, and was used for all chains
#> Error in fun(data): could not find function "fun"

Created on 2024-11-12 with reprex v2.0.2