我使用Proc GLM来拟合一个基本的固定效应模型,我想要得到方差/协方差矩阵。我知道如果你用proc reg来拟合一个模型,这是非常困难的,但是我正在拟合的模型对一个类的每个成员(超过50个类成员)都有一个单独的斜率,因此我不想为所有的成员编写虚拟变量。
有没有办法使用proc glm从拟合中获得方差协方差矩阵?
下面是一个包含虚构数据和我的代码的示例。我想得到估计的方差-协方差矩阵。
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;我得到了每个类别的参数估计(这些基本上是讨厌的参数),然后我对估计时间、x2和x3的协方差矩阵感兴趣。
谢谢
发布于 2017-09-04 16:16:05
您需要将输出添加到一个文件中:(我故意禁用了屏幕打印,但您可以根据需要随时启用它。)
proc glm data=example noprint;
class cat;
model price= cat time x2 x3 / noint solution ;
**output out= from_glm COVRATIO = Cov ;**
run; quit;结果是:
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
....编辑:更新了输出语句。
有关关键字的更多信息,请参阅https://support.sas.com/documentation/cdl/en/statug/63033/HTML/default/viewer.htm#statug_glm_sect020.htm
希望这就是你想要的。
https://stackoverflow.com/questions/46029905
复制相似问题