Variance Covariance Matrix from Proc GLM

1.4k views Asked by At

I'm using Proc GLM to fit a basic fixed effects model and I want to get the variance/covariance matrix. I know this is very east to do if you fit a model with proc reg, but the model I'm fitting has a separate slope for each member of a class (over 50 members of the class) and thus I don't want to code dummy variables for all of them.

Is there any way to get the variance covariance matrix from a fit using proc glm.

Here is an example with made up data and my code. I would like to get a variance-covariance matrix of the estimates.

data example;
   input price cat time x2 x3;
   cards; 
   5000 1 1 5.4  50
   6000 1 2 6    45
   3000 1 3 7     60
   4000 2 1 5    50
   4500 2 2 5.4  75
   4786 3 1 6    33
   6500 3 2 5.8  36
   1010 3 3 4    41
;;;;
run;


proc glm data=example PLOTS(UNPACK)=DIAGNOSTIC;
    class cat;
   model price= cat time x2 x3/ noint solution;
run;

I get a parameter estimate for each category (these are essentially nuisance parameters) and then I'm interested in the Covariance matrix of the estimates time, x2 and x3.

Thanks

1

There are 1 answers

2
pinegulf On

You need to add output to a file: (I disabled on screen print in purpose, but feel free to enable it as you need.)

proc glm data=example noprint;
    class cat;
    model price= cat time x2 x3  / noint solution ;
   **output out= from_glm COVRATIO = Cov ;**
run; quit;

Resulting to:

price cat time x2   x3 COV 
5000  1   1    5.4  50 597.2565 
6000  1   2    6    45 8.312725 
3000  1   3    7    60 0.0493 
....

Edit: Updated the output statement.

For more on on keywords see https://support.sas.com/documentation/cdl/en/statug/63033/HTML/default/viewer.htm#statug_glm_sect020.htm

Hopefully this is what you're after.