### GMM and covariance among factors

Posted:

**Thu Jun 06, 2019 2:48 pm**Given the 7 variables (y1,...,y7) and the tree factors (x1, x2 and x3),

system SDF

SDF.append ( y1*(1 - c(1)*(x1 - c(4)) - c(2)*(x2 - c(5)) - c(3)*(x3 - c(6))) ) = 0 @ c

SDF.append ( y2*(1 - c(1)*(x1 - c(4)) - c(2)*(x2 - c(5)) - c(3)*(x3 - c(6))) ) = 0 @ c

SDF.append ( y3*(1 - c(1)*(x1 - c(4)) - c(2)*(x2 - c(5)) - c(3)*(x3 - c(6))) ) = 0 @ c

SDF.append ( y4*(1 - c(1)*(x1 - c(4)) - c(2)*(x2 - c(5)) - c(3)*(x3 - c(6))) ) = 0 @ c

SDF.append ( y5*(1 - c(1)*(x1 - c(4)) - c(2)*(x2 - c(5)) - c(3)*(x3 - c(6))) ) = 0 @ c

SDF.append ( y6*(1 - c(1)*(x1 - c(4)) - c(2)*(x2 - c(5)) - c(3)*(x3 - c(6))) ) = 0 @ c

SDF.append ( y7*(1 - c(1)*(x1 - c(4)) - c(2)*(x2 - c(5)) - c(3)*(x3 - c(6))) ) = 0 @ c

SDF_all_{%type}.append ( X1 - c(4) ) = 0 @ c

SDF_all_{%type}.append ( x2 - c(5) ) = 0 @ c

SDF_all_{%type}.append ( x3 - c(6) ) = 0 @ c

param c(1) 0.9 c(2) 0.9 c(3) 0.9 c(4) 0.9 c(5) 0.9 c(6) 0.9

'Sequential weighting matrix & coefficient iteration

'Cross section (White Cov) will result in GMM estimates robust to heteroskedasticity of unknown form

SDF_all_{%type}.gmm(instwgt=white,method=nstep,wtype=istdev,s)

**is it possible to save the covariance of factors x1, x2 and x3 using GMM**, after solving the system below?system SDF

SDF.append ( y1*(1 - c(1)*(x1 - c(4)) - c(2)*(x2 - c(5)) - c(3)*(x3 - c(6))) ) = 0 @ c

SDF.append ( y2*(1 - c(1)*(x1 - c(4)) - c(2)*(x2 - c(5)) - c(3)*(x3 - c(6))) ) = 0 @ c

SDF.append ( y3*(1 - c(1)*(x1 - c(4)) - c(2)*(x2 - c(5)) - c(3)*(x3 - c(6))) ) = 0 @ c

SDF.append ( y4*(1 - c(1)*(x1 - c(4)) - c(2)*(x2 - c(5)) - c(3)*(x3 - c(6))) ) = 0 @ c

SDF.append ( y5*(1 - c(1)*(x1 - c(4)) - c(2)*(x2 - c(5)) - c(3)*(x3 - c(6))) ) = 0 @ c

SDF.append ( y6*(1 - c(1)*(x1 - c(4)) - c(2)*(x2 - c(5)) - c(3)*(x3 - c(6))) ) = 0 @ c

SDF.append ( y7*(1 - c(1)*(x1 - c(4)) - c(2)*(x2 - c(5)) - c(3)*(x3 - c(6))) ) = 0 @ c

SDF_all_{%type}.append ( X1 - c(4) ) = 0 @ c

SDF_all_{%type}.append ( x2 - c(5) ) = 0 @ c

SDF_all_{%type}.append ( x3 - c(6) ) = 0 @ c

param c(1) 0.9 c(2) 0.9 c(3) 0.9 c(4) 0.9 c(5) 0.9 c(6) 0.9

'Sequential weighting matrix & coefficient iteration

'Cross section (White Cov) will result in GMM estimates robust to heteroskedasticity of unknown form

SDF_all_{%type}.gmm(instwgt=white,method=nstep,wtype=istdev,s)