<?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: how to write code for 1 parameter logistic model in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-write-code-for-1-parameter-logistic-model/m-p/646549#M193449</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks much for your code and detailed explanation!&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried the code you suggested and it worked.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My eventual goal is do some iteration using theta=[-20, 20], then stop at certain criteria. That's a very complex process for me. I thought about asking the question from simple step, then go further, but that caused confusion.When you get time, could you please go to the following link to read the &lt;STRONG&gt;lasted post&lt;/STRONG&gt; and help? Again, thanks a bunch!&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Programming/How-to-write-150-values-in-one-column-to-be-150-data-set/m-p/646496/highlight/false#M193412" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/How-to-write-150-values-in-one-column-to-be-150-data-set/m-p/646496/highlight/false#M193412&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Sun, 10 May 2020 18:43:38 GMT</pubDate>
    <dc:creator>superbug</dc:creator>
    <dc:date>2020-05-10T18:43:38Z</dc:date>
    <item>
      <title>how to write code for 1 parameter logistic model</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-write-code-for-1-parameter-logistic-model/m-p/646419#M193358</link>
      <description>&lt;P&gt;Hello SAS expert,&lt;/P&gt;
&lt;P&gt;I have a test contains 150 items, item difficulty parameter for each item is as attached. Suppose I now have candidate whose ability level is 0, I named it theta=0. Now on &lt;STRONG&gt;each of the item&lt;/STRONG&gt;, I need to calculate the probability of this candidate correctly answer on each of the time, how should I edit the following &lt;STRONG&gt;macro sas&lt;/STRONG&gt; code to make it work?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc import datafile="\bpar.csv"&amp;nbsp; &amp;nbsp;dbms=csv out=bpar replace; run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%macro f1;&lt;/P&gt;
&lt;P&gt;do i=1 to 150;&amp;nbsp; /*from item 1 to item 150*/&lt;/P&gt;
&lt;P&gt;prob &amp;amp;i= exp(theta-bpar&amp;amp;i)/(1+exp(theta-bpar&amp;amp;i);&amp;nbsp; &amp;nbsp;/*1 parameter logistic regression model*/&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;%mend;&lt;/P&gt;
&lt;P&gt;%f1;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 09 May 2020 20:20:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-write-code-for-1-parameter-logistic-model/m-p/646419#M193358</guid>
      <dc:creator>superbug</dc:creator>
      <dc:date>2020-05-09T20:20:59Z</dc:date>
    </item>
    <item>
      <title>Re: how to write code for 1 parameter logistic model</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-write-code-for-1-parameter-logistic-model/m-p/646428#M193364</link>
      <description>&lt;OL&gt;
&lt;LI&gt;There's a lot of confusion here, so much that I don't even understand the question.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The formula you show is NOT a Logistic Regression formula as far as I can see (unless it is some algebraic manipulation of a Logistic Regression formula that I am not familiar with). A true logistic regression has an intercept and a slope, and the slope must be multiplied by an x-variable, and I don't see that in your formula. (You can see the proper formula to predict the probability of Y=1 at Wikipedia and many many web pages.) So I have no idea ahow to proceed here. We would furthermore need to know the slope and intercept even if we had the proper formula. So I have no idea how to proceed here.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So I advise you to phrase the problem more clearly, look up the proper formula, determine the intercept and slope in your logistic model, and then we might be able to move forward.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, your macro appears to be data set code, but it's not called within a data set, and then there are syntax errors as well. And it's not obvious why you need a macro anyway.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV id="tap-translate"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV id="tap-translate"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV id="tap-translate"&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Sun, 10 May 2020 00:37:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-write-code-for-1-parameter-logistic-model/m-p/646428#M193364</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-05-10T00:37:13Z</dc:date>
    </item>
    <item>
      <title>Re: how to write code for 1 parameter logistic model</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-write-code-for-1-parameter-logistic-model/m-p/646431#M193367</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for your response!&lt;/P&gt;
&lt;P&gt;In the field of measurement, the model is called Rasch model, which is similar to 1 parameter logistic regression model. This one parameter is called item difficulty. If I want to know the probability of a examinee with a certain ability level get item i correct, it write as,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;prob (i)=exp(theta-bpar(i))/(1+(exp(theta-bpar(i)))&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;where theta denote a certain ability level, bpar is the difficulty parameter of item i&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now I have 150 items in a test, the "bpar.csv" as in the attachment are the item difficulty for those 150 items. Now suppose I have a examinee with ability level theta=0,&amp;nbsp; I want to know the probability of this&amp;nbsp; examinee get each item correct, how should I wrote that in a SAS macro?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 10 May 2020 00:38:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-write-code-for-1-parameter-logistic-model/m-p/646431#M193367</guid>
      <dc:creator>superbug</dc:creator>
      <dc:date>2020-05-10T00:38:31Z</dc:date>
    </item>
    <item>
      <title>Re: how to write code for 1 parameter logistic model</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-write-code-for-1-parameter-logistic-model/m-p/646434#M193370</link>
      <description>&lt;P&gt;So where do we get the value of the parameter bpar? You say your .csv file contains difficulty, not bpar. Your code also seems to indicate bpar(i), that there are many values of bpar.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV id="tap-translate"&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Sun, 10 May 2020 00:48:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-write-code-for-1-parameter-logistic-model/m-p/646434#M193370</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-05-10T00:48:55Z</dc:date>
    </item>
    <item>
      <title>Re: how to write code for 1 parameter logistic model</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-write-code-for-1-parameter-logistic-model/m-p/646436#M193371</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;in the "bpar.csv", there is a variable named bpar. There are 150 items in total, so there are 150 bpar values.&lt;/P&gt;
&lt;P&gt;Corresponding to each bpar value, there is one probability. so I need to write a macro that can compute 150 probabilities.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I know my code is not correct, so I am asking for help.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 10 May 2020 01:11:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-write-code-for-1-parameter-logistic-model/m-p/646436#M193371</guid>
      <dc:creator>superbug</dc:creator>
      <dc:date>2020-05-10T01:11:37Z</dc:date>
    </item>
    <item>
      <title>Re: how to write code for 1 parameter logistic model</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-write-code-for-1-parameter-logistic-model/m-p/646437#M193372</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;FYI, variable "bpar" in the "bpar.csv" is the item difficulty parameter.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 10 May 2020 01:14:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-write-code-for-1-parameter-logistic-model/m-p/646437#M193372</guid>
      <dc:creator>superbug</dc:creator>
      <dc:date>2020-05-10T01:14:00Z</dc:date>
    </item>
    <item>
      <title>Re: how to write code for 1 parameter logistic model</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-write-code-for-1-parameter-logistic-model/m-p/646483#M193403</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/304931"&gt;@superbug&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now I have 150 items in a test, the "bpar.csv" as in the attachment are the item difficulty for those 150 items. Now suppose I have a examinee with ability level theta=0,&amp;nbsp; I want to know the probability of this&amp;nbsp; examinee get each item correct, how should I wrote that in a SAS macro?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Part of the problem we are having is that I still don't think I have understood the problem, and you have not yet explained it clearly. So now you state "Now suppose I have a examinee with ability level theta=0" ... okay, I see that bpar is in the CSV file, but theta is not in the CSV file. If we have a formula that has theta in it, we need to know theta for each examinee; and your words imply that theta is zero for one specific examinee.&lt;/P&gt;</description>
      <pubDate>Sun, 10 May 2020 10:02:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-write-code-for-1-parameter-logistic-model/m-p/646483#M193403</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-05-10T10:02:25Z</dc:date>
    </item>
    <item>
      <title>Re: how to write code for 1 parameter logistic model</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-write-code-for-1-parameter-logistic-model/m-p/646542#M193443</link>
      <description>&lt;P&gt;Assuming your formula is what you want and theta =0, your formula simplifies to:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;prob &amp;amp;i= exp(-bpar&amp;amp;i)/(1+exp(-bpar&amp;amp;i);   /*1 parameter logistic regression model*/&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;For completeness sake, let's say you want to make theta adjustable, so we can include it in the formula and set it to 0.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;*want is the final output data set with the probabilities;
data want;

*bpar is the input data set you read in;
set bpar;

*set theta to 0 throughout the process;
theta = 0;

*calculate your probability - will operate on each line of your data;
prob = exp(theta-bpar)/(1+exp(theta - bpar));

*end data step;
run;

*print first 5 results to the results output page;
proc print data=want (obs=5);
run;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You DO NOT need a macro. A SAS data step automatically loops over each row and applies the formula to your data set. The code above will do the calculations and put it in a data set called WANT. It will display the first 5 records to the results window due to the PROC PRINT.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/304931"&gt;@superbug&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello SAS expert,&lt;/P&gt;
&lt;P&gt;I have a test contains 150 items, item difficulty parameter for each item is as attached. Suppose I now have candidate whose ability level is 0, I named it theta=0. Now on &lt;STRONG&gt;each of the item&lt;/STRONG&gt;, I need to calculate the probability of this candidate correctly answer on each of the time, how should I edit the following &lt;STRONG&gt;macro sas&lt;/STRONG&gt; code to make it work?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc import datafile="\bpar.csv"&amp;nbsp; &amp;nbsp;dbms=csv out=bpar replace; run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%macro f1;&lt;/P&gt;
&lt;P&gt;do i=1 to 150;&amp;nbsp; /*from item 1 to item 150*/&lt;/P&gt;
&lt;P&gt;prob &amp;amp;i= exp(theta-bpar&amp;amp;i)/(1+exp(theta-bpar&amp;amp;i);&amp;nbsp; &amp;nbsp;/*1 parameter logistic regression model*/&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;%mend;&lt;/P&gt;
&lt;P&gt;%f1;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 10 May 2020 18:14:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-write-code-for-1-parameter-logistic-model/m-p/646542#M193443</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-05-10T18:14:59Z</dc:date>
    </item>
    <item>
      <title>Re: how to write code for 1 parameter logistic model</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-write-code-for-1-parameter-logistic-model/m-p/646549#M193449</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks much for your code and detailed explanation!&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried the code you suggested and it worked.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My eventual goal is do some iteration using theta=[-20, 20], then stop at certain criteria. That's a very complex process for me. I thought about asking the question from simple step, then go further, but that caused confusion.When you get time, could you please go to the following link to read the &lt;STRONG&gt;lasted post&lt;/STRONG&gt; and help? Again, thanks a bunch!&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Programming/How-to-write-150-values-in-one-column-to-be-150-data-set/m-p/646496/highlight/false#M193412" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/How-to-write-150-values-in-one-column-to-be-150-data-set/m-p/646496/highlight/false#M193412&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 10 May 2020 18:43:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-write-code-for-1-parameter-logistic-model/m-p/646549#M193449</guid>
      <dc:creator>superbug</dc:creator>
      <dc:date>2020-05-10T18:43:38Z</dc:date>
    </item>
  </channel>
</rss>

