n=5; p=4;
u=randn(n, p);
X= sqrt(1-r*r)*u + r*u;
e=normrnd(0*eye(n),5*(n))
beta0=[4;3;2.3;1];
y=X*beta0*(eye(n))'+e;

1 件のコメント

the cyclist
the cyclist 2016 年 8 月 14 日
The code won't run because the value of r is not defined.

サインインしてコメントする。

 採用された回答

John BG
John BG 2016 年 8 月 14 日

0 投票

Satish
change your last line from
y=X*beta0*(eye(n))'+e;
to
diag(X*beta0)+e
I assumed
r=1
the command diag does what you tried with eye(n).
Satish
would you please be so kind to mark my answer as Accepted Answer?
To any other reader, please if you find this answer of any help solving your question,
please click on the thumbs-up vote link,
thanks in advance
John BG

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeMATLAB についてさらに検索

質問済み:

2016 年 8 月 14 日

回答済み:

2016 年 8 月 14 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by