GMacro ChiArea # For Release 14 - low density version of NormArea3 # Based on NormArea written by Jon Cryer: Jon-Cryer@uiowa.edu #Note Graphic display of chi square curve areas #Note Finds and displays areas to the left or right of a given value #Note or between two values. (This macro uses C100-C116 and K100-K120) #Note #Note Enter the degrees of freedom. #Set c100; #file 'terminal'; #NObs 1. #let C100(2) = 0 #In this version, input data is in C6 - mean, std. dev., lower limit, upper limit, # c6(5) is 0 if Area is between C6(3) and C6(4) # c6(5) is 1 if Area is to the left of C6(4) # c6(5) is 2 if Area is to the right of C6(3) Let C100(1)= c6(1) Let C100(2)= c6(2) Let K100 = C100(1) Let K101 = C100(2) Let K115 = C6(5) #Note #Note Do you want the area to the left of a value? (Y or N) #YesNo K115 If K115 = 1 Call Left EndIf #Note Do you want the area to the right of a value? (Y or N) #YesNo K115 # If K115 = 1 # Let K115 = 2 # EndIf If K115 = 2 Call Right EndIf If K115 = 0 Call Between EndIf name k103 'mode' let k103 = k100 - 2 name k120 'median' let k120 = k100 - 0.666667 print k103, k120 Erase C100-C116 K100-K120 EndMacro GMacro # Want area to the left Left Note #Note Enter the value for which you want the area to the left. #Set c100; #file 'terminal'; #NObs 1. Let c100(1) = c6(4) Note Note ...working... Let K102 = C100(1) InvCDF .0001 k117; ChiSquare K100. #Lower Limit InvCDF .9999 k118; ChiSquare K100. #Upper Limit Let K119 = 2*K100 Let K119 = SQRT(K119) #Standard Deviation Let K105 = .01*K119 Let K101 = K119 Set C101 K117:K118/K105 End PDF C101 C102; ChiSquare K100. Set C103 K117:K102/K105 End #Let K114 = N(C103) #Let C103(K114) = K102 PDF C103 C104; ChiSquare K100. CDF K102 C106; # Get area to report ChiSquare K100. Text C106 C106; # Convert to text for labeling decimal 4. Let K109 = C106 Let C107 = K102 Text C107 C107 Let K107 = C107 Let K110 = "The Area to the Left of " KKCAT K110 K107 K112 Let K111 = " is " KKCAT K112 K111 K112 KKCAT K112 K109 K112 # Get df and stdev labeling Let C108 = K100 Text C108 C108 Let K103 = C108 # df as text Let C109 = K101 Text C109 C109 Let K104 = C109 # Stdev as text Let K105 = "ChiSquare Curve with " Let K106 = " Degrees of Freedom and Standard Deviation " KKCAT K105 K103 K111 KKCAT K111 K106 K111 KKCAT K111 K104 K111 Let K113 = -0.01/K101 # Set marker placement a little below zero Plot C102*C101 C104*C103; NoLegend; WTitle "Chi Squared Curve Area"; Title K111; Title K112; Connect; Size 2; Color 1; Area; Type 0 1; Color 1 4; AXLabel 1 "Data Axis"; AXLabel 2 "Density"; Marker K102 K113; Type 19; Color 1; Size 2.0; Scale 2; Min 0; Overlay. Return EndMacro GMacro # Want area to the right Right #Note #Note Enter the value for which you want the area to the right. #Set c100; #file 'terminal'; #NObs 1. Let c100(1) = c6(3) Note Note ...working... Let K102 = C100(1) InvCDF .0001 k117; ChiSquare K100. #Lower Limit InvCDF .9999 k118; ChiSquare K100. #Upper Limit Let K119 = 2*K100 Let K119 = SQRT(K119) #Standard Deviation Let K105 = .01*K119 Let K101 = K119 Set C101 K117:K118/K105 End PDF C101 C102; ChiSquare K100. Set C103 K102:K118/K105 End #Let K114 = N(C103) #Let C103(K114) = K104 PDF C103 C104; ChiSquare K100. CDF K102 C106; # Get area to report ChiSquare K100. Let C106 = 1 - C106 Text C106 C106; # Convert to text for labeling decimal 4. Let K109 = C106 Let C107 = K102 Text C107 C107 Let K107 = C107 Let K110 = "The Area to the Right of " KKCAT K110 K107 K112 Let K111 = " is " KKCAT K112 K111 K112 KKCAT K112 K109 K112 # Get df and stdev labeling Let C108 = K100 Text C108 C108 Let K103 = C108 # df as text Let C109 = K101 Text C109 C109 Let K104 = C109 # Stdev as text Let K105 = "ChiSquare Curve with " Let K106 = " Degrees of Freedom and Standard Deviation " KKCAT K105 K103 K111 KKCAT K111 K106 K111 KKCAT K111 K104 K111 Let K113 = -0.01/K101 # Set marker placement a little below zero Plot C102*C101 C104*C103; NoLegend; WTitle "ChiSquare Curve Area"; Title K111; Title K112; Connect; Size 2; Color 1; Area; Type 0 1; Color 1 4; AXLabel 1 "Data Axis"; AXLabel 2 "Density"; Marker K102 K113; Type 19; Color 1; Size 2.0; Scale 2; Min 0; Overlay. Return EndMacro GMacro # Want area between two values Between #Note #Note Enter the two values for which you want the area between. #Set c100; #file 'terminal'; #NObs 2. let c100(1) = c6(3) let c100(2) = c6(4) Note Note ...working... Let K102 = C100(1) Let K115 = C100(2) InvCDF .0001 k117; ChiSquare K100. #Lower Limit InvCDF .9999 k118; ChiSquare K100. #Upper Limit Let K119 = 2*K100 Let K119 = SQRT(K119) #Standard Deviation Let K105 = .01*K119 Let K101 = K119 #Let K103 = K100-4*K101 #let K104 = K100+4*K101 #Let K105 = .01*K101 Set C101 K117:K118/K105 End PDF C101 C102; # Get values for full chi-squared curve ChiSquare K100. Set C103 K102:K115/K105 End #Let K114 = N(C103) #Let C103(K114) = K115 PDF C103 C104; ChiSquare K100. CDF K102 C106; # Get area to report ChiSquare K100. CDF K115 C110; Chisquare K100. Let C106 = C110-C106 Text C106 C106; # Convert area to text for labeling decimal 4. Let K109 = C106 Let C107 = K102 # Convert lower value to text Text C107 C107 Let K107 = C107 Let C107 = K115 Text C107 C107 # Convert upper value to text Let K116 = C107 Let K110 = "The Area Between " Let K111 = " and " Let K113 = " is " KKCAT K110 K107 K112 KKCAT K112 K111 K112 KKCAT K112 K116 K112 KKCAT K112 K113 K112 KKCAT K112 K109 K112 # Get df and stdev for labeling Let C108 = K100 Text C108 C108 Let K103 = C108 # df as text Let C109 = K119 Text C109 C109 Let K104 = C109 # Stdev as text Let K105 = "ChiSquared Curve with " Let K106 = " Degrees of Freedom and Standard Deviation " KKCAT K105 K103 K111 KKCAT K111 K106 K111 KKCAT K111 K104 K111 Let K113 = -0.01/K101 # Set marker placement a little below zero Let K114 = -0.01/K101 Plot C102*C101 C104*C103; NoLegend; WTitle "Chi Squared Curve Area"; Title K111; Title K112; Connect; Color 1; Size 2; Area; Type 0 1; Color 1 4; AXLabel 1 "Data Axis"; AXLabel 2 "Density"; Marker K102 K113; Type 19; Color 1; Size 2.0; Marker K115 K114; Type 19; Color 1; Size 2.0; Scale 2; Min 0; Overlay. Return EndMacro