# How to increase the effective sample size?

Hi,

I’m working on a small comparison between different variable selection/ shrinkage priors, namely Spike & Slab Priors (George & McCulloch 1993) and the Horseshoe prior (Carvalho, Polson & Scott 2008).
When sampling from these models, I receive warning messages regarding the acceptance probability and the effective sample size. The code can be found below.
How do I deal with these kinds of warnings? Just increase the tune and sample size? Or is there any other advise?

Thanks.

``````import numpy as np
import pymc3 as pm
import theano.tensor as tt

from arviz import summary, plot_trace
from theano.tensor import _shared

# Simulate data
k = 6
n = 200
sigma = 0.5
beta = np.array([-0.2, 3, 5, 0, -4, 0])
L = np.array(
[[1., 0., 0., 0., 0., 0.],
[0.5, 0.4, 0., 0., 0., 0.],
[0.2, 0.5 , -0.7, 0., 0., 0.],
[0., 0., 0., 1., 0., 0.],
[0.7, 0.06, 0.03, 0., 0.8, 0.],
[-0.7, 0., 0., 0., 0.08, .1]]
)
K = L@L.T

X = pm.MvNormal.dist(mu=np.zeros(6), cov=K, shape=[1, 6]).random(size=n)
x = _shared(X)
y = X.dot(beta) + np.random.randn(n) * sigma

# Spike and Slab Priors - George & McCulloch 1993
with pm.Model() as model1:
spike_prior = pm.Normal.dist(mu=0, sigma=0.01)
slab_prior = pm.Normal.dist(mu=0, sigma=10)

# w = pm.Bernoulli("w", p=0.5, shape=k)
w = pm.Beta("w", alpha=0.5, beta=0.5, shape=k)
weights = pm.Deterministic("weights", pm.math.stack([1.-w, w], axis=1))

beta = pm.Mixture("beta", w=weights, comp_dists=[spike_prior, slab_prior], shape=k)
sd = pm.Gamma("sd", alpha=0.05, beta=0.1, shape=1)

# Likelihood
mu = pm.Deterministic("mu", tt.dot(x, beta))
y_ = pm.Normal("y_", mu=mu, sd=sd, observed=y)

tr1 = pm.sample(cores=4)

# Horseshoe Prior - Carvalho, Polson and Scott 2009
with pm.Model() as model2:

# Priors
sd = pm.Gamma("sd", alpha=0.05, beta=0.1, shape=1)
tau = pm.HalfCauchy("tau", beta=sd, shape=1) # global shrinkage
lam = pm.HalfCauchy("lam", beta=1, shape=k) # local shrinkage

scale = pm.Deterministic("scale", pm.math.sqr(lam*tau))
beta = pm.Normal("beta", mu=0, sigma=scale, shape=k)

kappa = pm.Deterministic("kappa", 1/(1+pm.math.sqr(lam)))

# Likelihood
mu = pm.Deterministic("mu", tt.dot(x, beta))
y_ = pm.Normal("y_obs", mu=mu, sd=sd, observed=y)

tr2 = pm.sample(cores=4)``````