R/maxlikg2.R

Defines functions maxlikg2

Documented in maxlikg2

#' Title
#'
#' @param theta1
#' @param theta2
#' @param lfun
#' @param ...
#'
#' @return
#' @export
#'
#' @examples
maxlikg2=function(theta1,theta2,lfun="logbinpois",...){
  n1=length(theta1)
  n2=length(theta2)
  z=outer(theta1,theta2,lfun)
  contour(theta1,theta2,exp(z),...) # exp(z) gives the lik
  maxl=max(exp(z))    # max lik
  coord=which(exp(z)==maxl,arr.ind=TRUE)  # find the co-ords of the max
  th1est=theta1[coord[1]] # mxlik estimate of theta1
  th2est=theta2[coord[2]]
  abline(v=th1est,h=th2est)
  axis(3,th1est,round(th1est,2))
  axis(4,th2est,round(th2est,2),las=1)
  list(th1est=th1est,th2est=th2est)
}
ecoberley/MATH4753cobe0001 documentation built on May 3, 2022, 7:30 p.m.