[gradsusr] Contingency Table

Eric Altshuler ela at cola.iges.org
Wed Apr 30 14:38:41 EDT 2014


Dear Amulya, 


The grads scripting language does not support directly accessing the values of data variables (either defined or from a dataset). In your 'if' statements, the variables 'a' and 'b' refer to script variables, not data variables. You need to first obtain the values of your defined variables a and b, then assign these values to script variables. Just before each 'if' statement in your script, insert the following lines: 


'display a' 
a=subwrd(result,4) 
'display b' 
b=subwrd(result,4) 


It may be a bit confusing, but the script variables 'a' and 'b' (i.e. those assigned values using subwrd function) are NOT the same as the data variables a and b (i.e. those in the 'display' commands). 


Best regards, 


Eric L. Altshuler 
Research Scientist 
Center for Ocean-Land-Atmosphere Studies 
253 Research Hall, Mail Stop 6C5 
George Mason University 
4400 University Drive 
Fairfax, VA 22030 USA 

E-mail: ela at cola.iges.org 
Phone: (703) 993-5725 
Fax: (703) 993-5770 

----- Original Message -----
From: "Amulya Chevuturi" <amulya.chevuturi at gmail.com> 
To: "GrADS Users Forum" <gradsusr at gradsusr.org> 
Sent: Wednesday, April 30, 2014 12:18:33 AM 
Subject: [gradsusr] Contingency Table 


Dear Grads Users 


I am trying to build contingency table for model verification using grads. Currently my model and observation are both at exactly same resolution. So I have written the following script. But it is not giving me the count of Yes/Yes, No/No etc correctly. How am I supposed to build contingency table using grads if someone can please help. 


Following is the script. 



'reinit' 


'open model.ctl' 
'set t 3' 
'set y 57 208' 
'set x 72 228' 
'define a = rain' 
'close 1' 


'open observation.ctl' 
'set t 3' 
'set y 57 208' 
'set x 72 228' 
'define b = prec' 


n1=0 
n2=0 
n3=0 
n4=0 
j=72 

while (j<=228) 
'set y 'j 
i=57 
while (i<=208) 
'set x 'i 
if(a>0&b>0) 
n1=n1+1 
else 
if(a<=0&b<=0) 
n2=n2+1 
else 
if(a<=0&b>0) 
n3=n3+1 
else 
if(a>0&b<=0) 
n4=n4+1 
endif 
endif 
endif 
endif 
i=i+1 
endwhile 
j=j+1 
endwhile 
say n1 
say n2 
say n3 
say n4 
'close 1' 


Or is anyother method available for making contingency tables for forecast verification with grads? 


Please let me know. 


Regards 
Amulya Chevuturi 




_______________________________________________ 
gradsusr mailing list 
gradsusr at gradsusr.org 
http://gradsusr.org/mailman/listinfo/gradsusr 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20140430/4d67bed3/attachment.html 


More information about the gradsusr mailing list