R/mymaxlikg.R

Defines functions mymaxlikg

Documented in mymaxlikg

#' mymaxlikg function creates a maximum likelihood estimate
#'
#' creates a maximum likelihood estimate to find graphical max
#'
#' @param lfun function name to use
#' @param theta sequence of theta to create the estimate for
#'
#' @export

mymaxlikg=function(lfun="logbin2",theta) { # default log lik is a combination bin
  nth=length(theta)  # nu. of valuse used in theta
  thmat=matrix(theta,nr=nth,nc=1,byrow=TRUE) # Matrix of theta
  z=apply(thmat,1,lfun) # z holds the log lik values
  zmax=max(which(z==max(z)))  # finding the INDEX of the max lik
  plot(theta,exp(z),type="l") # plot of lik
  abline(v=theta[zmax],col="Blue")   #  verical line through max
  axis(3,theta[zmax],round(theta[zmax],4))  # one tick on the third axis
  theta[zmax]   # theta corresponding to max lik
}
Thoic/MATH4753thom0414 documentation built on April 22, 2021, 6:37 a.m.