MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

runs test for evaluation of model fit

  • To: mathgroup at smc.vnet.net
  • Subject: [mg57173] runs test for evaluation of model fit
  • From: Csukas Attila <attila at biking.taiiku.tsukuba.ac.jp>
  • Date: Fri, 20 May 2005 04:43:06 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Dear Everybody,

I am facing to a new problem and if it is possible would like to ask  
some help from experts as you are.
I have observed values (second in the brackets) for three ids (first in  
the brackets) and also have predicted values (third in the brackets)  
estimated by a model. I would like to use runs test to prove that the  
model fitted well, that is there is no significant difference between  
observed and predicted values for each id.

Does anybody know how can it be done? Any help is appreciated! Thanks  
in advance!

Out[10]=
{{id,obs,pred},{2,116.9,116.486},{2,122.1,122.073},{2,126.1,127.074},{2,
      
131.1,131.598},{2,137.1,135.899},{2,141.1,140.88},{2,148.3,149.053},{2,
     161.2,160.338},{2,165.9,166.697},{2,
      
167.8,168.316},{2,168.,168.617},{2,170.1,168.67},{4,120.8,121.477},{4,
      
128.2,127.612},{4,134.5,133.438},{4,138.9,139.369},{4,145.2,146.045},{4,
     153.7,154.016},{4,163.7,162.616},{4,
      
170.1,169.62},{4,172.1,173.697},{4,174.4,175.536},{4,177.3,176.255},{4,
      
177.3,176.518},{7,111.8,110.578},{7,115.5,116.887},{7,122.1,122.456},{
      
7,126.8,127.377},{7,132.4,131.743},{7,136.4,135.698},{7,139.1,139.616},{
      
7,145.3,144.669},{7,152.1,152.685},{7,161.,160.428},{7,163.2,163.488},{
     7,164.1,164.176}}

One of the mathgroup contributors had comments on Wald-Wolfowitz test  
but I have difficulties with the application for the above data. Hints  
I have found on W-W are the next:

In[1]:=
x = Table[Random[Integer],{n = 25}]

Out[1]=
{1,1,0,0,1,1,1,0,0,1,1,1,1,0,0,0,1,1,0,1,1,0,1,0,0}

In[2]:=
{{n1 = Tr@x, n0 = n - n1},  r = Length@Split@x}

Out[2]=
{{14,11},12}

In[3]:=
N@{m = 1 + 2*n0*n1/n, sd = Sqrt[(m-1)(m-2)/(n-1)]}

Out[3]=
{13.32,2.41059}

In[6]:=
f[r_,n0_,n1_] := If[EvenQ@r,
With[{k = r/2 - 1},2*Binomial[n0-1,k  ]*Binomial[n1-1,k  ]],
With[{k = (r-1)/2},  Binomial[n0-1,k  ]*Binomial[n1-1,k-1] +
(**)                 Binomial[n0-1,k-1]*Binomial[n1-1,k  ]]];
rf=Table[{r,f[r,n0,n1]},{r,2,2Min[n0,n1]+Boole[n0??n1]}]

Out[7]=
{{2,2},{3,23},{4,260},{5,1365},{6,
      
7020},{7,22230},{8,68640},{9,145860},{10,300300},{11,450450},{12,648648} 
,{?_
13,702702},{
    
14,720720},{15,566280},{16,411840},{17,231660},{18,115830},{19,45045},{2 
0,?_
14300},{21,3575},{22,572},{23,78}}

In[8]:=
{#, # === Tr@rf[[All,2]]}&@Binomial[n,n1]

Out[8]=
{4457400,True}


  • Prev by Date: Re: Reducing binary representation
  • Next by Date: Re: Re: Crossing of 3D functions
  • Previous by thread: Re: Nestwhile
  • Next by thread: Re: runs test for evaluation of model fit