Two groups i=1,2 mean estimate for normal distribution.
I would like to find the gradient and the hessian of the log-likelihood using R for the two groups.
The log-likelihood function: loglik=expression(log(( 1/sqrt(2*pi*sigmasq)*exp(y-mu)^2/ 2*sigmasq)))
The derivative dbt=D(loglik,"mu")
The hessian dbtt=D(dbt,"mu")
My code is for a one sample, how would I code for the two groups and find the derivative and hessian as in a joint distribution?
Update: the log-likelihood for the two groups
N = n1+n2, is the sum of the sample sizes for the two groups