####################################################### # R function for fitting a logistic regression model # # for estimating participation probabilities # # using the method of Chen, Li and Wu (2020, JASA) # ####################################################### ############################################################## # Input: # # Xa, data matrix of x for the nonprobility sample # # Xb, data matrix of x for the reference sample # # db, the vector of design weights from the reference sample # # # # Output: b0, the estimated regression coefficients # # in the logistic regression model # # # # Note: # # Xa and Xb have the same column variables of x # # The first column of Xa and Xb are 1's for an intercept # # # # Written by Changbao Wu, August 15, 2024 # ############################################################## CLW=function(Xa,Xb,db){ b0=rep(0,dim(Xa)[2]) tol=0.0000001 dif=1 while(dif>tol){ mua=1-1/(1+exp(Xa%*%b0)) mub=1-1/(1+exp(Xb%*%b0)) Uab=t(Xa)%*%Xa[,1]-t(Xb)%*%(db*mub) Hab=-t(Xb)%*%(c(db*mub*(1-mub))*Xb) b1=b0-solve(Hab,Uab) dif=max(abs(b1-b0)) b0=b1 } return(as.vector(b0)) }