Description Usage Arguments Details Value Examples
Fit predefined functions to data via nonlinear least squares using LevenbergMarquardt
algorithm via nlsLM
.
1 2 3 4 5 6 7 8 9 10  fitFunction(
dataset = cs.in.dataset(),
preds = cs.in.predictors(),
resps = cs.in.responses(),
groups = cs.in.groupvars(),
auxs = cs.in.auxiliaries(),
scriptvars = cs.in.scriptvars(),
return.results = FALSE,
...
)

dataset 
[ 
preds 
[ 
resps 
[ 
groups 
[ 
auxs 
[ 
scriptvars 
[ 
return.results 
[ 
... 
[ANY] 
The following script variables are summarized in scriptvars
list:
[character(1)
]
Function selection for fitting data. It is possible to choose a predefined model, or
compose a model manually by selecting User Defined
.
Default is User Defined
[character(1)
]
Required if math.fun
is set to User Defined
.
Valid R formula
for the right hand side (predictors) of the model equation.
[character(1)
]
Required if math.fun
is set to User Defined
.
Valid R formula
for the left hand side (response) of the model equation.
[character(1)
]
Optional if math.fun
is set to User Defined
.
Specifies minimum and maximum value for function math.fun
as a comma separated list
of min
and max
.
It is possible to assign variables, e.g. min=a
, which need start values in
start.vals
, as well as real numbers, e.g. min=4.5
, with a period as decimal
separator.
[character(1)
]
Required if math.fun
is set to User Defined
.
Specify starting values for all terms of the right hand side as a comma separated list
with a period as decimal separator.
[character(1)
]
Select a weighting variable from the auxiliary variables.
Maximum number of iterations.
For details see link[minpack.lm]{nls.lm.control}
Maximum relative error desired in the sum of squares. If 0
,
the default is used.
For details see link[minpack.lm]{nls.lm.control}
Logical [TRUE
] invisibly and outputs to Cornerstone or,
if return.results = TRUE
, list
of
resulting data.frame
objects:
coeff 
Estimated coefficients and standard errors for each group.
Convergence information is available for every group (for details see

vcov 
VarianceCovariance matrix of the main coefficients for the fitted model of each
group (for details see 
predictions 
Dataset to brush with predictions and residuals added to original values and groups, if available. 
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22  # Generate data from logistic function:
fun = function(x, a, b, c, d, sigma = 1) {
a+(ba) / (1+exp(d*(xc))) + rnorm(length(x), sd = sigma)
}
library(data.table)
dt = data.table( x1 = sample(seq(10, 10, length.out = 100))
, group1 = sample(x = c("A", "B"), replace = TRUE, size = 100)
)
dt[group1 == "A", y1 := fun(x1, 1, 10, 1, 0.6, 0.1)]
dt[group1 == "B", y1 := fun(x1, 8, 2, 1, 0.3, 0.1)]
# Set script variables
scriptvars = list(math.fun = "Logistic", resp.frml = "", preds.frml = "", limits = ""
, start.vals = "", weights = "", max.iter = 50, max.ftol = 0
)
# Fit the logistic function:
res = fitFunction(dt, "x1", "y1", "group1", character(0), scriptvars, TRUE)
# Show estimated coefficients:
res$coeff
# VarianceCovariance matrix:
res$vcov
# Plot fitted vs. residuals:
plot(res$predictions$Fitted, res$predictions$Residuals)

Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.