function[betamat,acceptmat]=gs_Poisson_rwc(y,X,k,N,mub0,Vb0,c,Vc,betadraw,r1,r2);
R = r1+r2;
thoucount=1000;
betamat=zeros(k,r2);
betacount=0;
% start main loop
for i=1:R
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% draw beta
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%take candidate draw from CGD
betacan=mvnrnd(betadraw, c*Vc)'; %draw candidate beta
lam=X*betacan; %n by 1
int=sum(y.*lam-exp(lam));
logcanbeta = log(mvnpdf(betacan,mub0,Vb0))+int;
lam=X*betadraw; %n by 1
int=sum(y.*lam-exp(lam));
logdrawbeta = log(mvnpdf(betadraw,mub0,Vb0))+int;
% log of aceptance probability
logacc = logcanbeta-logdrawbeta;
% acceptance rule
lr=log(rand);
if lrr1
betamat(:,i-r1)=betadraw; %since we're re-parameterizing
end
if i== thoucount
i
thoucount=thoucount+1000;
end
end; %end main loop
acceptmat=betacount/R;