econmethods 3.0.5__tar.gz → 3.0.5.1__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.5
3
+ Version: 3.0.5.1
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
@@ -412,13 +412,14 @@ class FECM:
412
412
  return means
413
413
 
414
414
  def build_GLS(self, w_err: float) -> np.ndarray:
415
- re = self.__lr_df.copy(deep=True)
416
- sigma2 = np.sum((sm.OLS(re.iloc[:, 2], sm.add_constant(re.iloc[:, 3:])).fit()).resid**2) / (self.__N*self.__T - self.__exog)
417
- sigma_u = sigma2 - w_err
415
+ re = self.__lr_df.groupby('region')[self.__lr_df.columns[2:]].mean()
416
+ temp = sm.OLS(re.iloc[:, 2], sm.add_constant(re.iloc[:, 3:])).fit()
417
+ sigma2 = temp.ssr / temp.df_resid
418
+ sigma_u = sigma2 - w_err/self.__T
418
419
  if sigma_u <= 0:
419
420
  sigma_u = 0
420
421
  sig = np.full((self.__T, self.__T), sigma_u)
421
- np.fill_diagonal(sig, sigma2)
422
+ np.fill_diagonal(sig, sigma_u+w_err)
422
423
  matrix = np.kron(np.eye(self.__N), sig)
423
424
  return matrix
424
425
 
@@ -460,11 +461,11 @@ class FECM:
460
461
  else:
461
462
  lr_fe = self.build_FE()
462
463
  if self.__lr_c:
463
- resid = np.sum(sm.OLS(lr_fe.loc[:, 'target'], sm.add_constant(lr_fe.iloc[:, 3:])).fit().resid**2) / (self.__N*(self.__T - 1) - self.__exog)
464
+ resid = sm.OLS(lr_fe.loc[:, 'target'], sm.add_constant(lr_fe.iloc[:, 3:])).fit().mse_resid
464
465
  lr_re_matrix = self.build_GLS(resid)
465
466
  return sm.GLS(self.__lr_df.loc[:, 'target'], sm.add_constant(self.__lr_df.iloc[:, 3:]), lr_re_matrix).fit()
466
467
  else:
467
- resid = np.sum(sm.OLS(lr_fe.loc[:, 'target'], lr_fe.iloc[:, 3:]).fit().resid**2) / (self.__N*(self.__T - 1) - self.__exog)
468
+ resid = sm.OLS(lr_fe.loc[:, 'target'], lr_fe.iloc[:, 3:]).fit().mse_resid
468
469
  lr_re_matrix = self.build_GLS(resid)
469
470
  return sm.GLS(self.__lr_df.loc[:, 'target'], self.__lr_df.iloc[:, 3:], lr_re_matrix).fit()
470
471
 
@@ -701,41 +702,31 @@ class CDTwoWay:
701
702
  print(f'p-value = {pval} < alpha = {self.__alpha}\n There is Significant Cross-Sectional Dependence in your data according to the CD-test. \n Significance level: {self.__alpha*100}%')
702
703
  else:
703
704
  print(f'p-value = {pval} > alpha = {self.__alpha} There is No Significant Cross-Sectional Dependence in your data according to the CD-test. \n Significance level: {self.__alpha*100}%')
704
-
705
-
706
705
  class SlopeHomogeneityF:
707
706
  '''
708
- <h2>The implementation of the F-test for data slope Homogeneity in panel data.</h2>
709
- <hr>
710
- <h2>Hypotheses:</h2>
711
- <hr>
712
- <ul>
713
- <li> <em>H0</em>: b_i = b_j given that i != j</li>
714
- <li><em>H_1</em>: b_i != b_j for at least one such pair of (i, j) that i != j </li>
715
- </ul>
716
- <hr>
717
- <h2>PARAMETERS:</h2>
718
- <hr>
719
- <ul>
720
- <li> <strong>df</strong>: a Pandas DataFrame containing panel data. Make sure your data is structured in this exact order (by column index):
721
- <ul>
722
- <li>0 - Spatial units. The data must be homogenous, e.g. only cities, contries, regions, etc.</li>
723
- <li>1 - Temporal units. The data must be homogenous, e.g. only years, months, quarters, etc.</li>
724
- <li>2 - Your target/endogenous variable. The data must not contain NaN values.</li>
725
- <li>3+ - Your exogenous variables. The data must not contain NaN values.</li>
726
- </ul>
727
- <li> <strong>level</strong>: Your significance level to test at. Defaults to 5%.</li>
728
- <li> <strong>intercept</strong>: Specify whether your model has an intercept. Defaults to True.</li>
729
- <li> <strong>skip_premise</strong>: Set to True if you wish to ignore heteroskedasticity. Not a recommended option, parameter defaults to False</li>
730
- </ul>
731
- <hr>
732
- <h3><em>Note that this test has got certain assumptions, such as error homoskedasticity, N < T.
733
- The <FTwoWay> instance will check for these conditions to be met, and will yield an error if they are not.</em></h3>
734
- <hr>
735
- <h2>RETURNS:</h2>
736
- <ol>
737
- <li>Via the instance.verdict() method - prints the result of the F-test.</li>
738
- </ol>
707
+ The implementation of the F-test for data slope Homogeneity in panel data.
708
+ ---
709
+ Hypotheses:
710
+ ---
711
+ + H0: b_i = b_j given that i != j
712
+ + H_1: b_i != b_j for at least one such pair of (i, j) that i != j
713
+ ---
714
+ PARAMETERS:
715
+ ---
716
+ - **df:** a Pandas DataFrame containing panel data. Make sure your data is structured in this exact order (by column index):
717
+ + 0 - Spatial units. The data must be homogenous, e.g. only cities, contries, regions, etc.
718
+ + 1 - Temporal units. The data must be homogenous, e.g. only years, months, quarters, etc.
719
+ + 2 - Your target/endogenous variable. The data must not contain NaN values.
720
+ + 3+ - Your exogenous variables. The data must not contain NaN values.
721
+ - **level:** Your significance level to test at. Defaults to 5%.
722
+ - **intercept:** Specify whether your model has an intercept. Defaults to True.
723
+ - **skip_premise:** Set to True if you wish to ignore heteroskedasticity. Not a recommended option, parameter defaults to False
724
+ *Note that this test has got certain assumptions, such as error homoskedasticity, N < T.
725
+ The <FTwoWay> instance will check for these conditions to be met, and will yield an error if they are not.*
726
+ ---
727
+ **RETURNS:**
728
+
729
+ + Via the instance.verdict() method - prints the result of the F-test.
739
730
  '''
740
731
  def __init__(self, df: pd.DataFrame, level: int = 5, intercept: bool = True, skip_premise: bool = False) -> None:
741
732
  self.__df = df
@@ -787,4 +778,4 @@ class SlopeHomogeneityF:
787
778
 
788
779
  def __del__(self) -> None:
789
780
  pass
790
-
781
+
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: econmethods
3
- Version: 3.0.5
3
+ Version: 3.0.5.1
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.5',
8
+ version = 'v3.0.5.1',
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