point.profile: Fit a Single Profile Point

Description Usage Arguments Value Examples

View source: R/point_profile_function.R

Description

For a fixed value of one of the parameters, point.profile fits the remaining parameters and stores the results in the folder "Profile-Results/Fits/" to be accessed by create.profile later.

Usage

1
2
3
point.profile(no.fit, parms, fit.fn, homedir = getwd(), optim.runs = 5,
  random.borders = 1, con.tol = 0.1, control.optim = list(maxit =
  1000), parscale.pars = TRUE, save.rel.diff = 0, ...)

Arguments

no.fit

A named vector containing the values of all parameters that are not to be fitted.

parms

A named vector containing the values of all parameters.

fit.fn

A cost function. Has to take the complete parameter vector as an input (needs to be names parms) and must return the corresponding negative log-likelihood (-2LL, see Burnham and Anderson 2002).

homedir

The directory to which the results should be saved to.

optim.runs

The number of times that each model will be fitted by optim. Default to 5.

random.borders

The ranges from which the random initial parameter conditions for all optim.runs larger than one are sampled. Can be either given as a vector containing the relative deviations for all parameters or as a matrix containing in its first column the lower and in its second column the upper border values. Parameters are uniformly sampled based on runif. Default to 1 (100% deviation of all parameters). Alternatively, functions such as rnorm, rchisq, etc. can be used if the additional arguments are passed along as well.

con.tol

The absolute convergence tolerance of each fitting run (see Details). Default is set to 0.1.

control.optim

Control parameters passed along to optim. For more details, see optim.

parscale.pars

Logical. If TRUE (default), the parscale option will be used when fitting with optim. This is helpful, if the parameter values are on different scales.

save.rel.diff

A numeric value indicating when to overwrite a pre-existing result. Default to 0, which means that results get overwritten if an improvement is made.

...

Other parameters to be passed on to optim.

Value

Returns the fitted parameter set and the corresponding log-likelihood.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
#define cost function
cost_function <- function(parms){
  y <- parms[1] + parms[2]*c(1:3) + parms[3]^2 *c(1:3)
  LL <- sum((y - c(1:3))^2)
}

#create profile values
point.profile(no.fit = c(p1 = 1),
              parms = c(p1 = 1, p2 = 3, p3 = 2),
              fit.fn = cost_function,
              optim.runs = 1)

GabelHub/ProfileIroning documentation built on May 17, 2019, 12:49 p.m.