Appendix
SAS Syntax for Proportional Hazard Model with Frailty Term
The following is the syntax used for fitting the unadjusted proportional hazard model relating positive affect (PA) and time to sex with a shared frailty term in SAS.
procphreg data=reportdata ;
class id;
modelttsex_hrs*censor(1)=patotal ;
random id;
run;
The ttsex_hrs variable is the duration (in hours) between the time of the current report and the time of next sex (for observed events) or between the time of the current report and the time of the next report (for censored observations). censor is an indicator variable equal to 1 if time to sex is censored (i.e. a sex event does not occur between reports) and 0 if an time to sex is observed (i.e. a sex event occurs before the next report). The variable patotal contains the PA variable collected on the momentary report. The shared frailty term is introduced using the RANDOM statement and specifying the variable that represents a cluster (in this case that is id). This variable must also be specified in the CLASS statement. The model is run on a dataset with multiple observations per individual (in this case called reportdata).
SAS Syntax for Proportional Hazard Model with Robust Standard Errors
The following is the syntax used for fitting the unadjusted proportional hazard model relating PA and time to sex with robust standard errors in SAS.
procphreg data=reportdatacovs(aggregate) ;
modelttsex_hrs*censor(1)=patotal;
idid;
run;
The ttsex_hrs,censor, and patotal variables are the same as for the previous example. The robust standard errors are implemented by specifying the COVS(AGGREGATE) option on the PROC PHREG statement. The ID statement indicates the variable identifying a new individual/cluster(in this case that is id). The model is run on a dataset with multiple observations per individual (reportdata).
R Syntax for Accelerated Failure Time Model
The following is the syntax used for fitting the unadjusted accelerated failure time model relating PA and time to sex using a modified version of the lss function in R.
lss(Surv(log(ttsex_hrs),sex)~patotal,data=reportdata, mcsize=100, cluster=1)
The ttsex_hrs and patotalvaraibles are the same as those described above. sex is an indicator variable equal to 1 if an observation is observed (i.e. a sex event occurs) and equal to 0 if an observation is censored. The mcsize option specifies the resampling size for calculating the standard error of the regression coefficients. The cluster option identifies the column in the dataset containing the cluster variable (in this case id is in the first column of the dataset so cluster is set to 1). The input to the lssfunction is an R survival object (Surv()). The model is run on a dataset with multiple observations per individual (in this case called reportdata).