1. Data gsa 
The analgesic trial was a single-arm clinical trial involving 395 patients who were given analgesic treatment for pain caused by 
a chronic non-malignant disease. Treatment was to be administered for 12 months and assessed by the patients 
on a five-point Global Satisfaction Assessment (GSA) scale: (1) very good; (2) good; (3) indifferent; (4) bad; (5) very bad. 
As it is frequently of interest to physicians to classify a patients status as either improving or worsening,
for some analyses a dichotomized version was used with variable GSABIN equal to 1 if GSA = 3 and 0 otherwise.
GSA was rated by each person four times during the trial: at months 3, 6, 9, and 12, corresponding to variables gsabin1, gsabin2, gsabin3 and gsabin4.
Apart from the outcome of interest, a pain control assessment at baseline (pca0) was used as covariate. Variable PATID contains the ID of the patient.


2. Full Likelihood Based Bahadur Model (see progr_full.sas)
Library dat can be specified by the user, where gsa data can be stored.

To apply the full likelihood Bahadur model, the original format of the GSA data was used.
Further, the NLMIXED procedure of SAS (SAS 9.4) was applied, when all possible profiles were considered.
Note that the variable intercept is used here only for the general(.) statement of proc nlmixed.
For the first-order correlations, a Toepliz structure was assumed, for the higher-order correlations a general form of the correlations.

3. Pairwise Likelihood Based Model (see progr_pairwise.sas)

In this SAS file, some examples of data formatting are listed as well as the code to fit the model to different cases of the estimating equation.
In these examples, some cases are omitted due to their mutual similarity.
Complete cases and complete pairs are different in their inverse probability weights:
for complete cases, the weights are calculated based on the probability of a patient to be completely observed,
for complete pairs the probability to be observed until a certain time-point.
After the model is fitted, the principle of sandwich-type robust variance estimation is applied to obtain precision estimates.

Naive Case:
For modeling using naive estimating equations, all possible pairs from the sequence of GSA measurement per patient were considered (response and responsek).
If the response measurement of a pair was missing, the 999 code was used instead.
For the available cases the whole data was used, for the complete pairs and complete cases the corresponding subject selection.
The code for the available cases can be found in the SAS file.

Singly Robust Case: 
First, a dropout model with previous measurement was considered.
Then, based on probabilities estimated with the dropout model, the inverse probabilities weights were calculated.
Again, the code for available cases are in the SAS file. As for naive case, the data and the code was adopted for the complete pairs and complete cases.

Doubly Robust Case:
The inverse probability weights were calculated in the same way as for the singly robust case.
To model the expectations in the doubly robust case, a help Bahadur model was applied.
To model the marginal probabilities, the expressions for the linear predictors were defined at different time-points.
To model pairs, assuming all previous measurements are available, the history parameters were used by taking, as reference for the history,
the response with the lower value of the time point (e.g., in pair Y2 - Y3 we used only gsabin1 as the history covariate).
If some of the measurements are missing, the corresponding term in the model will be omitted.
In the data, the pairs are complemented with expectations. An implementation for available cases is given in the SAS file. 
It was also shown how it can be adapted to the case of complete pairs. Further, similar code will be applied to fit the model with complete cases.

