inst/examples/objective.R

  ## Generate three objective functions
  prior <- structure(rep(0, 5), names = letters[1:5])
  
  obj1 <- constraintL2(mu = prior, attr.name = "center")
  obj2 <- constraintL2(mu = prior + 1, attr.name = "right")
  obj3 <- constraintL2(mu = prior - 1, attr.name = "left")
  
  ## Evaluate first objective function on a random vector
  pouter <- prior + rnorm(length(prior))
  print(obj1(pouter))
  
  ## Split into fixed and non-fixed part
  fixed <- pouter[4:5]
  pouter <- pouter[1:3]
  print(obj1(pouter, fixed = fixed))
  
  
  ## Visualize the result by a parameter profile
  myfit <- trust(obj1, pouter, rinit = 1, rmax = 10, fixed = fixed)
  myprof <- profile(obj1, myfit$argument, "a", fixed = fixed)
  plotProfile(myprof)
  
  
  ## Create new objective function by adding the single ones,
  ## then evalue the random vector again
  pouter <- prior + rnorm(length(prior))
  obj <- obj1 + obj2 + obj3
  print(obj(pouter))

Try the dMod package in your browser

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

dMod documentation built on Jan. 27, 2021, 1:07 a.m.