def test_mixed_input(data):
y = PanelData(data.y)
nt = y.values2d.shape[0]
effects = np.random.randint(0, 5, size=nt)
prim = ['a', 'b', 'c', 'd', 'e']
temp = {'effect.0': pd.Categorical(pd.Series(effects, index=y.index)),
'effect.1': pd.Series(np.random.choice(prim, size=nt), index=y.index)}
effects = pd.DataFrame(temp, index=y.index)
mod = PanelOLS(data.y, data.x, other_effects=effects)
mod.fit()
clusters = np.random.randint(0, y.shape[2] // 2, size=(nt, 2))
temp = {}
prim = list(map(lambda s: ''.join(s), list(product(ascii_lowercase, ascii_lowercase))))
temp['var.cluster.0'] = pd.Series(np.random.choice(prim, size=nt), index=y.index)
temp['var.cluster.1'] = pd.Series(clusters[:, 1], index=y.index)
clusters = pd.DataFrame(temp, index=y.index)
mod.fit(cov_type='clustered', clusters=clusters)
test_cluster_input_formats.py 文件源码
python
阅读 31
收藏 0
点赞 0
评论 0
评论列表
文章目录