# how to test for significant differencecs in ML estimates after optim()

#### LVP

##### New Member
I am trying to test whether or not there is a significant difference between maximum likelihood estimates of two genetic parameters (selection and dominance) across two environments with genotype data from a cross. There are three genotype classes, C11, C12, and C22, and I am looking to maximize the likelihood below:

Code:
 llhood2 <- function(theta, c, c11,c12,c22){

s<-theta
d<-theta

P11 = (1 - ((s * (1 - c) * (1 - c + (2 * d * c)))) / (4 - (s * (1 + (2 * d))))
P22 = (1 - (s * c * ((2 * d * (1 - c)) + c))) / (4 - (s * (1 + (2 * d))))
P12 = (1 - P11 - P22)
logL = c11*log(P11) + c12*log(P12) + c22*log(P22)
-logL
}
c is fixed depending on which genetic marker you are using, and c11, c12, and c22 are the data, representing genotypes AA, AB, and BB respectively. So I am jointly estimating s and d.

Using the optim function in R and plugging in genotype data from each environment, I am able to get a point estimate for s and d in one environment (s1 and d1) and the variance of these estimates from the hessian, then I get parameter estimates using genotype data from the 2nd environment,(s2 and d2, and thier associated variances). So, two separate fittings of the model give me s1 var_s_1 and s2 var_s_2, etc. The Code for optim is below:

Code:
fit1 <- optim(inits, llhood, method="L-BFGS-B", hessian=T, lower=lower,   upper=upper,
c=c,c11=c11,c12=c12,c22=c22, control=list(trace=1))

fit2 <- optim(inits, llhood, method="L-BFGS-B", hessian=T, lower=lower, upper=upper,
c=c,c11=n11,c12=n12,c22=n22, control=list(trace=1)
I then want to know if s1 is significantly different from s2 (likewise for d1 and d2). I thought this would be a straight forward test, but I have had a hard time finding documentation on how to do this properly, or most elegantly. As a crude approximation, I used a simple two-sample T test, but Im pretty sure that it is not quite right... Perhaps a wald test?

Ive also considered a likelihood ratio test where I test whether the difference between the two estimates of s1 and s2, is not different from zero (s1= s2 ,reduced model) vs different from zero. But I'm not sure how to set this up given my likelihood equations (i.e how to get ML estimates in both environments simultaneously). An added wrinkle is that I have two unknowns, s and d, both of which Id like to test for significant differences between the two environments. So would I need to fix one, to test for the other?

Any specific help would be much appreciated.

Louis