def residualize(X, ps): numObs = X.shape[0] resHat = np.zeros((numObs,1)) hOptimal = LLR.optimalBandwidthSelection(X, ps) # for each observations, get prediction for iObs in range(numObs): xFit = LLR.polynomialFit(X,ps, ps[iObs], hOptimal) resHat[iObs] = X[iObs] - xFit[0] return resHat
def residualize(X, ps): numObs = X.shape[0] resHat = np.zeros((numObs, 1)) hOptimal = LLR.optimalBandwidthSelection(X, ps) # for each observations, get prediction for iObs in range(numObs): xFit = LLR.polynomialFit(X, ps, ps[iObs], hOptimal) resHat[iObs] = X[iObs] - xFit[0] return resHat
def LLRKpLIVMTE(yTilda, ps, hOptimal, betaDif, x, u): # test for size agree if x.shape[1] != betaDif.shape[0]: print 'the size of X and beta does not agree' raise elif x.shape[0] != 1: print 'the x is not row vector' raise elif betaDif.shape[1] != 1: print 'the beta is not column vector' raise result = LLR.polynomialFit(yTilda,ps,u,hOptimal) mteHat = np.dot(x, betaDif) + result[2] return mteHat
def LLRKpLIVMTE(yTilda, ps, hOptimal, betaDif, x, u): # test for size agree if x.shape[1] != betaDif.shape[0]: print 'the size of X and beta does not agree' raise elif x.shape[0] != 1: print 'the x is not row vector' raise elif betaDif.shape[1] != 1: print 'the beta is not column vector' raise result = LLR.polynomialFit(yTilda, ps, u, hOptimal) mteHat = np.dot(x, betaDif) + result[2] return mteHat