Exemplo n.º 1
0
def fit(request):
    method = request.param
    data = generate_simultaneous_data()
    if 'ols' in method or 'sur' in method:
        mod = SUR
        for key in data:
            temp = data[key]
            temp['exog'] = concat([temp['exog'], temp['endog']], 1)
            del temp['endog']
            del temp['instruments']
    else:
        mod = IV3SLS
    if 'ols' in method or '2sls' in method:
        fit_method = 'ols'
    else:
        fit_method = 'gls'
    mod = mod(data)
    iterate = 'ireg3' in method
    stata = results[method]
    debiased = method in ('ols', '2sls')
    kwargs = {}
    decimal = 2 if 'ireg3' in method else 5
    rtol = 10**-decimal
    res = mod.fit(cov_type='unadjusted',
                  method=fit_method,
                  debiased=debiased,
                  iterate=iterate,
                  **kwargs)
    return stata, res, rtol
def fit(request):
    method = request.param
    data = generate_simultaneous_data()
    if "ols" in method or "sur" in method:
        mod = SUR
        for key in data:
            temp = data[key]
            temp["exog"] = concat([temp["exog"], temp["endog"]], axis=1, sort=False)
            del temp["endog"]
            del temp["instruments"]
    else:
        mod = IV3SLS
    if "ols" in method or "2sls" in method:
        fit_method = "ols"
    else:
        fit_method = "gls"
    mod = mod(data)
    iterate = "ireg3" in method
    stata = results[method]
    debiased = method in ("ols", "2sls")
    kwargs = {}
    decimal = 3 if "ireg3" in method else 5
    rtol = 10**-decimal
    res = mod.fit(
        cov_type="unadjusted",
        method=fit_method,
        debiased=debiased,
        iterate=iterate,
        **kwargs,
    )
    return stata, res, rtol
Exemplo n.º 3
0
"""
Important cases

"""
import os
import subprocess
from typing import List

import pandas as pd

from linearmodels.tests.system._utility import generate_simultaneous_data

data = generate_simultaneous_data()
all_cols: List[str] = []
out = []
for key in data:
    eqn = data[key]
    for key in ("exog", "endog"):
        vals = eqn[key]
        for col in vals:
            if col in all_cols:
                continue
            else:
                out.append(vals[col])
                all_cols.append(col)
out_df = pd.concat(out, 1, sort=False)
if "const" in out_df:
    out_df.pop("const")
out_df.to_stata("simulated-3sls.dta", write_index=False)
SEP = """