2

我想执行 OLS 面板回归

import pandas as pd
import numpy as np
import statsmodels.api as sm

from linearmodels.datasets import wage_panel
from linearmodels.panel import PanelOLS

data = wage_panel.load()

但我得到这个错误:

ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-2-fe79e40655e1> in <module>
      3 import statsmodels.api as sm
      4 
----> 5 from linearmodels.datasets import wage_panel
      6 from linearmodels.panel import PanelOLS
      7 

ModuleNotFoundError: No module named 'linearmodels'

我不知道为什么会这样。有任何想法吗?

4

1 回答 1

2

“linearmodels”是一个单独的包,参见https://github.com/bashtage/linearmodels。因此,必须单独安装:

pip install linearmodels为我工作。

于 2020-11-13T13:28:39.023 回答