BookmarkSubscribeRSS Feed
courtney889
Calcite | Level 5

Hello, 

I am trying to calculate inverse probability weights for loss-to-followup in my cohort study. From what I've read, my stabilized weights should have a mean of 1 and the sum of the unstabilized weights should be double the sum of the stabilized weights, however, the average of my stabilized weights is 1.4. I tried two methods below (with the tables ipw22 and ipw44) I am not sure where the error in my code could be, it would be greatly appreciated if someone could help!

 

(I had some missing data with the covariates, so I imputed with the mean or mode) so as not to lose too many subjects in the logistic regression.

**I am not sure which version of SAS I am on because I use SAS through EMACS, but I think it is 9.3**

 

/*Part1: Estimate conditional probabilities for denominator using pooled logistic regression*/
proc logistic data=tables.ipw;
class <covariates>;
model dropout= <covariates>/lackfit;
output out=d_data (keep=n_ident d) p=d; run;

 

/*Part2: Calculate cumulative probabilities for stabilized weights (sw)*/
proc sort data=tables.ipw; by n_ident; run;
proc sort data=n_data; by n_ident; run;
proc sort data=d_data; by n_ident; run;

data ipw22;
merge tables.ipwsimple n_data d_data;
by n_ident;
if dropout=1 then do;
uw=1/d; /*unstabilized weight*/
sw=n/d; /*stabilized weight*/
end;

else if dropout=0 then do;
uw=1/(1-d); /*unstabilized weight*/
sw=(1-n)/(1-d); /*stabilized weight*/
end;
run;

 

data ipw44;
merge tables.ipw n_data d_data;
by n_ident;
if dropout=1 then do;
uw=1/d; /*unstabilized weight*/
sw=(1195/2002)/d; /*(eligible population/total population) stabilized weight*/
end;
else if dropout=0 then do;
uw=1/(1-d);
sw=(1-(1195/2002))/(1-d);
end;

predict=log(d/(1-d))*log(d/(1-d)); run; /*Create term to check verifications after*/

 

*----------------------------------------------------
*Assess distribution of SW
*Mean should be=1
*UW range should be greater than SW range
*UW sum should be twice the sum of SW sum
*----------------------------------------------------;

proc means data=ipw22 mean sum min max; var uw sw; run;
proc means data=ipw44 mean sum min max; var sw uw; run;

 

1 REPLY 1
SteveDenham
Jade | Level 19

I've never done anything like this, so take what I suggest with a swimming pool of salt.

 

Could you just scale your SW after calculating the mean?  For instance if you get a mean of 1.4, divide all the stabilized weights you have calculated by 1.4 and then rerun.  The other possibility here is there may be a missing factor.  Whenever I see 1.4, I immediately think of two possibilities - square root of 2 (the remainder is lost to round off) or square root of the normal variate for .975 (=1.96).  If either of those is a possibility, check your sources.

 

SteveDenham

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 632 views
  • 1 like
  • 2 in conversation