楼主: Tigflanker
3937 6

多元正态分布的纵向数据模拟 [推广有奖]

  • 8关注
  • 18粉丝

副教授

49%

还不是VIP/贵宾

-

威望
0
论坛币
2321 个
通用积分
9.9128
学术水平
179 点
热心指数
194 点
信用等级
167 点
经验
27443 点
帖子
622
精华
0
在线时间
851 小时
注册时间
2011-3-27
最后登录
2023-5-14

楼主
Tigflanker 发表于 2013-2-23 19:42:17 |AI写论文
500论坛币
我又来求助了,我这问题太多了,谢谢大家的帮忙。

问题描述:我想模拟一个纵向数据,需要服从多元正态分布,我想用iml的vnormal,但是我现在不会设置协方差矩阵。

我想模拟的两组(拿其中之一说):均数方面,v1时是140,v2时是138,。。。,v7时是128(递减2)

就拿同一个观测来说,v1与v2,v2与v3之间的相关性可以是相等的,然后所有变量v1-v7的标准差都设为2。

请问下应该怎么算协方差矩阵呢?

我自己这样写的好像忽略了协方差的意义:

proc iml;
do i=1 to 2000;
mu={140,138,136,134,132,130,128};
sigma=I(7);
call vnormal(et, mu, sigma, i);
end;
create abc from et;
append from et;
quit;

请求大家的帮助。

最佳答案

bobguy 查看完整内容

I have a post using Cholesky decomposition algorithm https://bbs.pinggu.org/thread-1129334-1-1.html The algorithm can be write into a function call with FCMP and directly use in a data step. The tough part for this problem is to find a valid covariance/correlation matrix. A valid covariance/correlation matrix should be positive semi-definite. For example 3x3 correlation (covariance ...
关键词:多元正态分布 纵向数据 正态分布 数据模拟 normal 正态分布
Bye SAS.
若有缘,能重聚。

沙发
bobguy 发表于 2013-2-23 19:42:18
I have a post using Cholesky decomposition algorithm

https://bbs.pinggu.org/thread-1129334-1-1.html

The algorithm can be write into a function call with FCMP and directly use in a data step.

The tough part for this problem is to find a valid covariance/correlation matrix.

A valid covariance/correlation matrix should be positive semi-definite.

For example 3x3 correlation (covariance ~ correlation scale by variance components), it has 3 rhos, but 3 rhos need to satisfy certain conditions to be positive semi-definite. Higher dimensions will have more conditions. In other words rhos cannot arbitrary defined.

If you have a real problem, at lease you can define a sample covariance/correlation matrix and start from there.
已有 1 人评分学术水平 热心指数 信用等级 收起 理由
Tigflanker + 1 + 1 + 1 感谢,我会去尝试用您的方法做些调整。

总评分: 学术水平 + 1  热心指数 + 1  信用等级 + 1   查看全部评分

藤椅
webgu 发表于 2013-2-23 21:27:21
等等熟悉IML 的高手。
已有 1 人评分学术水平 热心指数 信用等级 收起 理由
Tigflanker + 1 + 1 + 1 感谢版主照顾。

总评分: 学术水平 + 1  热心指数 + 1  信用等级 + 1   查看全部评分

SAS资源
1. SAS 微信:StatsThinking
2. SAS QQ群:348941365

板凳
ziyenano 发表于 2013-2-25 10:21:07
你需要知道v1~v7之间相互的协方差,以及v1~v7各自的方差,这也是协方差阵包含的信息~
我在这篇帖子里,用的是randnormal函数生成多元正态,
对比cholesky分解协方差阵,从多元正态的定义生成多元正态,
https://bbs.pinggu.org/thread-2157211-1-1.html
已有 1 人评分学术水平 热心指数 信用等级 收起 理由
Tigflanker + 1 + 1 + 1 观点有启发

总评分: 学术水平 + 1  热心指数 + 1  信用等级 + 1   查看全部评分

报纸
Tigflanker 发表于 2013-2-25 15:50:10
ziyenano 发表于 2013-2-25 10:21
你需要知道v1~v7之间相互的协方差,以及v1~v7各自的方差,这也是协方差阵包含的信息~
我在这篇帖子里,用的 ...
可能比较草率,我用一篇文献中的协方差矩阵和设置进行模拟,然后解释结果。

《Multiple Imputation Approaches for the Analysis of Dichotomized Responses in Longitudinal Studies with Missing Data》

感谢回复,请问你这则帖子中的协方差矩阵是怎么算得的?需要考虑哪些因素呢?
Bye SAS.
若有缘,能重聚。

地板
ziyenano 发表于 2013-2-25 16:59:53
Tigflanker 发表于 2013-2-25 15:50
可能比较草率,我用一篇文献中的协方差矩阵和设置进行模拟,然后解释结果。

《Multiple Imputation Ap ...
我只是随机生成一个协方差阵来生成多元正态分布;
只需要保持协方差阵正定即可。
至于怎么算协方差阵,应该是和实际问题有关,你希望v1-v7之间有怎样的
相关关系,就应该设计什么样的协方差阵
已有 1 人评分学术水平 热心指数 信用等级 收起 理由
Tigflanker + 1 + 1 + 1 收到。

总评分: 学术水平 + 1  热心指数 + 1  信用等级 + 1   查看全部评分

7
zkymath 在职认证  发表于 2013-2-27 21:32:09
生成标准正态分布,独立(?):合在一起——差不多就是多元正态分布X;
Y=AX,成了
已有 1 人评分学术水平 热心指数 信用等级 收起 理由
Tigflanker + 1 + 1 + 1 谢谢。

总评分: 学术水平 + 1  热心指数 + 1  信用等级 + 1   查看全部评分

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2026-1-8 04:51