logistic regression model for process with memory Say there is a stream of binary variables x(t) where t is a discrete index. Say the model is that p=p(x(t)=1) is logistic regression on past realization: log(p/1-p) = x(t-1)b1 + x(t-2)b2 + ... x(t-L)bL + b0. Now to fit the model, one can prepare the design matrix X which contains consecutive lags of order L so that X is (N-L)L in size: X = [x(1) ... x(L); x(2) ... x(L+1); ... x(N-L-1) ... x(N-1)] and the dependent variable Y is just [x(L+1), x(L+2), ... x(N)] in order to maximize likelihood, standard function such as glmfit in MATLAB assumes that the variables X and Y are independent, however the model is such that they are not. How can this be solved? Thanks.
 A: From what you write, your model is 
$$P(X_t = 1 \mid \{X_{t-1},...,X_{t-L}) = \Lambda_t (g_t), \;\; \Lambda(g) = (1+e^{-g})^{-1},\;\; g_t=b_0 + \sum_{j=1}^Lb_jX_{t-j}$$
The joint probability mass function of the $X$'s is, by the chain rule,
$$P(X_N,...,X_{N-L}) = P(X_N\mid X_{N-1},...,X_{N-L})\cdot P(X_{N-1}\mid X_{N-2},...,X_{N-L-1})\cdot...\cdot P(X_{L+1}\mid X_{L},...,X_{1})$$
So the log-likelihood is 
$$\sum_{i=L+1}^{N}\left[X_i\ln(\Lambda_i)+(1-X_i)\ln(1-\Lambda_i)\right]$$
The maximum likelihood estimator satisfies the first order conditions
$$\sum_{i=L+1}^N\left[x_i - \Lambda_i(g_i)\right]\cdot\frac{\partial g_i}{\partial b_0} = \sum_{i=L+1}^N\left[x_i - \Lambda_i(g_i)\right]=0$$
for the constant term,
and
$$\sum_{i=L+1}^N\left[x_i - \Lambda_i(g_i)\right]\cdot\frac{\partial g_i}{\partial b_j}= \sum_{i=L+1}^N\left[x_i - \Lambda_i(g_i)\right] x_{i-j}=0,\qquad j=1,...,L$$
for the lags.
As you can see, the mathematical expressions are exactly like in the usual model. If you create the "dependent variable" series and the "regresors series" appropriately, and label them accordingly as separate series, then the software should run and maximize the log-likelihood -it cannot tell whether the regressors are essentially lagged dependent variables. The statistical properties of the estimator is another matter.
A: After discussion with my friend Liran I suddenly realized my question is quite naive... The independence assumption is only on the CONDITIONAL probabilities. Meaning that the independence is only on the error term. Therefore, statistically the assumption is correct although the predictors and predicted variables are not.
The model is NOT:
$$log{\frac{p(x(t))}{1-p(x(t))}}=\sum_{k=1}^{N}{x(t-k)}\beta_k + \epsilon(t)$$
but rather:
$$log{\frac{p(x(t)|x(t-1),...,x(t-N))}{1-p(x(t)|x(t-1),...,x(t-N)))}}=\sum_{k=1}^{N}{x(t-k)}\beta_k + \epsilon(t)$$
So that as long as the NOISE is independent, the model assumption holds.
A: There is some research in econometrics concerning using limited dependent variable models (logit & probit) in time series context:  
https://helda.helsinki.fi/bitstream/handle/10138/23519/studieso.pdf?sequence=1 
You can find references there on page 7 (de Jong & Woutersen) concerning regularity conditions for ML estimators.
EDIT:
Link for the consistency of ML estimator 
http://ideas.repec.org/a/cup/etheor/v27y2011i04p673-702_00.html
