As i am going through the Panel Data which is in LINEAR-MODEL And i tried to run the peace of code given in the Introduction i got this error can you tell me what i have done wrong ??
mod = PanelOLS.from_formula('lwage ~ 1 + expersq + union + married + EntityEffect',data)
And it given me this error And Please Tell me that
EntityEffect is a keyword that is already defined if defined than what is the default value it has.
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
~\Anaconda3\lib\site-packages\patsy\compat.py in call_and_wrap_exc(msg, origin, f, *args, **kwargs)
35 try:
---> 36 return f(*args, **kwargs)
37 except Exception as e:
~\Anaconda3\lib\site-packages\patsy\eval.py in eval(self, expr, source_name, inner_namespace)
165 return eval(code, {}, VarLookupDict([inner_namespace]
--> 166 + self._namespaces))
167
<string> in <module>()
NameError: name 'EntityEffect' is not defined
The above exception was the direct cause of the following exception:
PatsyError Traceback (most recent call last)
<ipython-input-34-11e31c3be118> in <module>()
6 dependent = data.lwage
7 exog = sm.add_constant(data[['expersq','married','union']])
----> 8 mod = PanelOLS.from_formula('lwage ~ 1 + expersq + union + married + EntityEffect',data)
9 res = mod.fit(cov_type='unadjusted')
10 res
~\Anaconda3\lib\site-packages\linearmodels\panel\model.py in from_formula(cls, formula, data, weights, other_effects)
861 entity_effect = parser.entity_effect
862 time_effect = parser.time_effect
--> 863 dependent, exog = parser.data
864 mod = cls(dependent, exog, entity_effects=entity_effect, time_effects=time_effect,
865 weights=weights, other_effects=other_effects)
~\Anaconda3\lib\site-packages\linearmodels\panel\model.py in data(self)
93 """Returns a tuple containing the dependent, exog, endog and instruments"""
94 self._eval_env += 1
---> 95 out = self.dependent, self.exog
96 self._eval_env -= 1
97 return out
~\Anaconda3\lib\site-packages\linearmodels\panel\model.py in exog(self)
107 """DataFrame containing the exogenous variables"""
108 out = dmatrix(self._rhs, self._data.dataframe, eval_env=self._eval_env,
--> 109 return_type='dataframe', NA_action=self._na_action)
110 return out
111
~\Anaconda3\lib\site-packages\patsy\highlevel.py in dmatrix(formula_like, data, eval_env, NA_action, return_type)
289 eval_env = EvalEnvironment.capture(eval_env, reference=1)
290 (lhs, rhs) = _do_highlevel_design(formula_like, data, eval_env,
--> 291 NA_action, return_type)
292 if lhs.shape[1] != 0:
293 raise PatsyError("encountered outcome variables for a model "
~\Anaconda3\lib\site-packages\patsy\highlevel.py in _do_highlevel_design(formula_like, data, eval_env, NA_action, return_type)
163 return iter([data])
164 design_infos = _try_incr_builders(formula_like, data_iter_maker, eval_env,
--> 165 NA_action)
166 if design_infos is not None:
167 return build_design_matrices(design_infos, data,
~\Anaconda3\lib\site-packages\patsy\highlevel.py in _try_incr_builders(formula_like, data_iter_maker, eval_env, NA_action)
68 data_iter_maker,
69 eval_env,
---> 70 NA_action)
71 else:
72 return None
~\Anaconda3\lib\site-packages\patsy\build.py in design_matrix_builders(termlists, data_iter_maker, eval_env, NA_action)
694 factor_states,
695 data_iter_maker,
--> 696 NA_action)
697 # Now we need the factor infos, which encapsulate the knowledge of
698 # how to turn any given factor into a chunk of data:
~\Anaconda3\lib\site-packages\patsy\build.py in _examine_factor_types(factors, factor_states, data_iter_maker, NA_action)
441 for data in data_iter_maker():
442 for factor in list(examine_needed):
--> 443 value = factor.eval(factor_states[factor], data)
444 if factor in cat_sniffers or guess_categorical(value):
445 if factor not in cat_sniffers:
~\Anaconda3\lib\site-packages\patsy\eval.py in eval(self, memorize_state, data)
564 return self._eval(memorize_state["eval_code"],
565 memorize_state,
--> 566 data)
567
568 __getstate__ = no_pickling
~\Anaconda3\lib\site-packages\patsy\eval.py in _eval(self, code, memorize_state, data)
549 memorize_state["eval_env"].eval,
550 code,
--> 551 inner_namespace=inner_namespace)
552
553 def memorize_chunk(self, state, which_pass, data):
~\Anaconda3\lib\site-packages\patsy\compat.py in call_and_wrap_exc(msg, origin, f, *args, **kwargs)
41 origin)
42 # Use 'exec' to hide this syntax from the Python 2 parser:
---> 43 exec("raise new_exc from e")
44 else:
45 # In python 2, we just let the original exception escape -- better
~\Anaconda3\lib\site-packages\patsy\compat.py in <module>()
PatsyError: Error evaluating factor: NameError: name 'EntityEffect' is not defined
expersq + union + married + EntityEffect
^^^^^^^^^^^^