R Under development (unstable) (2024-03-20 r86162 ucrt) -- "Unsuffered Consequences" Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > > ### test numeric methods, in particular handling of unequal > ### function lengths > library(maxLik) Loading required package: miscTools Please cite the 'maxLik' package as: Henningsen, Arne and Toomet, Ott (2011). maxLik: A package for maximum likelihood estimation in R. Computational Statistics 26(3), 443-458. DOI 10.1007/s00180-010-0217-1. If you have questions, suggestions, or comments regarding the 'maxLik' package, please use its GitHub page and the issues there: https://github.com/arne-henningsen/maxLik > > f <- function(x) { + if(x[1] <= 0) + return(NA) + # support of x[1] is (0, Inf) + return(c(log(x[1]),x[2])) + } > > ng <- numericGradient(f, c(0.01,1), eps=0.1) Warning message: In numericGradient(f, c(0.01, 1), eps = 0.1) : Function value at -0.04 1.00 = NA (length 1) does not conform with the length at original value 2 Component 1 set to NA > > nh <- try(numericHessian(f, t0=c(0.01,1), eps=0.1)) There were 13 warnings (use warnings() to see them) > > proc.time() user system elapsed 0.29 0.03 0.31