建模引入了这些包
import numpy as np
import pandas
import ggplot
from matplotlib import pyplot as plt
from sas7bdat import SAS7BDAT as sas
from scipy.optimize import minimize
from math import pi, isnan, isinf, sqrt
from scipy.linalg import inv
from scipy import stats
但是在运行下面代码时出现问题报错:
data = np.asarray(pandas.DataFrame(daily['return']))[1:,0]
dates = np.asarray(pandas.DataFrame(daily.date).date)[1:]
# define the RV and X matrix
rv,X = midas_data(data, dates, 'month', 36)
## initial values
# [mu, alpha, beta, theta, w, m]
x0 = np.array([0.0005, 0.08, 0.90, 0.1, 5, 0.0001])
# estimate
#result = minimize(__loglike__, x0=x0, method='SLSQP', \
# args = (data, X, 36, False)) ## Sequential Least squares
result = minimize(__loglike__, x0=x0, method='L-BFGS-B', \
args = (data, X, 36, False)) ## Limited Memory BFGS
# recover the components
loglik, logliks, e, tau, gt, ht, T = __loglike__(result['x'], data, X, 36, \
full_output=True)
最后报错:“AttributeError: module 'pandas' has no attribute 'tslib'”
搜了很多资料都说是ggplot版本问题,可是这里的情况好像不大一样
求指点迷津
1. Change `pandas.tslib.Timestamp` to `pandas.Timestamp` (in utils.py and stats/smoothers.py)
2. Change `from pandas.lib import Timestamp` to `from pandas import Timestamp`. (in smoothers.py)
参考https://github.com/yhat/ggpy/issues/662
已解决,前面代码中含有pandas.tslib,吧tslib删了就可以了