RaschModel¶
pyfies.model.RaschModel ¶
Weighted dichotomous Rasch model for FIES data.
Example
from pyfies import RaschModel, FAO_2014_2016 model = RaschModel().fit(X, sample_weight=w) # doctest: +SKIP model.equate(FAO_2014_2016) # doctest: +SKIP result = model.prevalence() # doctest: +SKIP print(result.moderate_or_severe, result.severe) # doctest: +SKIP
Source code in src/pyfies/model.py
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 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 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 | |
equating
property
¶
Equating result. Raises if :meth:equate has not been called.
equated_beta
property
¶
Item severities on the reference metric (after equating).
fit ¶
fit(X: NDArray[int_] | DataFrame, sample_weight: NDArray[float64] | None = None, pseudo_extreme: tuple[float, float] | None = None) -> RaschModel
Estimate item severities and person parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
X
|
NDArray[int_] | DataFrame
|
2-D matrix of dichotomized responses (1 = affirmative, 0 = negative, NaN = missing). Rows are respondents, columns are items in a fixed order. |
required |
sample_weight
|
NDArray[float64] | None
|
Optional sampling weights (one per row). If None, all respondents are weighted equally. |
None
|
pseudo_extreme
|
tuple[float, float] | None
|
Pseudo raw scores |
None
|
Returns:
| Type | Description |
|---|---|
RaschModel
|
Self, to support fluent chaining. |
Source code in src/pyfies/model.py
equate ¶
equate(reference: ReferenceStandard = FAO_2014_2016, tol: float = 0.35, max_unique: int = 3) -> RaschModel
Calibrate the country metric to a reference standard.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
reference
|
ReferenceStandard
|
Reference scale (default: FAO 2014-2016 global standard). |
FAO_2014_2016
|
tol
|
float
|
Tolerance for flagging an item as unique. |
0.35
|
max_unique
|
int
|
Maximum number of items that may be flagged unique. |
3
|
Returns:
| Type | Description |
|---|---|
RaschModel
|
Self, to support fluent chaining. |
Source code in src/pyfies/model.py
prevalence ¶
Compute the SDG 2.1.2 prevalence rates.
Defaults to using the equated thresholds (the reference standard's
moderate-or-severe and severe thresholds back-transformed onto the
country metric). If :meth:equate has not been called, falls back to
the country's own item-5 and item-8 severities.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
thresholds_country_metric
|
tuple[float, float] | None
|
Optional override for the two thresholds, expressed on the country metric. |
None
|
Returns:
| Type | Description |
|---|---|
PrevalenceResult
|
class: |
Source code in src/pyfies/model.py
pyfies.model.PrevalenceResult
dataclass
¶
Headline output: SDG 2.1.2 prevalence rates.
Attributes:
| Name | Type | Description |
|---|---|---|
moderate_or_severe |
float
|
Estimated prevalence (0-1) of moderate-or-severe food insecurity at the equated moderate-or-severe threshold. |
severe |
float
|
Estimated prevalence (0-1) of severe food insecurity. |
thresholds_country_metric |
tuple[float, float]
|
The two thresholds used, expressed on the country metric (i.e., reference thresholds back-transformed via the equating). |
on_reference_metric |
ReferenceStandard | None
|
Reference standard against which prevalence was equated, or None if no equating was performed. |
table |
PrevalenceTable
|
Underlying :class: |