Happy new year! Context: I am conducting moderation analysis with binary outcome variable (DV). [Medication use(time1/dichotomous) moderating the effect of X(time1/continuous) on Y(time2/dichotomous)], but I am using a little-known statistical method to reduce problems associated with binary data. I would like help to add some control variables ("gender", "conduct problems") to Hess et al.'s* test of moderation in logistic regression (code below), but I am very new to SAS, coming from SPSS. I could run it as is with no controls (two analyses of male and female), but I would like to try it with gender and conduct problems included in the model if possible. Could somebody please help me to code in the control variables (say "gender" and "conduct problems") without changing the moderating nature of the code below? Less important question: I am unsure what " values of the parameters to be estimated" means. How would I go about deciding if I should change these values or not? *Source of Hess et al.'s code and description: https://papers.ssrn.com/sol3/papers.cfm?abstract_id=2393725 Sorry if my terminology is poor, I have background in psychology not statistics. For ease of access to code without annotations: data test; input n k X1 X2; datalines; 30 7 0 0 33 4 0 1 33 23 1 0 28 6 1 1 run; proc nlmixed data=test DF=120; parms b0=0.1 b1=0.1 b2=0.1 b12=0.1; u = b0 + b1*X1 + b2*X2 + b12*X1*X2; p = exp(u)/(1+exp(u)); model k ~ binomial(n,p); estimate 'phi12' exp(b0+b1+b2+b12)/(1+exp(b0+b1+b2+b12)) + exp(b0)/(1+exp(b0)) - exp(b0+b1)/(1+exp(b0+b1)) - exp(b0+b2)/(1+exp(b0+b2)); run; Annotated SAS Code for Testing Moderation Effects in a 2x2 Experiment with a Binary Dependent Variable
/*---------------------------------------------------------------------------
SAS code for two-way interaction effects in binary data using logistic regression. The following code will run “as is” for any 2x2 experiment, changing only the data and DF value.
---------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------
this is the test dataset (named “test”)
n is the number of subjects in a treatment condition,
k is the number of subjects choosing “1” in that treatment condition,
X1 and X2 are the dummy variables for the two treatment conditions
--------------------------------------------------------------------------*/
data test;
input n k X1 X2;
datalines;
30 7 0 0
33 4 0 1
33 23 1 0
28 6 1 1
run;
/* call proc nlmixed, specifying the degree of freedom (DF) to be n-k
where n is the number of observations and k is the number of parameters */
proc nlmixed data=test DF=120;
/* parms specifies the initial values of the parameters to be estimated
for a 2x2 experiment; these can be set at any value, here are set at 0.1
b0 is the intercept,
b1 and b2 are the coefficients for main effects,
b12 is the interaction coefficient */
parms b0=0.1 b1=0.1 b2=0.1 b12=0.1;
/* specifying the basic utility model for a 2x2 experiment */
u = b0 + b1*X1 + b2*X2 + b12*X1*X2;
/* the next 2 lines formulate a logit model; these can be used as is
even if the research design is modified from 2x2 */
p = exp(u)/(1+exp(u));
model k ~ binomial(n,p);
/* estimating the moderation effect between X1 and X2 for a
2x2 experiment */
estimate 'phi12' exp(b0+b1+b2+b12)/(1+exp(b0+b1+b2+b12)) + exp(b0)/(1+exp(b0)) - exp(b0+b1)/(1+exp(b0+b1)) - exp(b0+b2)/(1+exp(b0+b2));
run;
/* end of code */
... View more