Dear Stataliters,
I'd want to obtain a weight vector by writing a stata command to realize its compute process. I have carried out these by a Stata .do profile, but I want to convert it to a Stata command. To run these code, we should read dataset first, but I think it doesn't be a barrier to convert it. The Stata code are listed as follows:
mata
w=st_data(.,.)
cols(w)
w=st_data(.,3..32)
cols(w)
ei=st_data(.,33)
rows(ei)
T=14
N=30
w1=J(1,1,.)
for (i=1;i<=T;i++) {
t1=(i-1)*N+1;
t2=i*N;
w2=st_data(t1::t2,3..32)*st_data(t1::t2,33);
w1=(w1\ w2);
}
J=J(421,1,1)
I=I(421,1)
w1=select(w1,J-I)
w1
end
I would feel very appriciate that anyone who can help me to fix this problem. Thx.
Best wishes!
I'd want to obtain a weight vector by writing a stata command to realize its compute process. I have carried out these by a Stata .do profile, but I want to convert it to a Stata command. To run these code, we should read dataset first, but I think it doesn't be a barrier to convert it. The Stata code are listed as follows:
mata
w=st_data(.,.)
cols(w)
w=st_data(.,3..32)
cols(w)
ei=st_data(.,33)
rows(ei)
T=14
N=30
w1=J(1,1,.)
for (i=1;i<=T;i++) {
t1=(i-1)*N+1;
t2=i*N;
w2=st_data(t1::t2,3..32)*st_data(t1::t2,33);
w1=(w1\ w2);
}
J=J(421,1,1)
I=I(421,1)
w1=select(w1,J-I)
w1
end
I would feel very appriciate that anyone who can help me to fix this problem. Thx.
Best wishes!
Comment