Help with Error: rror in dim(free_state_draws) <- c(1, dim(free_state_draws)) : invalid first argument

I tried to run the following code from the example(https://cran.r-project.org/web/packages/greta/vignettes/get_started.html)

library(greta)

# data
x <- as_data(iris$Petal.Length)
y <- as_data(iris$Sepal.Length)

# variables and priors
int <- normal(0, 1)
coef <- normal(0, 3)
sd <- student(3, 0, 1, truncation = c(0, Inf))

# operations
mean <- int + coef * x

# likelihood
distribution(y) <- normal(mean, sd)

# defining the model
m <- model(int, coef, sd)

# plotting
plot(m)

# sampling
draws <- mcmc(m, n_samples = 1000)

But I keep getting error “Error in dim(free_state_draws) <- c(1, dim(free_state_draws)) :
invalid first argument” when I try to run the line “draws <- mcmc(m, n_samples = 1000)”

If anyone know how to solve this problem, help would be greatly appreciated.

Thanks!

There was a change in the latest version of Tensorflow Probability that broke the CRAN release of greta. There’s a fix in the GitHub version which will be heading to CRAN soon. You can install it with:

remotes::install_github("greta-dev/greta")

Thanks for the help! It’s working now.

1 Like