Code now compiles as R package.  Fixed a few issues, including (a)
correcting function scoping, (b) including M as a vector instead of a
fixed value (should help with speed), (c) corrected way that
"Bin.length" is used to update distance for unobserved animals, (d)
eliminated Control$grp.mean in favor of using Cov.prior.pdf and
Cov.prior.parms.  

Next up: see if "pseudo-priors" can be updated within MCMC (e.g., group
size parameters)
Code updated to include parametric models for covariates. 
Poisson family (e.g., zero-truncated lognormal Poisson) appears
to be working when Area.transect=1; Area.transect<1 doesn't work right
now...
Transect areas<100% of strata area now works. Species covariate updates
(direchlet/multinomial)
and other individual covariate updates (e.g., lognormal zero
truncated poisson for group sizes now working

Also
fixed several bugs:

(1) fixed bug in how Sig.inv for rho updates calculated; Changed to
(1-rho^2)^-1 from sqrt(1-rho^2)

(2) fixed scoping problem in "stacked_data"; now should work when G=0 or
G=1 for first transect

(3) Now passing strata group sizes to log_lambda function (was
previously passing transect group sizes); 
Code set up for running spatial sims; both spatial (with and without
spatial independence) and 'standard' sims show negative bias in N...
what's up?

Also implemented speed up to individual covariate updates, but this
wasn't a factor here (sims occurred both before and after this
implementation).
stupid redundant commit so I can go back to a different branch
Revert "stupid redundant commit so I can go back to a different branch"

This reverts commit 4ce40a3c4320b7671ac1509c3fb619e0cd530dc1.
Code appears to work for 1/2 observers now, at least when there's enough
data.  (previously, DM for habitat mismatched that used in simulation,
11/4/11 bug was still present somehow).

Looks like long runs are needed (maybe 1 million iter), and care should
be taken to avoid confounding b/w intercept and species effect (at least
when interpreting individual parameters).

next up: implement spatially restricted regression (SRR) for spatial
effects
Spatially restricted regression implemented, including options to
use/not use SRR and fix/not fix tau_nu.

Getting behavior that looks like impropriety in habitat effects, even
though detection parameters look good by and large.  Need to do some
testing with simpler observation model...

Bugs Fixed:
*spatial plotting bits had habitat effects transposed
*stack-data didn't properly account for multiple observers when
determining # of levels for each covariate
*bug in sim code for Mapping[] (used 5 instead of n.transects)
Merged back in changes from Poisson observation model branch (reduced
rank srr, limiting nu L-H to only those cells where there are data, obs
vs. exp, a few bug fixes)
Working - finally!  (at least with reduced rank SRR & no
overdispersion).  I'll try to use this version for simulated data in
paper
Realized the formula for variance and mean of theta in reduced rank srr
didnt' incorporate tau_nu.  Unfortunately, changing these formulas to
what I think they should be makes beta parameter blow up.  Need to go
back to Poisson observation model to debug.
Simulations complete; sent first draft of ms to coauthors
Dimension increased in misID version to include species in data,
parameter vectors and tested.

Two bugs corrected from previous MCMC code:
1) In Det par update, Cur.dat used Data[itrans,...] instead of
Data[GT0[itrans],..]

2) in Y-tilde update, incorrectly had
Y2~truncnorm(mu_y2+rho*(Y2-mu_1),..)
Changed to Y2~truncnorm(mu_y2+rho*(Y1-mu_1),..)

3) In beta update for habitat parameters, Mu was not reset to 'old' Mu
if proposal is rejected (this may have been fixed at last commit...can't
remember)
Package formulated for PLoS submission (the one with the golf tee
dataset).  Now need to try to make it faster!