inst/doc/v03_root_solvers.R

## ---- echo = FALSE, message = FALSE, warning=FALSE----------------------------
library(geex)

## ----SB6_estFUN, echo = TRUE--------------------------------------------------
myefun <- function(data, k = 1.5){
  function(theta){
    x <- data$Y1 - theta[1]
    if(abs(x) <= k) x else sign(x) * k
  }
}

## ----multiroot_example, echo = TRUE, message=FALSE----------------------------
multiroot_results <- m_estimate(
  estFUN = myefun, 
  data  = geexex,
  root_control = setup_root_control(start = 3))

## ----uniroot_example, echo = TRUE, message=FALSE------------------------------
uniroot_results <- m_estimate(
  estFUN = myefun, 
  data  = geexex,
  root_control = setup_root_control(stats::uniroot, interval = c(0, 10)))

## ----compare_results----------------------------------------------------------
roots(multiroot_results) - roots(uniroot_results)

Try the geex package in your browser

Any scripts or data that you put into this service are public.

geex documentation built on Aug. 8, 2022, 5:05 p.m.