Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
self.group,
self.data[self.group].unique()[i],
self.ranked_data,
)
for i in range(self.data[self.group].nunique())
)
betas = np.array(betas)
# Get the model matrix formula from patsy to make it more reliable to set the results dataframe index like Lmer
y, x = dmatrices(self.formula, self.data, 1, return_type="dataframe")
# Perform an intercept only regression for each beta
results = []
perm_ps = []
for i in range(betas.shape[1]):
df = pd.DataFrame({"X": np.ones_like(betas[:, i]), "Y": betas[:, i]})
lm = Lm("Y ~ 1", data=df)
lm.fit(
robust=robust,
conf_int=conf_int,
summarize=False,
n_boot=n_boot,
n_jobs=n_jobs,
n_lags=n_lags,
)
results.append(lm.coefs)
if permute:
# sign-flip permutation test for each beta instead to replace p-values
if perm_on == 'coef':
return_stat = 'mean'
else:
return_stat = 't-stat'
seeds = np.random.randint(np.iinfo(np.int32).max, size=permute)