Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

delete unused functions #317

Merged
merged 1 commit into from
Feb 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 1 addition & 60 deletions pyfixest/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,63 +222,4 @@ def get_data(N=1000, seed=1234, beta_type="1", error_type="1", model="Feols"):
df["weights"] = rng.uniform(0, 1, N)
# df["weights"].iloc[]

return df


def get_poisson_data(N=1000, seed=4320):
"""
Generate data following a Poisson regression DGP.

Parameters
----------
N : int, optional
Number of observations. Default is 1000.
seed : int, optional
Seed for the random number generator. Default is 4320.

Returns
-------
pandas.DataFrame
Generated data with columns 'Y', 'X1', 'X2', 'X3', and 'X4'.
"""
# create data
np.random.seed(seed)
X1 = np.random.normal(0, 1, N)
X2 = np.random.choice([0, 1], N, True)
X3 = np.random.choice([0, 1, 2, 3, 4, 5, 6], N, True)
X4 = np.random.choice([0, 1], N, True)
beta = np.array([1, 0, 1, 0])
u = np.random.normal(0, 1, N)
mu = np.exp(1 + X1 * beta[0] + X2 * beta[1] + X3 * beta[2] + X4 * beta[3] + u)

Y = np.random.poisson(mu, N)

return pd.DataFrame({"Y": Y, "X1": X1, "X2": X2, "X3": X3, "X4": X4})


def absolute_diff(x, y, tol=1e-03):
"""

Calculate the absolute difference between two values.

Parameters
----------
x : numpy.ndarray
Numeric array representing the reference value.
y : numpy.ndarray
Numeric array representing the value to compare against.
tol : float, optional
Tolerance value used to determine if two values are different. Default is 1e-03.

Returns
-------
bool
True if the absolute difference is greater than the tolerance and there
is a non-zero value in y, False otherwise.
"""
absolute_diff = (np.abs(x - y) > tol).any()
if not any(y == 0):
relative_diff = (np.abs(x - y) / np.abs(y) > tol).any()
return absolute_diff and relative_diff
else:
return absolute_diff
return df
Loading