when we create a function why we use -(minus) in return in R -


when create function why use -(minus) in return, in r program see example

f <- function(pars) {   l <- (n*log(pars[1]))+(n*pars[1]*log(t1))+(n*pars[1]*log(pars[2]))-        (n*log((t1^pars[1])-(pars[2]^pars[1])))- ((pars[1]+1)*sum(log(pars[2]+x)))   return(-l)   } 

here why use (-l) in return if use return (l)

the sourse of example error in f(x, ...) : argument "x" missing, no default in nlm

usually aim of maximization. when optimizing functions in r default set of optimizing functions minimize. short cut use - sign in log likelihood function on being minimized in turn maximized. although not necessary. can able use controls within optimizing functions indicate whether need maximize or minimize log likelihood function


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -