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 Exchange에서 MATLAB에 대해 자세히 알아보기

질문:

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