Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Options

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

🔒 This topic is **solved** and **locked**.
Need further help from the community? Please
sign in and ask a **new** question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Posted 11-15-2015 02:05 PM
(1117 views)

When we are talk about confouders in statistics, we usually say that the distribution of confounders is not equal in Expousre and Disease and the confounders also correlate with disease and expousre.

It is very easy to simulate confounder's effect in continuous variable and test it by regression by creating a random varaible on confouder and multiply it with plus one error term to get the x and y.

Now, the correlation between X and Y is due to confounder.

However, I am confused when I try to simulate in binary variable.

can everyone shows me how to do it in E, D, and Confounder all are binary variables.

1 ACCEPTED SOLUTION

Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

You could play with something like this:

```
data test;
length C D E $16;
call streamInit(8685);
exposedEffect = 1; /* No difference in exposure effect */
unexposedEffect = 1;
confoundEffect = 10; /* Effect mostly due to confounding factor */
probC_Exposed = 0.7; /* Confounding probability in exposed group */
probC_Unexposed = 0.1; /* Confounding probability in unexposed group */
groupSize = 100;
/* Unexposed group */
E = "Unexposed";
do i = 1 to groupSize;
id + 1;
if rand("BERNOULLI", probC_Unexposed) then C = "Confounded";
else C = "Unconfounded";
if rand("BERNOULLI", logistic(unexposedEffect+(C="Confounded")*confoundEffect))
then D = "Sick";
else D = "Not sick";
output;
end;
/* Exposed group */
E = "Exposed";
do i = 1 to groupSize;
id + 1;
if rand("BERNOULLI", probC_Exposed) then C = "Confounded";
else C = "Unconfounded";
if rand("BERNOULLI", logistic(ExposedEffect+(C="Confounded")*confoundEffect))
then D = "Sick";
else D = "Not sick";
output;
end;
keep id C D E;
run;
/* Exposure effect shows up as significant when confounding is ignored */
proc freq data=test;
tables E*D / chisq;
run;
proc logistic data=test;
class E;
model D(event="Sick") = E;
run;
/* Etc... */
```

PG

1 REPLY 1

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

You could play with something like this:

```
data test;
length C D E $16;
call streamInit(8685);
exposedEffect = 1; /* No difference in exposure effect */
unexposedEffect = 1;
confoundEffect = 10; /* Effect mostly due to confounding factor */
probC_Exposed = 0.7; /* Confounding probability in exposed group */
probC_Unexposed = 0.1; /* Confounding probability in unexposed group */
groupSize = 100;
/* Unexposed group */
E = "Unexposed";
do i = 1 to groupSize;
id + 1;
if rand("BERNOULLI", probC_Unexposed) then C = "Confounded";
else C = "Unconfounded";
if rand("BERNOULLI", logistic(unexposedEffect+(C="Confounded")*confoundEffect))
then D = "Sick";
else D = "Not sick";
output;
end;
/* Exposed group */
E = "Exposed";
do i = 1 to groupSize;
id + 1;
if rand("BERNOULLI", probC_Exposed) then C = "Confounded";
else C = "Unconfounded";
if rand("BERNOULLI", logistic(ExposedEffect+(C="Confounded")*confoundEffect))
then D = "Sick";
else D = "Not sick";
output;
end;
keep id C D E;
run;
/* Exposure effect shows up as significant when confounding is ignored */
proc freq data=test;
tables E*D / chisq;
run;
proc logistic data=test;
class E;
model D(event="Sick") = E;
run;
/* Etc... */
```

PG

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

Multiple Linear Regression in SAS

Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.

Find more tutorials on the SAS Users YouTube channel.