Closed goldingn closed 1 year ago
Here's a first pass:
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 <- normal(0,1)
#> ℹ Initialising python and checking dependencies, this may take a moment.
#> ✔ Initialising python and checking dependencies ... done!
#>
greta:::check_if_greta_model(x)
#> Error: `x` must be a <greta_model>
#> But `x` is <greta_array/array>
mcmc(x)
#> Error: `x` must be a <greta_model>
#> But `x` is <greta_array/array>
Created on 2022-08-01 by the reprex package (v2.0.1)
Although I could probably have something more bespoke for the mcmc check, to give the user more directions on how to convert greta arrays into models
Here's a second pass.
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
my_array <- normal(0,1)
#> ℹ Initialising python and checking dependencies, this may take a moment.
#> ✔ Initialising python and checking dependencies ... done!
#>
greta:::check_if_greta_model(my_array)
#> Error: `x` must be a <greta_model>
#> But `x` is <greta_array/array>
greta:::check_if_greta_array_in_mcmc(my_array)
#> Error: `x` is a <greta_array> but must be a <greta_model>
#> You can convert `x` into a <greta_model> by running:
#> `` model(`x`) ``
mcmc(my_array)
#> Error: `x` is a <greta_array> but must be a <greta_model>
#> You can convert `x` into a <greta_model> by running:
#> `` model(`x`) ``
Created on 2022-08-01 by the reprex package (v2.0.1)
I'd prefer it if R grabbed the object name - in this case, my_array
, rather than x
, but I'm not sure if that's particularly hard to do.
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 <- normal(0,1)
#> ℹ Initialising python and checking dependencies, this may take a moment.
#> ✔ Initialising python and checking dependencies ... done!
#>
mcmc(x)
#> Error: MCMC requires input to be a <greta_model> not a <greta_array>
#> ✖ `x` is a <greta_array> not a <greta_model>
#> ℹ You can convert `x` into a <greta_model> by running:
#> `model(x)`
Created on 2022-09-02 by the reprex package (v2.0.1)
Like a noob, I passed a greta array straight to mcmc(), instead of creating a a model object and passing that:
I got an error message, as I should have. But it was an uninformative error message: