<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Simulate data for logistic regression by specifying the response rate and the significant covari in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/Simulate-data-for-logistic-regression-by-specifying-the-response/m-p/477665#M24877</link>
    <description>&lt;P&gt;Hi Rick,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your quick reply.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1) Yes, by response rate, I mean the proportion of success.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2) Your first example of simulating data for linear regression uses the normal distribution to simulate the values of the predictors.&amp;nbsp; Recall your code&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;do j = 1 to dim(x);
				  
     x[j] = rand("Normal"); /* 2. Simulate explanatory variables   */
				
end;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;3) That's a very good idea to use the intercept to adjust the response rate.&amp;nbsp; Thank you!&lt;/P&gt;</description>
    <pubDate>Thu, 12 Jul 2018 19:41:34 GMT</pubDate>
    <dc:creator>PurpleNinja</dc:creator>
    <dc:date>2018-07-12T19:41:34Z</dc:date>
    <item>
      <title>Simulate data for logistic regression by specifying the response rate and the significant covariates</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Simulate-data-for-logistic-regression-by-specifying-the-response/m-p/477501#M24863</link>
      <description>&lt;P&gt;I read this blog post by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13684"&gt;@Rick_SAS&lt;/a&gt;&amp;nbsp;on simulating data for linear regression.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://blogs.sas.com/content/iml/2017/01/25/simulate-regression-model-sas.html" target="_blank"&gt;https://blogs.sas.com/content/iml/2017/01/25/simulate-regression-model-sas.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I modified the code to simulate data for logistic regression, and it works very well.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;mu = beta[0]; /* intercept term */

do j = 1 to &amp;amp;ncovar;
     mu = mu + beta[j] * x[j]; /* + sum(beta[j]*x[j]) */
end;

prob = 1 / (1 + exp(-mu)); /* specify the probability of success using the logistic function and "mu" */

y = RAND('BERNOULLI', prob); /* simulate binary variables based on "prob" */&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thanks, Rick!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, I now want to&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;a) add a binary covariate that is way more significant than the other continuous covariates&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;b) specify the response rate (i.e. the proportion of success for "Y").&amp;nbsp; For my particular example, I need a very low response rate.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Based on Rick's example, I know how to specify the regression coefficients, but I don't know how to also specify the response rate.&amp;nbsp; (It may be impossible to do both.)&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For my example, I don't need to specify the regression coefficients; I just need the binary covariate to be much more significant than the continuous covariates, and I need a very low response rate in my raw data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I accomplish both of these goals?&lt;/P&gt;</description>
      <pubDate>Thu, 12 Jul 2018 14:24:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Simulate-data-for-logistic-regression-by-specifying-the-response/m-p/477501#M24863</guid>
      <dc:creator>PurpleNinja</dc:creator>
      <dc:date>2018-07-12T14:24:12Z</dc:date>
    </item>
    <item>
      <title>Re: Simulate data for logistic regression by specifying the response rate and the significant covari</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Simulate-data-for-logistic-regression-by-specifying-the-response/m-p/477533#M24869</link>
      <description>&lt;P&gt;I also wrote several articles on simulating&amp;nbsp;logistic&amp;nbsp;data directly:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://blogs.sas.com/content/iml/2014/06/25/simulate-logistic-data.html" target="_self"&gt;https://blogs.sas.com/content/iml/2014/06/25/simulate-logistic-data.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://blogs.sas.com/content/iml/2014/06/27/simulate-many-samples-from-a-logistic-regression-model.html" target="_self"&gt;https://blogs.sas.com/content/iml/2014/06/27/simulate-many-samples-from-a-logistic-regression-model.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For the binary covariate, just use (or simulate) a 0/1 variable and give it a large relative coefficient such as&lt;/P&gt;
&lt;P&gt;G = rand("Bern", 0.5);&lt;/P&gt;
&lt;P&gt;eta = intercept + 50*G + 0.3*x1 - 0.4*x2;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;By "response rate," I assume you mean the relative proportion of 0/1 responses.&amp;nbsp; That depends on the linear predictor (eta). You can use the&amp;nbsp;Intercept term to raise or lower the rate, but&amp;nbsp;the rate will depends not only on mean(eta) but also on&amp;nbsp;the values of the explanatory variables. Adjusting the response rate is easiest when the explanatory variables are normally distributed with mean 0.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Jul 2018 15:08:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Simulate-data-for-logistic-regression-by-specifying-the-response/m-p/477533#M24869</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2018-07-12T15:08:44Z</dc:date>
    </item>
    <item>
      <title>Re: Simulate data for logistic regression by specifying the response rate and the significant covari</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Simulate-data-for-logistic-regression-by-specifying-the-response/m-p/477665#M24877</link>
      <description>&lt;P&gt;Hi Rick,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your quick reply.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1) Yes, by response rate, I mean the proportion of success.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2) Your first example of simulating data for linear regression uses the normal distribution to simulate the values of the predictors.&amp;nbsp; Recall your code&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;do j = 1 to dim(x);
				  
     x[j] = rand("Normal"); /* 2. Simulate explanatory variables   */
				
end;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;3) That's a very good idea to use the intercept to adjust the response rate.&amp;nbsp; Thank you!&lt;/P&gt;</description>
      <pubDate>Thu, 12 Jul 2018 19:41:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Simulate-data-for-logistic-regression-by-specifying-the-response/m-p/477665#M24877</guid>
      <dc:creator>PurpleNinja</dc:creator>
      <dc:date>2018-07-12T19:41:34Z</dc:date>
    </item>
  </channel>
</rss>

