View source: R/grad_hess_L_gamma.R
grad_hess_L_gamma | R Documentation |
This function calculates the gradient and Hessian of the log-likelihood with respect to gamma
grad_hess_L_gamma(Y, X, eta, gamma, I, J)
Y |
Observation matrix |
X |
Design matrix |
eta |
Initial eta vector |
gamma |
Initial gamma vector |
I |
Number of conditions |
J |
Number of replications |
grad_L_gamma |
Vector of the gradient of L with respect to gamma |
hess_L_gamma |
Matrix of the Hessian of L with respect to gamma |
Marina Gomtsyan
Maintainer: Marina Gomtsyan <marina.gomtsyan@agroparistech.fr>
M. Gomtsyan et al. "Variable selection in sparse multivariate GLARMA models: Application to germination control by environment", arXiv:2208.14721
data(Y) I=3 J=100 T=dim(Y)[2] q=1 X=matrix(0,nrow=(I*J),ncol=I) for (i in 1:I) { X[((i-1)*J+1):(i*J),i]=rep(1,J) } gamma_0 = matrix(0, nrow = 1, ncol = q) eta_glm_mat_0 = matrix(0,ncol=T,nrow=I) for (t in 1:T) { result_glm_0 = glm(Y[,t]~X-1,family=poisson(link='log')) eta_glm_mat_0[,t]=as.numeric(result_glm_0$coefficients) } eta_0 = round(as.numeric(t(eta_glm_mat_0)),digits=6) result = grad_hess_L_gamma(Y, X, eta_0, gamma_0, I, J) grad = result$grad_L_gamma Hessian = result$hess_L_gamma
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.