f.quad {FertBoot}R Documentation

Fitting quadratic model using multiple initial values

Description

f.quad fits quadratic model using multiple initial values. The multiple initial values are randomly sampled in a "cube" of parameter space. More precisely, quadratic model assumes y ~ a+b*x+c*x^2,

Usage

f.quad(
  d,
  start = list(a = 1, b = 1, c = 1),
  plus_minus = 1,
  n.start = 10,
  msg = FALSE
)

Arguments

d

data frame with two columns (x and y)

start

initial estimate for non-linear least square (default value: list(a = 1, b = 1, c = 1))

plus_minus

radius of random initial values (default: 100)

n.start

total number of initial points considered (default: 1000)

msg

logical flag whether printing progress

Value

f.quad returns a list of two components (if converged): nls.summary: summary of the fitted model; nls.model: nls object

Examples


set.seed(1)
x <- rep(1:300, each=2)
a <- 8; b <- 0.05; c <- -1e-3
y <- a + b*x + c*x^2 + rnorm(length(x), sd=0.1)
d <- cbind(x,y)

# a converged example:
ans <- f.quad(d, start=list(a = 7, b = 0.02, c = 1e-5),
    plus_minus=10, n.start=10, msg=FALSE)

summary(ans$nls.model)




[Package FertBoot version 0.5.0 Index]