I am using Logistic Regression with count representation. So, for any feature-tuple, I have few 0's(negative class) and few 1's. I duplicate each row, one for target 0 and other for target 1, And I use, number of 0's as sample weights for the row with target 0 and number of 1's as sample weights for the row with target 1.
gets pre-processed as
I am using sandwich estimator for estimating covariance matrix of the coefficients as described in https://web.stanford.edu/class/stats200/Lecture26.pdf
sigma=inverse(X.T * W_hat * X ) * (X. T * W_tilda * X ) * inverse(X.T * W_hat * X )
Where, X, an n by k matrix, contains all observations in row-manner (so, i_th observation (x_i1,x_i2,...,x_ik) constitute the i_th row)
W_hat, an n by n matrix, is diag((y_1_hat*(1-y_1_hat), (y_2_hat*(1-y_2_hat)........(y_n_hat*(1-y_n_hat))
W_tilda, an n by n matrix, diag((y_1-y_1_hat)^2, (y_2-y_2_hat)^2,.......,(y_n-y_n_hat)^2)
How, can I estimate covariance matrix for my model which contains same feature tuple for both targets along with sample weights?
I found one article, which suggests multiplying with each row of X and W_hat and W_tilda with sqrt(sample_weights). But, I can't have duplicate rows in my X matrix(otherwise , it would be singular). https://www.parisschoolofeconomics.eu/docs/dupraz-yannick/using-weights-in-stata(1).pdf
Anyways, I am not sure if multiplying with sqrt(sample_weights) is the correct way of handling this situation.