Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
df = df.assign(Sig=df["Perm-P-val"].apply(lambda x: _sig_stars(x)))
df = df.assign(Sig=df["P-val"].apply(lambda x: _sig_stars(x)))
elif "Perm-P-val" in df.columns:
lambda x: _sig_stars(x)
)
intercept_pd = dict()
for c in results.columns:
intercept_pd[c] = np.nan
intercept_pd = pd.DataFrame(intercept_pd, index=[0])
results = pd.concat([intercept_pd, results], ignore_index=True)
results.index = x.columns
self.coefs = results
if to_corrs:
self.fixef = pd.DataFrame(betas, columns=ivs)
else:
self.fixef = pd.DataFrame(betas, columns=x.columns)
self.fixef.index = self.data[self.group].unique()
self.fixef.index.name = self.group
if permute:
# get signifance stars
sig = [_sig_stars(elem) for elem in perm_ps]
# Replace dof and p-vales with permutation results
if conf_int != "boot":
self.coefs = self.coefs.drop(columns=["DF", "P-val"])
if to_corrs:
self.coefs["Num_perm"] = [np.nan] + [permute] * (
self.coefs.shape[0] - 1
)
self.coefs["Sig"] = [np.nan] + sig
self.coefs["Perm-P-val"] = [np.nan] + perm_ps
else:
self.coefs["Num_perm"] = [permute] * self.coefs.shape[0]
self.coefs["Sig"] = sig
self.coefs["Perm-P-val"] = perm_ps
self.coefs = self.coefs[
[
"Estimate",
robust=robust,
n_lags=n_lags,
cluster=cluster,
weights=weights,
seed=seeds[i],
)
for i in range(permute)
)
perm_ts = np.array(perm_ts)
p = []
for col, fit_t in zip(range(perm_ts.shape[1]), t):
p.append(_perm_find(perm_ts[:, col], fit_t))
p = np.array(p)
df = np.array([permute] * len(p))
sig = np.array([_sig_stars(elem) for elem in p])
# Make output df
results = np.column_stack([b, ci_l, ci_u, se, df, t, p, sig])
results = pd.DataFrame(results)
results.index = x.columns
results.columns = [
"Estimate",
"2.5_ci",
"97.5_ci",
"SE",
"DF",
"T-stat",
"P-val",
"Sig",
]
results[