I am using survey package to calculate weighted Poisson regression however I am not sure that the weights are used in a correct way.
Each observation of my dataset has been assigned a weight based on Propensity Score and subsequently IPTW.
Example:
library(cobalt)
library(WeightIt)
library(weights)
library(survey)
data("lalonde", package = "cobalt")
W.out <- weightit(treat ~ age + educ + race + nodegree + re74 + re75,
data = lalonde, estimand = "ATT", method = "ps")
fit <- svyglm(married ~ treat, design = d.w, family="quasipoisson")
exp(coefficients(fit))
exp(confint(fit))
The obtained risk ratio is correct (I calculated it manually also) however I am not quite sure about the 95% confidence intervals and the p value.
In STATA, I found that there are different commands for weights, for example: iw and pw. When I use pw command the risk ratio and confidence intervals as well as p value are the same as in R, when I use iw the CI and p value are different.
Am I proceeding correctly in R? Should I use pw in STATA should I want to use STATA?
My questions comes because when I perform the weighted chi square (code: wtd.chi.sq(lalonde$treat, lalonde$married, weight=W.out$weights)
) , the p value resulting is significant while that from Poisson regression is not significant (not in this example, however I am using the same code applied to another dataset). So I have doubts if I am performing these two tests correctly or if I am missing something since I am not familiar with packages such as survey or weights. Please help.
Is there any other way to perform POISSON REGRESSION on a WEIGHTED dataset and a WEIGHTED CHI SQUARE?