求助各位论坛大神,这是想做一个股价走势的模拟,生成完有相关性的两个随机变量后,想根据前一个值,算后一个值,但怎么写都出错。
clear
matrix C = (1, .1, 1)
drawnorm x y, n(1000) corr(C) cstorage(lower)
summarize
gen xx=x/10+1
gen yy=y/10+1
set obs 1000
tempvar z
gen z=10
forvalues i=2/1000{
scalar a=z[i-1]
scalar b=xx[i-1]
replace z = b * a in 'i'
}