This function is used to update G matrix
Gupdate(A, Gdata, p, q, I, refG)numeric matrix
the dataset used to update G
the number of covariates in the dimension reduction
the numbne of study covariates
a U by U incidence matrix with elements; I(i,j)=1 if state j can be accessed from state i in one step and 0 otherwise
a vector of reference categories
a list of outputs:
NewG: the updated G matrix
loglikeK: the loglikelihood when updating G
sderr: standard errors for the coefficient matrix