Data Processing
Processing module - stores all inputs to run Dynamic Factor Model.
DataProcessor
¶
Source code in dfmdash/processing.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 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 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 |
|
__init__(ad, global_multiplier=1, maxiter=10000)
¶
Prepares inputs for running model
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ad
|
AnnData
|
Annotated data object |
required |
global_multiplier
|
int
|
Global multiplier. Defaults to 1. |
1
|
maxiter
|
int
|
Maximum number of iterations. Defaults to 10_000. |
10000
|
Source code in dfmdash/processing.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
|
diff_vars()
¶
Performs differencing on the specified columns
Returns:
Name | Type | Description |
---|---|---|
DataProcessor |
DataProcessor
|
Processed data |
Source code in dfmdash/processing.py
146 147 148 149 150 151 152 153 |
|
drop_constant_cols()
¶
Drops constant columns from the DataFrame.
Returns:
Name | Type | Description |
---|---|---|
DataProcessor |
DataProcessor
|
Processed data |
Source code in dfmdash/processing.py
107 108 109 110 111 112 113 114 |
|
get_diff_cols()
¶
Returns the columns that should be differenced.
Returns:
Type | Description |
---|---|
list[str]
|
list[str]: List of columns to be differenced |
Source code in dfmdash/processing.py
116 117 118 119 120 121 122 |
|
get_factors()
¶
Gets the factor dictionary from the AnnData object for the DFM
Returns:
Type | Description |
---|---|
dict[str, tuple[str]]
|
dict[str, tuple[str]]: Dictionary of factors |
Source code in dfmdash/processing.py
75 76 77 78 79 80 81 82 83 84 85 86 87 |
|
get_logdiff_cols()
¶
Returns the columns that should be log-differenced.
Returns:
Type | Description |
---|---|
list[str]
|
list[str]: List of columns to be log-differenced |
Source code in dfmdash/processing.py
124 125 126 127 128 129 130 |
|
get_nonstationary_columns()
¶
Runs AD-Fuller test on columns and returns non-stationary columns
Returns:
Type | Description |
---|---|
list[str]
|
list[str]: List of non-stationary columns |
Source code in dfmdash/processing.py
164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
|
logdiff_vars()
¶
Performs log-differencing on the specified columns
Returns:
Name | Type | Description |
---|---|---|
DataProcessor |
DataProcessor
|
Processed data |
Source code in dfmdash/processing.py
155 156 157 158 159 160 161 162 |
|
normalize()
¶
Normalizes the data between 0 and 1
Returns:
Name | Type | Description |
---|---|---|
DataProcessor |
DataProcessor
|
Processed data |
Source code in dfmdash/processing.py
179 180 181 182 183 184 185 186 187 |
|
process(columns=None)
¶
Processes the data for the Dynamic Factor Model
Parameters:
Name | Type | Description | Default |
---|---|---|---|
columns
|
Optional[list[str]]
|
Subset of columns to use. Defaults to None, which uses all columns. |
None
|
Returns:
Name | Type | Description |
---|---|---|
DataProcessor |
DataProcessor
|
Stores processed data |
Source code in dfmdash/processing.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
|
process_differences()
¶
Processes the differences in the data
Returns:
Name | Type | Description |
---|---|---|
DataProcessor |
DataProcessor
|
Processed data |
Source code in dfmdash/processing.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
|
write(outdir)
¶
Writes the processed input data and run info to outdir
Parameters:
Name | Type | Description | Default |
---|---|---|---|
outdir
|
Path
|
Output directory |
required |
Source code in dfmdash/processing.py
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
|
is_constant(column)
¶
Returns True if a DataFrame column is constant
Source code in dfmdash/processing.py
190 191 192 |
|