buildModel | R Documentation |
Build a model object used for model fitting later on
buildModel(mFun, mName, mFormula, mParams, mStarting)
mFun |
Function of the form f(x, params), where params is a named list of parameters and x a vector of input data |
mName |
String, name of the model |
mFormula |
Formula describing the model |
mParams |
Vector of strings containing the parameters names |
mStarting |
Named list with default starting values when fitting the model to some data |
An object of class "customModel" (basically a list)
# Simple linear model
f = function(x, params) {
a = params[["a"]]
b = params[["b"]]
return(a + b * x)
}
myModel = buildModel(f, "linear model",
y ~ a + b * x, c("a", "b"),
list(a = 1, b= 1))
x = c(1, 1, 2, 3, 4, 4, 5, 7)
y = c(2, 4, 3, 7, 8, 7, 10, 11)
fit = fitModel(myModel, x, y)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.