buildModel: Build a model object used for model fitting later on

View source: R/buildModel.R

buildModelR Documentation

Build a model object used for model fitting later on

Description

Build a model object used for model fitting later on

Usage

buildModel(mFun, mName, mFormula, mParams, mStarting)

Arguments

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

Value

An object of class "customModel" (basically a list)

Examples

# 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)


mdjbru-R-packages/thermPerf documentation built on Nov. 4, 2023, 11:48 p.m.