BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
rameezroshan
Calcite | Level 5
Please some one suggest me how to deal with large determinants in IML. How to solve this issue. This is a part of mixed model anaysis for genetic data. The random effect being individual animals. amatrix1 is numerator relationship matrix based on pedigree. bw5 is bodyweight. batch, pondno, gender are fixed effects. 
1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
72
73 proc iml;
NOTE: IML Ready
74 USE MAGUR;
75 READ ALL VAR {BATCH} INTO BATCH;
76 READ ALL VAR {PONDNO} INTO POND;
77 READ ALL VAR {GENDER} INTO SEX;
78 READ ALL VAR {BW5} INTO y1;
79 x1=DESIGN(BATCH);
79 ! x2=DESIGN(POND);
79 ! x3=DESIGN(SEX);
80 x4=x1||x2||x3;
81 x5=J(154,15,0);
82 x6=X5//X4;
83 x7=J (NROW (x6),1,1)||x6;
84 START matrank (x7);
84 ! /** matrank computes matrix rank **/
85 matrank=ROUND (TRACE (x7*GINV(x7)));
86 RETURN (matrank);
87 FINISH;
NOTE: Module MATRANK defined.
88 a=matrank (x7);
89 y2=J(154,1,0);
90 y=y2//y1;
91 Z=I(1567);
92 USE AMTRIX1;
93 READ ALL VAR _all_ INTO am;
94 *IA=INV(am);
95 n = NROW (x7);
96 ie =I (1567);
97 pi = CONSTANT ("PI");
98 START reml (theta) GLOBAL (z,y,x6,am,ie,pi,n,a);
99 /** Defining the function -2 (Log Likelihood) **/
100 sigma_a = theta[1, 1]*am;
101 sigma_e = theta[1, 2]*ie;
102 v = z*sigma_a*z` + sigma_e;
103 /** Covariance matrix **/
104 vinv=inv(v);
105 r=y-x6*GINV(x6`*vinv*x6)*x6`*vinv*y;
106 prod=LOG(DET(v))+LOG(DET(x6`*vinv*x6))+
107 r`*vinv*r+(n-a)*LOG(2*pi);
108 RETURN (prod);
109 FINISH reml;
NOTE: Module REML defined.
110 /** MIVQUE (0) **/
111 p=ie-x7*GINV(x7);
111 ! /** projection onto x **/;
112 pz1=p*z*z`;
113 pz2=p*ie;
114 mat_a=(TRACE(pz1*pz1)||trace(pz1*pz2))//(TRACE(pz2*pz1)||trace(pz2*pz2));
115 mat_b=(y`*pz1*p`*y)//(y`*pz2*p*y);
116 mivque0=(GINV(mat_a)*mat_b)`;
117 print mivque0;
118 *print reml;
119 optn = {0 1};
120 con={ 0 0 };
121 CALL NLPNRR (rc, covs,"reml", mivque0,optn,con);
ERROR: Overflow error in DET.
ERROR: Execution error as noted previously. (rc=100)
 
operation : DET at line 106 column 13
operands : v
v 1567 rows 1567 cols (numeric)
 
statement : ASSIGN at line 106 column 1
traceback : module REML at line 106 column 1
 
ERROR: Execution error as noted previously. (rc=100)
 
operation : NLPNRR at line 121 column 1
operands : *LIT1023, mivque0, optn, con
 
*LIT1023 1 row 1 col (character, size 4)
 
reml
 
mivque0 1 row 2 cols (numeric)
 
468.80571 468.80571
 
optn 1 row 2 cols (numeric)
 
0 1
 
con 1 row 2 cols (numeric)
 
0 0
 
statement : CALL at line 121 column 1
122 PRINT covs;
ERROR: Matrix covs has not been set to a value.
 
statement : PRINT at line 122 column 1
123
124
125
126
127 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
140
1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

Instead of computing the DET and then taking the LOG, compute the log-determinant directly by using the LOGABSDET function.

For an example, see "Compute the log-determinant of an arbitrary matrix."

View solution in original post

2 REPLIES 2
Rick_SAS
SAS Super FREQ

Instead of computing the DET and then taking the LOG, compute the log-determinant directly by using the LOGABSDET function.

For an example, see "Compute the log-determinant of an arbitrary matrix."

rameezroshan
Calcite | Level 5

Hi Rick,

Thank you so much for the prompt response. The issue is solved and it's working. 

 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

Multiple Linear Regression in SAS

Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.

Find more tutorials on the SAS Users YouTube channel.

From The DO Loop
Want more? Visit our blog for more articles like these.
Discussion stats
  • 2 replies
  • 1248 views
  • 1 like
  • 2 in conversation