0
$\begingroup$

I want to use logistic regression, but my data are time series data. Every observation is a different day, and I have days consecutively for 20 years. I have three variables(the predictors) that are daily measurements in these 20 years. My dependent variable is if it snows or not that day. I cannot use Logistic regression because the data are not independent. I was thinking of generalized estimating equations, but the data are neither clustered nor longitudinal. Any idea?

$\endgroup$
1

1 Answer 1

2
$\begingroup$

I'm not sure if that's legit but you can still use GEE. If I were you I would define an autoregressive working dependence structure (use the PACF and confirm which lags is any are significantly different from zero), covariance type as robust and I would treat all observations as one cluster.

Here's Python code for that:

import statsmodels.api as sm
import statsmodels.formula.api as smf

# Define the GEE model formula
formula = 'target ~ X1 + X2 + X3'

# Define the correlation structure - note that this statsmodels class allows only for a first-order autoregressive working dependence structure. Grid will become default argument in the future release, so to suppress warnings I set this argument to True.
cov_struct = sm.cov_struct.Autoregressive(grid=True)

# Define the GEE model with binary target variable and logistic link function
model = smf.gee(
    formula=formula,
    data=df,
    groups=np.ones(len(df)),
    family=sm.families.Binomial(),
    cov_struct=cov_struct,
)

# Fit the GEE model
result = model.fit(
    maxiter=100,
    cov_type='robust',
)

# Print the summary of the model
print(result.summary())
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.