How to specify standard deviation of prior

I’m fairly new and I thought I understood how to specify my priors but it seems like I must be doing it wrong.

I’m trying to use input data to specify the SD of a normal. I’m aware I could just transform it as I do with eff2 below. But it seems like my inputted SD is not doing anything and it’s being sampled as eff ~ normal(0, 1); if I had to guess:

data{
	real musd; // prior sd for eff
}
parameters{
	real eff;
}

transformed parameters{
      real eff2 = musd*eff;
}
model {
      print("musd",musd);
      eff ~ normal(0,musd);
}

Running it:

effs = list()
for (sdval in c(.001,.01,.1,1,1000)){
  hsam <- sampling(huh, data = list(musd =sdval),
                    chains = 1,
                    cores = 1,
                    iter = 1,
                    algorithm = 'Fixed_param',
                    seed = 1234) 
  hd <- rstan::extract(hsam)
  effs[[as.character(sdval)]] = c(hd$eff, hd$eff2)
}

I get:

> effs
$`0.001`
[1] -0.7987086944 -0.0007987087

$`0.01`
[1] -0.798708694 -0.007987087

$`0.1`
[1] -0.79870869 -0.07987087

$`1`
[1] -0.7987087 -0.7987087

$`1000`
[1]   -0.7987087 -798.7086944

Thank you!

Your Stan code looks fine but why are you using algorithm = 'Fixed_param'? It’s not going to sample from the distribution at all. You also need several “warmup” iterations before the sampler finds the correct distribution.

Ah, fixed_param must be it! And I see, I guess I was still thinking in terms of Gibbs sampling that you wouldn’t need a bunch of iterations to get the right distribution. Thank you! Here’s what it looks like if i removed “fixed_param” and increase iterations.

> effs
$`0.001`
[1] -1.309381e-03 -1.309381e-06

$`0.01`
[1] -3.02369e-03 -3.02369e-05

$`0.1`
[1] -0.14981255 -0.01498125

$`1`
[1] 0.5880846 0.5880846

$`1000`
[1]    -1023.534 -1023533.618