<?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: Wald-Wolfowitz (or Runs) test for randomness in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/Wald-Wolfowitz-or-Runs-test-for-randomness/m-p/648236#M31114</link>
    <description>&lt;P&gt;The runs test is available in the autoreg procedure which does support by-processing. It should go like;&lt;/P&gt;
&lt;P&gt;proc autoreg data=myData;&lt;/P&gt;
&lt;P&gt;by myByVariable;&lt;/P&gt;
&lt;P&gt;model myVariable= / runs;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note proc autoreg requires licence to SAS/ETS.&lt;/P&gt;</description>
    <pubDate>Sat, 16 May 2020 04:04:35 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2020-05-16T04:04:35Z</dc:date>
    <item>
      <title>Wald-Wolfowitz (or Runs) test for randomness</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Wald-Wolfowitz-or-Runs-test-for-randomness/m-p/23563#M806</link>
      <description>The following SAS link provides the code to implement Run's test. Does anyone know how to implement this code with a by group option in the data step. In otherwords, is it possible to compute the test statistic simultaneously by an id variable.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Wald-Wolfowitz (or Runs) test for randomness&lt;BR /&gt;
&lt;A href="http://support.sas.com/kb/33/092.html" target="_blank"&gt;http://support.sas.com/kb/33/092.html&lt;/A&gt;</description>
      <pubDate>Mon, 07 Mar 2011 19:18:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Wald-Wolfowitz-or-Runs-test-for-randomness/m-p/23563#M806</guid>
      <dc:creator>DB_ECON</dc:creator>
      <dc:date>2011-03-07T19:18:48Z</dc:date>
    </item>
    <item>
      <title>Re: Wald-Wolfowitz (or Runs) test for randomness</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Wald-Wolfowitz-or-Runs-test-for-randomness/m-p/23564#M807</link>
      <description>Hello DB_ECON,&lt;BR /&gt;
&lt;BR /&gt;
This is what I've got formally applying BY statement:&lt;BR /&gt;
[pre]&lt;BR /&gt;
 data one;&lt;BR /&gt;
   do id=1 to 5;&lt;BR /&gt;
     drop i;&lt;BR /&gt;
     do i=1 to 75;&lt;BR /&gt;
       d=rannor(123);&lt;BR /&gt;
       n=75;&lt;BR /&gt;
       output;&lt;BR /&gt;
     end;&lt;BR /&gt;
   end;&lt;BR /&gt;
 run;&lt;BR /&gt;
proc standard data=one out=two mean=0;&lt;BR /&gt;
  var d;&lt;BR /&gt;
  by ID;&lt;BR /&gt;
run;&lt;BR /&gt;
data runcount;&lt;BR /&gt;
  keep ID runs numpos numneg n;&lt;BR /&gt;
  set two end=last;&lt;BR /&gt;
  retain runs 0 numpos 0;&lt;BR /&gt;
  if FIRST.ID then do; runs=0; numpos=0; ld=.; end;&lt;BR /&gt;
  else do; prevpos=( ld GE 0 );  currpos=( D GE 0 ); ld=lag(D); end;&lt;BR /&gt;
  if currpos and prevpos then numpos+1;&lt;BR /&gt;
  else if currpos and ^prevpos then do;&lt;BR /&gt;
    runs+1;&lt;BR /&gt;
    numpos+1;&lt;BR /&gt;
  end;&lt;BR /&gt;
  else if ^currpos and prevpos then runs+1;&lt;BR /&gt;
  if last.ID then do;&lt;BR /&gt;
    numneg=n-numpos;&lt;BR /&gt;
    output;&lt;BR /&gt;
  end;&lt;BR /&gt;
  by ID;&lt;BR /&gt;
run;&lt;BR /&gt;
data waldwolf;&lt;BR /&gt;
  label z='Wald-Wolfowitz Z' pvalue='Pr &amp;gt; |Z|';&lt;BR /&gt;
  set runcount;&lt;BR /&gt;
    mu = ( (2*numpos*numneg) / (numpos+numneg) ) + 1;&lt;BR /&gt;
    sigmasq = ( (2*numpos*numneg) * (2*numpos*numneg-numneg-numpos) ) /&lt;BR /&gt;
              ( ( (numpos+numneg)**2 ) * (numpos+numneg-1) );&lt;BR /&gt;
    sigma=sqrt(sigmasq);&lt;BR /&gt;
    drop sigmasq;&lt;BR /&gt;
    if N GE 50 then Z = (Runs - mu) / sigma;&lt;BR /&gt;
    else if Runs-mu LT 0 then Z = (Runs-mu+0.5)/sigma;&lt;BR /&gt;
    else Z = (Runs-mu-0.5)/sigma;&lt;BR /&gt;
    pvalue=2*(1-probnorm(abs(Z)));&lt;BR /&gt;
  by ID;&lt;BR /&gt;
run;&lt;BR /&gt;
title  'Wald-Wolfowitz Test for Randomness';&lt;BR /&gt;
title2 'H0: The data are random';&lt;BR /&gt;
proc print data=waldwolf label noobs;&lt;BR /&gt;
  id ID;&lt;BR /&gt;
  var z pvalue;&lt;BR /&gt;
  format pvalue pvalue.;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
Sincerely,&lt;BR /&gt;
SPR</description>
      <pubDate>Mon, 07 Mar 2011 21:41:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Wald-Wolfowitz-or-Runs-test-for-randomness/m-p/23564#M807</guid>
      <dc:creator>SPR</dc:creator>
      <dc:date>2011-03-07T21:41:25Z</dc:date>
    </item>
    <item>
      <title>Re: Wald-Wolfowitz (or Runs) test for randomness</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Wald-Wolfowitz-or-Runs-test-for-randomness/m-p/648192#M31113</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I am trying to run your code, but the value for numneg and n is missing. Can you advise me on this please?</description>
      <pubDate>Fri, 15 May 2020 22:24:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Wald-Wolfowitz-or-Runs-test-for-randomness/m-p/648192#M31113</guid>
      <dc:creator>rosiecao2509</dc:creator>
      <dc:date>2020-05-15T22:24:52Z</dc:date>
    </item>
    <item>
      <title>Re: Wald-Wolfowitz (or Runs) test for randomness</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Wald-Wolfowitz-or-Runs-test-for-randomness/m-p/648236#M31114</link>
      <description>&lt;P&gt;The runs test is available in the autoreg procedure which does support by-processing. It should go like;&lt;/P&gt;
&lt;P&gt;proc autoreg data=myData;&lt;/P&gt;
&lt;P&gt;by myByVariable;&lt;/P&gt;
&lt;P&gt;model myVariable= / runs;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note proc autoreg requires licence to SAS/ETS.&lt;/P&gt;</description>
      <pubDate>Sat, 16 May 2020 04:04:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Wald-Wolfowitz-or-Runs-test-for-randomness/m-p/648236#M31114</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2020-05-16T04:04:35Z</dc:date>
    </item>
  </channel>
</rss>

