Skip to content

Commit

Permalink
precommit hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
mitch-at-orika committed Dec 8, 2023
1 parent c9e834d commit 154a503
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,9 @@
" u1 = beta_ic * wide_heating_df[\"ic.er\"] + beta_oc * wide_heating_df[\"oc.er\"]\n",
" u2 = beta_ic * wide_heating_df[\"ic.gc\"] + beta_oc * wide_heating_df[\"oc.gc\"]\n",
" u3 = beta_ic * wide_heating_df[\"ic.gr\"] + beta_oc * wide_heating_df[\"oc.gr\"]\n",
" u4 = beta_ic * wide_heating_df[\"ic.hp\"] + beta_oc * wide_heating_df[\"oc.hp\"]#np.zeros(N) # Outside Good\n",
" u4 = (\n",
" beta_ic * wide_heating_df[\"ic.hp\"] + beta_oc * wide_heating_df[\"oc.hp\"]\n",
" ) # np.zeros(N) # Outside Good\n",
" s = pm.math.stack([u0, u1, u2, u3, u4]).T\n",
"\n",
" ## Apply Softmax Transform\n",
Expand Down Expand Up @@ -4262,7 +4264,7 @@
}
],
"source": [
"idata_m1[\"posterior\"][\"p\"].mean(dim=[\"chain\", \"draw\", \"obs\"]).to_dataframe()['p']"
"idata_m1[\"posterior\"][\"p\"].mean(dim=[\"chain\", \"draw\", \"obs\"]).to_dataframe()[\"p\"]"
]
},
{
Expand Down Expand Up @@ -4579,7 +4581,9 @@
" u1 = alphas[1] + beta_ic * wide_heating_df[\"ic.er\"] + beta_oc * wide_heating_df[\"oc.er\"]\n",
" u2 = alphas[2] + beta_ic * wide_heating_df[\"ic.gc\"] + beta_oc * wide_heating_df[\"oc.gc\"]\n",
" u3 = alphas[3] + beta_ic * wide_heating_df[\"ic.gr\"] + beta_oc * wide_heating_df[\"oc.gr\"]\n",
" u4 = 0 + beta_ic * wide_heating_df[\"ic.hp\"] + beta_oc * wide_heating_df[\"oc.hp\"] # Make one constant zero\n",
" u4 = (\n",
" 0 + beta_ic * wide_heating_df[\"ic.hp\"] + beta_oc * wide_heating_df[\"oc.hp\"]\n",
" ) # Make one constant zero\n",
" s = pm.math.stack([u0, u1, u2, u3, u4]).T\n",
"\n",
" ## Apply Softmax Transform\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ jupytext:
format_name: myst
format_version: 0.13
kernelspec:
display_name: pymc_examples_new
display_name: Python 3 (ipykernel)
language: python
name: pymc_examples_new
name: python3
myst:
substitutions:
extra_dependencies: jax, jaxlib, numpyro
Expand Down Expand Up @@ -98,14 +98,14 @@ This assumption proves to be mathematically convenient because the difference be

$$ \text{softmax}(u)_{j} = \frac{\exp(u_{j})}{\sum_{q=1}^{J}\exp(u_{q})} $$

The model then assumes that decision maker chooses the option that maximises their subjective utility. The individual utility functions can be richly parameterised. The model is identified just when the utility measures of the alternatives are benchmarked against the fixed utility of the "outside good." The last quantity is fixed at 0.
The model then assumes that decision maker chooses the option that maximises their subjective utility. The individual utility functions can be richly parameterised. When contants are included, one alternative's constant must be fixed at 0 in order to normalise the overall level of the constants.

$$\begin{pmatrix}
u_{gc} \\
u_{gr} \\
u_{ec} \\
u_{er} \\
0 \\
u_{hp} \\
\end{pmatrix}
$$

Expand Down Expand Up @@ -150,7 +150,9 @@ with pm.Model(coords=coords) as model_1:
u1 = beta_ic * wide_heating_df["ic.er"] + beta_oc * wide_heating_df["oc.er"]
u2 = beta_ic * wide_heating_df["ic.gc"] + beta_oc * wide_heating_df["oc.gc"]
u3 = beta_ic * wide_heating_df["ic.gr"] + beta_oc * wide_heating_df["oc.gr"]
u4 = np.zeros(N) # Outside Good
u4 = (
beta_ic * wide_heating_df["ic.hp"] + beta_oc * wide_heating_df["oc.hp"]
) # np.zeros(N) # Outside Good
s = pm.math.stack([u0, u1, u2, u3, u4]).T
## Apply Softmax Transform
Expand Down Expand Up @@ -215,7 +217,7 @@ which suggests that there is almost twice the value accorded to the a unit reduc
To assess overall model adequacy we can rely on the posterior predictive checks to see if the model can recover an approximation to the data generating process.

```{code-cell} ipython3
idata_m1["posterior"]["p"].mean(dim=["chain", "draw", "obs"])
idata_m1["posterior"]["p"].mean(dim=["chain", "draw", "obs"]).to_dataframe()["p"]
```

```{code-cell} ipython3
Expand Down Expand Up @@ -272,7 +274,9 @@ with pm.Model(coords=coords) as model_2:
u1 = alphas[1] + beta_ic * wide_heating_df["ic.er"] + beta_oc * wide_heating_df["oc.er"]
u2 = alphas[2] + beta_ic * wide_heating_df["ic.gc"] + beta_oc * wide_heating_df["oc.gc"]
u3 = alphas[3] + beta_ic * wide_heating_df["ic.gr"] + beta_oc * wide_heating_df["oc.gr"]
u4 = np.zeros(N) # Outside Good
u4 = (
0 + beta_ic * wide_heating_df["ic.hp"] + beta_oc * wide_heating_df["oc.hp"]
) # Make one constant zero
s = pm.math.stack([u0, u1, u2, u3, u4]).T
## Apply Softmax Transform
Expand Down

0 comments on commit 154a503

Please sign in to comment.