Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from __future__ import print_function
- import numpy as np
- import pandas as pd
- from scipy import stats
- import statsmodels.api as sm
- import matplotlib.pyplot as plt
- from statsmodels.sandbox.regression.predstd import wls_prediction_std
- from statsmodels.iolib.table import (SimpleTable, default_txt_fmt)
- np.random.seed(1024)
- nsample = 50
- x = np.linspace(0, 20, nsample)
- X = np.column_stack((x, (x - 5)**2))
- X = sm.add_constant(X)
- beta = [5., 0.5, -0.01]
- sig = 0.5
- w = np.ones(nsample)
- w[nsample * 6//10:] = 3
- y_true = np.dot(X, beta)
- e = np.random.normal(size=nsample)
- y = y_true + sig * w * e
- X = X[:,[0,1]]
- mod_wls = sm.WLS(y, X, weights=1./(w ** 2))
- res_wls = mod_wls.fit()
- res_ols = sm.OLS(y, X).fit()
- infl = res_ols.get_influence()
- print(infl.resid_studentized_internal)
- infl1 = res_wls.get_influence()
- print(infl1.resid_studentized_internal)
- ----> 8 infl1 = res_wls.get_influence()
- 9 print(infl1.resid_studentized_internal)
- 10 # print(res_wls.summary())
- ~AppDataLocalProgramsPythonPython36libsite-packagesstatsmodelsbasewrapper.py in __getattribute__(self, attr)
- 33 pass
- 34
- ---> 35 obj = getattr(results, attr)
- 36 data = results.model.data
- 37 how = self._wrap_attrs.get(attr)
- AttributeError: 'RegressionResults' object has no attribute 'get_influence'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement