config module¶
Read FRAC estimation settings and data from a TOML configuration file.
The file has three sections:
[data]: where the data come from. Withsource = "real", the data are read from a CSV or Parquet file; withsource = "simulated", they are simulated.[simulation]: parameters of the simulation, used whensource = "simulated".[estimation]: options forfrac_nodemog_estimate.
Relative paths for file are taken relative to the directory of the config file.
Config
¶
Bases: _StrictModel
The whole configuration file.
Source code in frac_blp/config.py
139 140 141 142 143 144 | |
DataConfig
¶
Bases: _StrictModel
The [data] section.
Attributes:
| Name | Type | Description |
|---|---|---|
source |
str
|
|
file |
Path | None
|
Path to a CSV or Parquet file with one row per product
and market, stacked by market. Needed for |
shares |
str | None
|
Column with the observed shares. |
instruments |
list[str]
|
Columns of the instruments. A constant is added automatically, so do not include one. |
X1_exo |
list[str]
|
Columns of the exogenous regressors with fixed coefficients. |
X1_endo |
list[str]
|
Columns of the endogenous regressors with fixed coefficients. |
X2_exo |
list[str]
|
Columns of the exogenous regressors with random
coefficients. Must be a subset of |
X2_endo |
list[str]
|
Columns of the endogenous regressors with random
coefficients. Must be a subset of |
T |
int | None
|
Number of markets. Needed for |
J |
int | None
|
Number of products per market. Needed for |
Source code in frac_blp/config.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 | |
EstimationConfig
¶
Bases: _StrictModel
The [estimation] section; see :func:frac_nodemog_estimate.
Source code in frac_blp/config.py
129 130 131 132 133 134 135 136 | |
SimulationConfig
¶
Bases: _StrictModel
The [simulation] section; see :func:simulate_frac_nodemog_data.
Source code in frac_blp/config.py
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | |
build_frac_data(config)
¶
Build the FRAC data object described by a configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
Config
|
Settings from :func: |
required |
Returns:
| Name | Type | Description |
|---|---|---|
FracNoDemogData |
FracNoDemogData
|
Simulated data, or real data read from |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the file lacks some of the named columns or does not have
|
Source code in frac_blp/config.py
188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 | |
load_config(path)
¶
Read and validate a TOML configuration file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
Path to the TOML file. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Config |
Config
|
The validated settings. A relative |
Config
|
against the directory of the config file. |
Raises:
| Type | Description |
|---|---|
ValidationError
|
If the file has unknown keys or invalid values. |
Source code in frac_blp/config.py
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | |