Hi SAS Community,
I've got a non-positive definite G matrix. It is said that the estimates of fixed effects are still valid if the marginal covariance matrix V is positive definite. Unfortunately, I can't find anywhere if SAS system will tell me about it or will stop (it is telling only about G and R matrices and about infinite likelihood but not about the general matrix V). I though about saving the matrix with "ods output" and check somehow if it is positive definite but this is a block diagonal matrix and I have to write that I want 760 blocks (I have 760 subjects), since SAS shows only the blocks I am specifying. Is somebody familiar with that? Do I have to really prove V matrix or can I trust the results?
Darja
Your factor analytic structure, FA0(3), is still giving you an unstructured covaraince matrix. It is just contstraining it to be at least positive semi-definite. A valid covariance matrix must be positive semi-definite or posistive definite. It is always a very good practice to use FA0(#) or CHOL when one wants an unstructured G. BY the way, add the G and GCORR options to the RANDOM statement to get a direct display of G (in addition to the FA parameters that determine G).
Can you share your output? I suspect that you may have more random effects than are needed, and if this is the case, then the NPD of the G matrix should not be a problem--it's not like problems with the Hessian.
Steve Denham
Thank you very much for your answer. As random effects I have an intercept and two slopes, I can't remove any of them because it is what I have assumed in my analysis- that every subject is allowed to have random intercept and random slope. I suppose the problem is that I have somehow not enough observations after stratifying by group (one group is bigger than second and for bigger group D matrix is PD). Which part of the output or code would be helpful?
Your PROC MIXED code, and any of the output up to and including the parameter estimates (both fixed and random), including the iteration history.
I think you have identified the source of the problem with an intercept and two slopes. I would expect to need only one, but seeing your code may make this easier to understand.
Steve Denham
As indicated by Steve, you usually only have to be concerned when you get a message about the Hessian being non-positive definite.
Here is my SAS Code:
proc mixed data=stat method=reml nobound;
class id bmi_mother sex country isced troubled;
model bmi_z_score=slope_before slope_after bmi_mother sex country isced troubled/s cl ddfm=kr;
random int slope_before slope_after/ type=un subject=id_no;
format sex sex_new. isced isc. country count. troubled tr. bmi_mother catA.;
by categ;
run;
I have a piecewise mixed model, so I am assuming two random slopes-slope before the event and slope after. I saved some output in Word for one group where G matrix was NPD and attached it here. I deleted the reference categories too, I hope it is ok, was not sure what I am allowed to post. The output with random slopes and intercepts is too big because I have 760 subjects, so in the document is G matrix, intercept and R, iteration history, as well as fixed effects estimates. Without stratifying, the G matrix is ok. I think the problem is that it is just not enough variability in the data or something bacause for this group I have less observations per subject. The results look good compared to the other models but I am still not sure about conclusions.
I'm stumped as to how the G matrix is NPD, as there are estimates for every element of the covariance matrix. I am going to suggest re-running this in PROC GLIMMIX, so that the standard errors of the covariance elements might be presented.
proc glimmix data=stat nobound;
class id bmi_mother sex country isced troubled;
model bmi_z_score=slope_before slope_after bmi_mother sex country isced troubled/s cl ddfm=kr2;
random int slope_before slope_after/ type=un subject=id_no;
format sex sex_new. isced isc. country count. troubled tr. bmi_mother catA.;
by categ;
run;
If this throws the same type error, try type=chol for the covariance structure, to use a Cholesky parameterization. This occasionally helps solve NPD problems, and if it doesn't, the values obtained should help point out the source of the near singularity.
Steve Denham
I think it has every estimate because I have specified nobound option, otherwise some variances are 0. The matrix in general is NPD apparently. I have to use proc mixed because it is the procedure of my master thesis but I think I have found that type=chol is the same as type=FA0(q) in proc mixed, so I have now:
proc mixed data=stat method=reml nobound COVTEST;
class id bmi_mother sex country isced troubled;
model bmi_z_score=slope_before slope_after bmi_mother sex country isced troubled/s cl ddfm=kr;
random int slope_before slope_after/ type=FA0(3) subject=id_no;
format sex sex_new. isced isc. country count. troubled tr. bmi_mother catA.;
by categ;
run;
Both groups have no warning about NPD G matrix anymore and the estimates are changed just a little bit. Does it mean that I still have estimated the unstructured matrix just with this factor-analysis (as far as I understood from the Internet) and everything is good? I am not familiar with this method unfortunately.. It took more iterations too. Could you please look on my results? I made SE as well, it is possible with COVTEST.
Your factor analytic structure, FA0(3), is still giving you an unstructured covaraince matrix. It is just contstraining it to be at least positive semi-definite. A valid covariance matrix must be positive semi-definite or posistive definite. It is always a very good practice to use FA0(#) or CHOL when one wants an unstructured G. BY the way, add the G and GCORR options to the RANDOM statement to get a direct display of G (in addition to the FA parameters that determine G).
Thank you so much for the explanation and your help!
I did but thank you so much too, you helped me with the solution!
This looks really good--I would go with this analysis, remembering that the variance estimates are the factor analytic estimates, and not the values in the G matrix. Follow @lvm's advice and add G and GCORR to the RANDOM statement. And pay no attention to the Z test probability values you get from the COVTEST option--you are right in using it to get standard errors.
Steve Denham
The very last question for understanding. So, basically, SAS do not say anything about V matrix in general and I have to search for different solutions in these situations? It just seems strange that SAS check the positive definiteness of G and R matrices but not the V matrix.
A quick look back at theory says V = ZGZ' + R. Thus, we know everything we need to know about V once we know G and R, as Z is a design matrix. If either G or R has problems, then we know V will have the same problem, unless there is the very rare case where the matixes exactly offset. It is why you should always get a look at both of these, using the G or R options.
Steve Denham
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.
Find more tutorials on the SAS Users YouTube channel.