Dear all, I have been trying to singly and doubly integrate multivariable functions using the quad routine in SAS IML but getting errors. the integration domain is finite. The result should be a function of rho rather than a constant. Here is the log file for double integration. i am concerned about the error 'the matrix has not been set to a value'. i dont know how to assign the optional command for mean and std dev of the vector as suggested. both x and y are bivariate N(0,1) variates, r is the weighted polychoric correlation and is unknown. i can increase the integration domain length for convergence if needed. please help to debugg the errors. 0 proc iml;/*double integration for weighted polychoric correlation*/ NOTE: IML Ready 101 start inner(y) global(a); 102 return(a#exp(-.5*y#y+rho#x#y/(1-rho**2))) ; 103 finish; NOTE: Module INNER defined. 104 start outer(x) global(a); 105 a =exp(-.5*x#x/(1-rho**2)) ; 106 yinterval = 1.5 || 3; 107 /** evaluate inner integral for the function in x **/ 108 w=exp(-.5*x#x/(1-rho**2)); 109 call quad(w, "inner", yinterval); 110 return (w); 111 finish; NOTE: Module OUTER defined. 112 print w; ERROR: Matrix w has not been set to a value. statement : PRINT at line 112 column 1 113 xinterval= {1 2.6}; 114 call quad(v, "outer", xinterval); ERROR: (execution) Matrix has not been set to a value. operation : ** at line 105 column 1 operands : rho, *LIT1006 rho 0 row 0 col (type ?, size 0) *LIT1006 1 row 1 col (numeric) 2 statement : ASSIGN at line 105 column 1 traceback : module OUTER at line 105 column 1 Convergence could not be attained over the subinterval (1 , 2.6 ) The function might have one of the following: 1) A slowly convergent or a divergent integral. 2) Strong oscillations. 3) A small scale in the integrand: in this case you can change the independent variable in the integrand, or, provide the optional vector describing roughly the mean and the standard deviation of the integrand 4) Points of discontinuities in the interior in this case, you can provide a vector containing the points of discontinuity and try again. ERROR: Execution error as noted previously. (rc=100) operation : QUAD at line 114 column 1 operands : *LIT1014, xinterval *LIT1014 1 row 1 col (character, size 5) outer xinterval 1 row 2 cols (numeric) 1 2.6 statement : CALL at line 114 column 1 114! /** outer integral **/ 115 print v; ERROR: Matrix v has not been set to a value. statement : PRINT at line 115 column 1 here's the log for the single integration. the answer should be a function of rho and z. y and z are bivariate standard normal variates. 6 proc iml; NOTE: IML Ready 117 start inner(y) global(a); 118 return(exp(-0.5*(y-rho#z)##2/(1-rho##2))); 119 finish; NOTE: Module INNER defined. 120 121 /** evaluate integral for the parameter value, a=3 **/ 122 a = 3; 123 yinterval = 1.5 || a; 124 call quad(w, "inner", yinterval); ERROR: (execution) Matrix has not been set to a value. operation : # at line 118 column 26 operands : rho, z rho 0 row 0 col (type ?, size 0) z 0 row 0 col (type ?, size 0) statement : RETURN at line 118 column 4 traceback : module INNER at line 118 column 4 Convergence could not be attained over the subinterval (1.5 , 3 ) The function might have one of the following: 1) A slowly convergent or a divergent integral. 2) Strong oscillations. 3) A small scale in the integrand: in this case you can change the independent variable in the integrand, or, provide the optional vector describing roughly the mean and the standard deviation of the integrand 4) Points of discontinuities in the interior in this case, you can provide a vector containing the points of discontinuity and try again. ERROR: Execution error as noted previously. (rc=100) operation : QUAD at line 124 column 1 operands : *LIT1007, yinterval *LIT1007 1 row 1 col (character, size 5) inner yinterval 1 row 2 cols (numeric) 1.5 3 statement : CALL at line 124 column 1 125 print w; ERROR: Matrix w has not been set to a value. statement : PRINT at line 125 column 1
... View more