#### Step-by-Step Guide to Community Occupancy Modeling

1. Species Selection
   - First, select which species to include in your community model
   - Review the species table showing detections and number of sites for each species
   - Use the filtering options to select species based on minimum number of detections or sites
   - You can manually select/deselect individual species by clicking the rows
   - Consider removing rare species with too few detections for reliable parameter estimation; for rarely detection species, parameters will be driven by the overall community
   - Do not fit community models to fewer than 6 species, as community level parameters are challenging to estimate for very small communities
2. Model Configuration
   - Choose model type (Occupancy or Royle-Nichols model)
   - Set occasion length (in days) to create detection histories
   - Configure detection and occupancy covariates:
     - Fixed Effects: Effect is same for all species
     - Species Random Effects: Species-specific effects with shared variance
     - Independent Effects: Completely independent effects for each species
   - Configure how species intercepts are modeled (fixed, random, or independent)
   - Optional & recommended: Include survey effort as detection covariate
   - Optional: Add species-site random effects
3. Model Fitting
   - Set MCMC parameters (chains, iterations, burn-in, thinning)
   - Run model
   - Monitor progress (currently R console output, not in the dashboard)
4. Results Inspection
   - Review parameter estimates and their uncertainties
   - Check convergence diagnostics (Gelman-Rubin statistics)
   - Examine trace plots for key parameters
   - Optional: Run Goodness-of-Fit tests (not yet implemented)
5. Effect Visualization
   - View response curves for covariates
   - Compare effect sizes across species
   - You can:
     - Select subsets of species to display
     - Order effects by size
     - Adjust confidence intervals
     - Scale plot sizes for better visibility
6. Spatial Predictions
   - Generate species-specific occupancy/abundance maps
   - Create species richness predictions
   - Calculate percentage of area occupied
   - Maps include uncertainty estimates

#### Important Notes:

- More species and covariates increase computation time
- Check convergence diagnostics before interpreting results
- Covariates are scaled to mean = 0 and standard deviation = 1 automatically.
- Lack of model fit requires close examination of the data and model; in simple cases, adding important covariates may remedy lack of fit, but you may need to consult with an experienced user of these models
- Prediction rasters should be provided in original scale. They are scaled automatically to match model covariates.
- Species with very few detections may have unreliable estimates
- Save your model objects to avoid rerunning long computations

#### Tips for Model Convergence:

- Start with simpler models and gradually add complexity
- Covariates are standardized automatically
- Increase iterations if chains haven't converged or if effective sample size is very low
- Check for highly correlated covariates
- Consider removing rare species or combining similar species

#### Bayesian Priors

All models in this tool utilize hard-coded, weakly informative (vague) priors. The goal is to allow the observed data to drive parameter estimation while providing enough structural constraints to ensure computational stability. Because all continuous covariates are automatically standardized to a mean of 0 and standard deviation of 1, these priors span a very wide range of plausible effect sizes.

- Community Means (Intercepts & Covariate Effects):
  - `dnorm(0, 0.05)`
  - Used for all community-level means (shared across species), such as the detection and occupancy intercepts and mean covariate effects. This normal distribution is centered at 0 with a precision of 0.05, which translates to a standard deviation of roughly 4.47. On the logit scale (used for occupancy and detection probabilities), a standard deviation of 4.47 is extremely wide, making it a vague prior.
- Variance of Random Effects (Precision, `tau`):
  - `dgamma(0.1, 0.1)`
  - Used for the precision parameter `tau`, which controls the degree of variation among species-specific random effects (both intercepts and covariates). This Gamma prior (shape = 0.1, rate = 0.1) is a classic vague prior in Bayesian hierarchical models. It is highly diffuse, allowing the data to completely dictate the true level of variation across species. The corresponding standard deviation for the random effects is calculated as `sigma <- sqrt(1 / tau)`.

#### Relevant functions

- `communityModel` Create community occupancy models
- `fit(commOccu)` fit() method for community Models
- `predict(commOccu)` predict() method for community Models
- `ploe_coef` Plot model coefficients
- `plot_effecs` Plot model effects