Skip to content

Dimension mismatch when using Pathfinder object as initial values #975

Closed
@mhollanders

Description

@mhollanders

Hi,

The following Stan program declares mu as a matrix with 1 column.

data {
  int N;
  vector[N] y;
}

parameters {
  matrix[N, 1] mu;
  real<lower=0> sigma;
}

model {
  target += normal_lupdf(y | mu[:, 1] , sigma);
}

After running Pathfinder and using this object as initial values for HMC, the following error is reported:

mod <- cmdstan_model("test.stan")
data <- list(N = 100, y = rnorm(100))
pf <- mod$pathfinder(data = data)
fit <- mod$sample(data = data, init = pf)


Chain 1 Unrecoverable error evaluating the log probability at the initial value.
Chain 1 Exception: mismatch in number dimensions declared and found in context; processing stage=parameter initialization; variable name=mu; dims declared=(100,1); dims found=(100)

So it seems like Stan doesn't recognise that mu should be a matrix.

Thanks,

Matt

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions