Hello Dear Statalist Members,
I am using nested loops for a linear regression with the following code:
forvalues l=1/4 {
forvalues q=1/4 {
forvalues p=1/4 {
forvalues m=1/4 {
forvalues n=1/4 {
forvalues s=1/4 {
reg var38 L(0/`l').s_gapcdax L(0/`q').s_gaphp L(0/`p').s_gapcrr L(0/`m').s_gapinvr L(0/`n').s_gapgdp L(0/`s').s_gapm2fer, robust
}
}
}
}
}
}
My goal was to get the regression results for all the possible combinations of the lags for the independent variables, for example:
s_gapcdax (-1)
s_gaphp (-3)
s_gapcrr (-2)
s_gapinvr(-4)
s_gapgdp(-2)
s_gapm2fer(-1)
and other combinations.
However, at the end I get all the lags from 1 to 4 of all the variables in one regression.
Could someone, please, tell me, what is wrong with my code? I would appreciate any help.
I am using nested loops for a linear regression with the following code:
forvalues l=1/4 {
forvalues q=1/4 {
forvalues p=1/4 {
forvalues m=1/4 {
forvalues n=1/4 {
forvalues s=1/4 {
reg var38 L(0/`l').s_gapcdax L(0/`q').s_gaphp L(0/`p').s_gapcrr L(0/`m').s_gapinvr L(0/`n').s_gapgdp L(0/`s').s_gapm2fer, robust
}
}
}
}
}
}
My goal was to get the regression results for all the possible combinations of the lags for the independent variables, for example:
s_gapcdax (-1)
s_gaphp (-3)
s_gapcrr (-2)
s_gapinvr(-4)
s_gapgdp(-2)
s_gapm2fer(-1)
and other combinations.
However, at the end I get all the lags from 1 to 4 of all the variables in one regression.
Could someone, please, tell me, what is wrong with my code? I would appreciate any help.
Comment