below is a code to compute hessian matrix , which i need to generate 29 number of different matrices for example first element in x1 and x2 is use to generate let say matrix (M1) and second element in x1 and x2 give matrix (M2) upto  matrix (M29) corresponding to the total number of observations and b1 and b2 are constant. 
can some one guide me or help to implement this please. I did not understand how to construct the loop which i think it should be

about 3 dfferent loops
example i = 1 to 29 number of matrices
                j1=1 t0 2 row of matirx
                j2= 1 to 2 ncol of matrix


x1<-c(5.548,4.896,1.964,3.586,3.824,3.111,3.607,3.557,2.989,18.053,3.773,1.253,2.094,2.726,1.758,5.011,2.455,0.913,0.890,2.468,4.168,4.810,34.319,1.531,1.481,2.239,4.204,3.463,1.727)
y<-c(2.590,3.770,1.270,1.445,3.290,0.930,1.600,1.250,3.450,1.096,1.745,1.060,0.890,2.755,1.515,4.770,2.220,0.590,0.530,1.910,4.010,1.745,1.965,2.555,0.770,0.720,1.730,2.860,0.760)
x2<-c(0.137,2.499,0.419,1.699,0.605,0.677,0.159,1.699,0.340,2.899,0.082,0.425,0.444,0.225,0.241,0.099,0.644,0.266,0.351,0.027,0.030,3.400,1.499,0.351,0.082,0.518,0.471,0.036,0.721)
b1<-4.286b2<-1.362

n<-29
for(i in 1:n){
    gh<-matrix(0,2,2)
exp0<-(1+b1*x2^b2)
exp1<-x1*x2^b2*log(x2)
exp3<-x1*b1*x2^b2*(log(x2))^2
gh[1,1]<-2*x2^(2*b2)*exp0/exp0^4
gh[1,2]<--(exp0^2*exp1 - 2*b1*x2^b2*exp0*exp1)/exp0^4
gh[2,1]<--(exp3*exp0^2-2*exp0*b1^2*x2^b2*log(x2)*exp1)/exp0^4
gh[2,2]<--(exp1*exp0^2-2*exp0*x2^b2*b1*exp1)/exp0^4
}
	[[alternative HTML version deleted]]

