Skip to content

Commit 519fa5b

Browse files
committed
add use instructions
1 parent b57dad4 commit 519fa5b

File tree

3 files changed

+87
-0
lines changed

3 files changed

+87
-0
lines changed

docs/make.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ makedocs(
88
sitename = "StandardCGE.jl",
99
pages = [
1010
"Home" => "index.md",
11+
"Using Your Own SAM" => "custom_sam.md",
1112
"API" => "api.md",
1213
],
1314
format = Documenter.HTML(

docs/src/custom_sam.md

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# Using Your Own SAM
2+
3+
This page explains how to load a custom Social Accounting Matrix (SAM) with an
4+
arbitrary number of products (goods) and production factors.
5+
6+
## What the loader expects
7+
8+
The CSV file must include a header row with column labels and a first column
9+
with row labels. The loader uses these labels to index the SAM:
10+
11+
- `goods` and `factors` are not inferred from the CSV. You must pass them in
12+
`load_sam_table(...; goods=..., factors=...)`.
13+
- The CSV must include rows and columns for all `goods`, `factors`, and the
14+
special sectors listed below.
15+
16+
Required sector labels (defaults shown):
17+
18+
- `indirectTax_label` = `IDT`
19+
- `tariff_label` = `TRF`
20+
- `households_label` = `HOH`
21+
- `government_label` = `GOV`
22+
- `investment_label` = `INV`
23+
- `restOfTheWorld_label` = `EXT`
24+
- `numeraire_factor_label` = `LAB` (must be one of the factor labels)
25+
26+
If your CSV uses different labels, pass them as keyword arguments to
27+
`load_sam_table`.
28+
29+
## Minimal structure example
30+
31+
The table must be square and include all the labels you reference. This
32+
illustrative header shows the kind of layout expected:
33+
34+
```text
35+
Column1,BRD,MLK,CAP,LAB,IDT,TRF,HOH,GOV,INV,EXT
36+
BRD, ...
37+
MLK, ...
38+
CAP, ...
39+
LAB, ...
40+
IDT, ...
41+
TRF, ...
42+
HOH, ...
43+
GOV, ...
44+
INV, ...
45+
EXT, ...
46+
```
47+
48+
## Loading a custom SAM
49+
50+
```julia
51+
using StandardCGE
52+
53+
goods = ["A", "B", "C"]
54+
factors = ["LAB", "CAP", "LAND"]
55+
56+
sam = load_sam_table(
57+
"path/to/your_sam.csv";
58+
goods = goods,
59+
factors = factors,
60+
numeraire_factor_label = "LAB",
61+
indirectTax_label = "IDT",
62+
tariff_label = "TRF",
63+
households_label = "HOH",
64+
government_label = "GOV",
65+
investment_label = "INV",
66+
restOfTheWorld_label = "EXT",
67+
)
68+
69+
model, start, params = solve_model(sam)
70+
```
71+
72+
## Common pitfalls
73+
74+
- The SAM must be square and include all labels used in `goods`, `factors`, and
75+
the special sector labels.
76+
- The `numeraire_factor_label` must match one of the factor labels.
77+
- Missing values are replaced by `0`, but missing rows or columns will cause
78+
indexing errors.
79+
80+
## Tips for larger SAMs
81+
82+
- Keep goods and factors ordered consistently between the CSV and your lists.
83+
- Start by running `compute_starting_values(sam)` and `compute_calibration_params(sam, start)`
84+
to catch data issues before solving.

docs/src/index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ sam = load_sam_table("path/to/your_sam.csv"; goods=["A", "B"], factors=["LAB", "
3333
model, start, params = solve_model(sam)
3434
```
3535

36+
For a full walkthrough, see "Using Your Own SAM" in the sidebar.
37+
3638
## Examples
3739

3840
```julia

0 commit comments

Comments
 (0)