econmethods 3.0.1__tar.gz → 3.0.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: econmethods
3
- Version: 3.0.1
3
+ Version: 3.0.2
4
4
  Summary: A python package implementing various econometrical tests and estimators
5
5
  Home-page: https://github.com/NaturionBG/econmethods
6
6
  Author: NaturionBG
@@ -312,19 +312,18 @@ class FECM:
312
312
  - *stat_vars*: a DataFrame of the same format as "df" - includes variables that will not be differenced and included into the ECM in their raw form. Ensure these variables are I(0). Defaults to None.
313
313
  - *lr_const*: Specify whether the long-run model should have a constant.
314
314
  - *autorem*: Enables/Disables automatic removal of insignificant regression coefficients in the ECM. Defaults to True.
315
- - *remove_difs*: Remove the cointegration vector differences. Enabling this invalidates autorem. Defaults to False.
315
+ - *remove_difs*: Remove the cointegration vector differences. Enabling this invalidates autorem. Passing a string removes that exact variable. Defaults to False.
316
316
  - *remove_lr_ins*: Enables/Disables automatic removal of insignificant regression coefficients in the long-run model. Defaults to False.
317
317
  - *sf*: Your significance level.
318
+ - *cont_means*: Enable/disable contemporanous means for the CCE- framework. Disabling will cause all means to be lagged by one period. Defaults to True.
318
319
  ----
319
320
  RETURNS:
320
321
  --
321
322
  A python dictionary (dict) containing:
322
323
  - Long-run estimation results | key = "lr_res"
323
324
  - ECM (short-run) estimation results | key = "sr_res"\n
324
- If a CCE- method is chosen:
325
- - The AR(d) estimation results to forecast the cross-sectional mean | key = "ar"
326
325
  '''
327
- def __init__(self, df: pd.DataFrame, effects: str = 'rand', trend: int = 0, n_lags: int = 1, method: str = 'MG', coint: str | list[str] = 'x1', intercept: bool = True, stat_vars: pd.DataFrame|None = None, lr_const: bool = False, autorem: bool = True, remove_difs: bool = False, remove_lr_ins: bool = False, sf: float = 0.05) -> None:
326
+ def __init__(self, df: pd.DataFrame, effects: str = 'rand', trend: int = 0, n_lags: int = 1, method: str = 'MG', coint: str | list[str] = 'x1', intercept: bool = True, stat_vars: pd.DataFrame|None = None, lr_const: bool = False, autorem: bool = True, remove_difs: bool | list[str] = False, remove_lr_ins: bool = False, sf: float = 0.05, cont_means: bool = True) -> None:
328
327
  self.__df = df
329
328
  self.__eff = effects.lower()
330
329
  self.__t = trend
@@ -333,12 +332,20 @@ class FECM:
333
332
  self.__lag = n_lags
334
333
  self.sf = sf
335
334
  self.x_difs = []
336
- self.__remove_difs = remove_difs
335
+ self.__cont_means = cont_means
336
+ if type(remove_difs) == bool:
337
+ self.__remove_difs = remove_difs
338
+ else:
339
+ self.x_difs = np.array(remove_difs)+'_diff'
340
+ self.__remove_difs = True
337
341
  self.__method = method.lower()
338
342
  self.__exog = len(df.columns[3:])
339
343
  self.__l =[]
340
344
  self.__stat_vars = stat_vars
341
- self.__mean_names = ['target_avg_l1']
345
+ if not self.__cont_means:
346
+ self.__mean_names = ['target_avg_l1']
347
+ else:
348
+ self.__mean_names = ['target_avg']
342
349
  self.__stat = []
343
350
  self.__lr_autorem = remove_lr_ins
344
351
  self.__lr_c = lr_const
@@ -348,8 +355,12 @@ class FECM:
348
355
  self.__stat_vars.columns = ['SpUnit', 'time'] + self.__stat
349
356
  for i in range(1, self.__exog+1):
350
357
  self.__l.append(f'x{i}')
351
- self.x_difs.append(f'x{i}_diff')
352
- self.__mean_names.append(f'x{i}_avg')
358
+ if type(remove_difs) == bool:
359
+ self.x_difs.append(f'x{i}_diff')
360
+ if self.__cont_means:
361
+ self.__mean_names.append(f'x{i}_avg')
362
+ else:
363
+ self.__mean_names.append(f'x{i}_avg_1')
353
364
  self.__df.columns = ['SpUnit', 'time', 'target'] + self.__l
354
365
  if isinstance(coint, list):
355
366
  self.__lr_df = self.__df.copy(deep=True).loc[:, ['SpUnit', 'time', 'target', *coint]]
@@ -393,9 +404,11 @@ class FECM:
393
404
  def build_means(self) -> pd.DataFrame:
394
405
  mn = self.__df.copy(deep=True)
395
406
  mn = mn.set_index('time')
396
- means = mn.groupby('time')[['target'] + self.__l].mean()
407
+ if not self.__cont_means:
408
+ means = mn.groupby('time')[['target'] + self.__l].mean().shift(1)
409
+ else:
410
+ means = mn.groupby('time')[['target'] + self.__l].mean()
397
411
  means.columns = self.__mean_names
398
- means['target_avg_l1'] = means['target_avg_l1'].shift(1)
399
412
  return means
400
413
 
401
414
  def build_GLS(self, w_err: float) -> np.ndarray:
@@ -543,7 +556,7 @@ class FECM:
543
556
  else:
544
557
  est[0] = sm.OLS(pool['target_diff'], pool.iloc[:, 3:]).fit()
545
558
  else:
546
- pool = pool.drop(columns=[self.x_difs])
559
+ pool = pool.drop(columns=[*self.x_difs])
547
560
  if self.__C:
548
561
  est[0] = sm.OLS(pool['target_diff'], sm.add_constant(pool.iloc[:, 3:])).fit()
549
562
  else:
@@ -600,7 +613,7 @@ class FECM:
600
613
  else:
601
614
  res = self.mg_algorithm()
602
615
  else:
603
- self.__sr = self.build_sr([self.x_difs])
616
+ self.__sr = self.build_sr(self.x_difs)
604
617
  res = self.mg_algorithm()
605
618
 
606
619
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: econmethods
3
- Version: 3.0.1
3
+ Version: 3.0.2
4
4
  Summary: A python package implementing various econometrical tests and estimators
5
5
  Home-page: https://github.com/NaturionBG/econmethods
6
6
  Author: NaturionBG
@@ -5,7 +5,7 @@ with open('README.md', 'r') as f:
5
5
 
6
6
  setup(
7
7
  name = 'econmethods',
8
- version = 'v3.0.1',
8
+ version = 'v3.0.2',
9
9
  description='A python package implementing various econometrical tests and estimators',
10
10
  packages = find_packages(),
11
11
  long_description=long_desc,
File without changes
File without changes