My analysis focuses on causal inference. I am using the inverse of the propensity scores to form weights (Propensity score is the probability of receiving a treatment (or intervention) given a set of covariates). My question is, does anyone know how I do do the balance assessment for covariates before and after weighting? I know there are packages out there that may do this, but I want to write it by hand not by using packages. Here is an example:
X1<-c(1,1,1,0,0,1) #Covariate
X2<c(0,1,1,0,1,0) #Covariate
X3<-c(1,0,1,1,1,0) #Treatment
X4<- c(1,0,1,1,0,0) #Outcome
data<-data.frame(X1,X2,X3,X4)
model<- glm(X3~X1+X2, family= "binomial", data=subset(data, X3==1))
propensity_score<- predict(p, newdata=data, type="response")
weights<- 1/propensity_score
The is to see if the covariates have a balance after weighting with the inverse of the propensity score (I know the general idea but am not familiar with the theory behind it)