Skip to content

Commit

Permalink
Update plotting parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
philpatton committed Aug 26, 2024
1 parent 2685522 commit 66d915f
Show file tree
Hide file tree
Showing 53 changed files with 3,035 additions and 1,171 deletions.
1,735 changes: 1,735 additions & 0 deletions .jupyter_cache/executed/0506ea7b660ec3b6337ab1a7421b745c/base.ipynb

Large diffs are not rendered by default.

Binary file modified .jupyter_cache/global.db
Binary file not shown.
13 changes: 10 additions & 3 deletions cjs.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,25 @@ The goal of the CJS model is to estimate survival, accounting for capture probab
: An example of the M-array from a four year capture-recapture survey. The number recaptured, $m_{i,j}$ refers to the number of individuals released at $i$ who were first recaptured at time $j$.

```{python}
from pymc.distributions.dist_math import factln
from scipy.linalg import circulant
import seaborn as sns
import numpy as np
import matplotlib.pyplot as plt
import arviz as az
import pymc as pm
import pytensor.tensor as pt
from pymc.distributions.dist_math import factln
from scipy.linalg import circulant
plt.style.use('fivethirtyeight')
plt.rcParams['axes.facecolor'] = 'white'
plt.rcParams['figure.facecolor'] = 'white'
plt.rcParams['axes.spines.left'] = False
plt.rcParams['axes.spines.right'] = False
plt.rcParams['axes.spines.top'] = False
plt.rcParams['axes.spines.bottom'] = False
sns.set_palette("tab10")
def create_recapture_array(history):
"""Create the recapture array from a capture history."""
Expand Down
14 changes: 11 additions & 3 deletions closed_cmr.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,25 @@ This produces a capture history for each individual, which allows us to estimate

```{python}
# libraries
from pymc.distributions.dist_math import binomln, logpow
import vapeplot
import seaborn as sns
import numpy as np
import pandas as pd
import pymc as pm
import arviz as az
import matplotlib.pyplot as plt
from pymc.distributions.dist_math import binomln, logpow
# plotting parameters
plt.style.use('fivethirtyeight')
plt.rcParams['axes.facecolor'] = 'white'
plt.rcParams['figure.facecolor'] = 'white'
plt.rcParams['axes.spines.left'] = False
plt.rcParams['axes.spines.right'] = False
plt.rcParams['axes.spines.top'] = False
plt.rcParams['axes.spines.bottom'] = False
sns.set_palette("tab10")
# hyperparameters
SEED = 808
Expand Down Expand Up @@ -126,7 +134,7 @@ coords = {'species': ['pygmy', 'red_cheeked']}
with pm.Model(coords=coords) as M0:
# priors for the capture and inclusion probabilities
psi = pm.Uniform('psi', 0, 1, dims='species')
psi = pm.Beta('psi', 0.001, 1, dims='species')
p = pm.Uniform('p', 0, 1, dims='species')
# likelihood for the summarized data
Expand Down Expand Up @@ -280,7 +288,7 @@ coords = {'alpha_coeffs': ['Intercept', 'B_Response']}
with pm.Model(coords=coords) as mb:
# priors for the capture and inclusion probabilities
psi = pm.Uniform('psi', 0, 1)
psi = pm.Beta('psi', 0.001, 1)
Alpha = pm.Normal('Alpha', 0, 2, dims='alpha_coeffs')
nu = pm.math.dot(X, Alpha)
Expand Down
17 changes: 12 additions & 5 deletions distance.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ Following @hooten2019, Chapter 24 and @royle2008, Chapter 7, I use the impala da
```{python}
#| fig-cap: Histogram of the number of detected impalas at varying distances.
#| label: fig-hist
import seaborn as sns
import pymc as pm
import pytensor.tensor as pt
import matplotlib.pyplot as plt
Expand All @@ -30,6 +32,11 @@ import numpy as np
plt.style.use('fivethirtyeight')
plt.rcParams['axes.facecolor'] = 'white'
plt.rcParams['figure.facecolor'] = 'white'
plt.rcParams['axes.spines.left'] = False
plt.rcParams['axes.spines.right'] = False
plt.rcParams['axes.spines.top'] = False
plt.rcParams['axes.spines.bottom'] = False
sns.set_palette("tab10")
# hyper parameters
M = 500
Expand Down Expand Up @@ -84,7 +91,7 @@ The issue is that $x$ is unobserved for the undetected individuals. To work arou
with pm.Model() as distance:
psi = pm.Uniform('psi', 0, 1)
psi = pm.Beta('psi', 0.001, 1)
sigma = pm.Uniform('sigma', 0, U_SIGMA)
x_unobserved = pm.Uniform('x_unobserved', 0, U_X, shape=unobserved_count)
Expand Down Expand Up @@ -145,15 +152,15 @@ ax1.hist(sigma_samples, edgecolor='white', bins=30)
# ax0.set_xlim((100, M))
# axes labels
ax0.set_xlabel('Abundance $N$')
ax0.set_xlabel(r'Abundance $N$')
ax0.set_ylabel('Number of samples')
ax1.set_xlabel('Detection range $\sigma$')
ax1.set_xlabel(r'Detection range $\sigma$')
# add the point estimates
N_hat = N_samples.mean()
sigma_hat = sigma_samples.mean()
ax0.text(200, 350, f'$\hat{{N}}$={N_hat:.1f}', ha='left', va='center')
ax1.text(205, 350, f'$\hat{{\sigma}}$={sigma_hat:.1f}', ha='left', va='center')
ax0.text(200, 350, rf'$\hat{{N}}$={N_hat:.1f}', ha='left', va='center')
ax1.text(205, 350, rf'$\hat{{\sigma}}$={sigma_hat:.1f}', ha='left', va='center')
# the results from royle and dorazio (2008) for comparison
N_hat_royle = 179.9
Expand Down
171 changes: 83 additions & 88 deletions docs/cjs.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/cjs_files/figure-html/fig-cjs-output-1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/cjs_files/figure-html/fig-cjs_surv-output-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/cjs_files/figure-html/fig-cjs_trace-output-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 66d915f

Please sign in to comment.