R/mle.st.R

Defines functions mle.st

Documented in mle.st

mle.st <- function(st, init_par = c(2,1,60), impsam=F, correction = FALSE){
  n_trees = length(st)
  if(impsam==T){
    if(correction==TRUE){
      W = vector(mode = 'numeric',length = n_trees)
      D = vector(mode = 'numeric',length = n_trees)
      for(j in 1:n_trees){
        rec = st[[j]]
        W[j] = rec$logweight
        D[j] = length(rec$wt)
      }
      m1=lm(W~D)
      m1=m1$coefficients[2]
    }
    else{
      m1=0
    }
    p = subplex(par = init_par, fn = llik.st, setoftrees=st, impsam=impsam, correction=m1)$par
  }else{
    p = subplex(par = init_par, fn = llik.st, setoftrees=st,impsam=impsam)$par
  }

  return(p)
}
franciscorichter/dmea02 documentation built on March 21, 2020, 3:46 a.m.