One possibility is to use weighted least squares in statsmodels
about:
y is a response or endogenous variable ( endog
)
x is your 1 dimensional explanatory variable
w your weight array, the higher the weight of this observation
to get a polynomial matrix and put
import numpy as np import statsmodels.api as sm exog = np.vander(x, degree+1) result = sm.WLS(y, exog, weight=w).fit()
parameters are in result.params
. The set values ββare in result.fittedvalues
Forecasting has changed between versions. With version 0.4 you can use
result.predict(np.vander(x_new, degree+1))
source share