calculate_fit: Calculate fit by minimizing sum of error squares

View source: R/calculate_fit.R

calculate_fitR Documentation

Calculate fit by minimizing sum of error squares

Description

This is an internal function of the remulator package. It fits a curve to given data. For each region and year it minimizes the function sum((y - (a + b * x ^d))^2 x and y are the data provided by the user, and a, b, and d are the coefficients to be found. So, the fit is y = a+b*x^d.

Usage

calculate_fit(data, initial_values = c(1, 1, 1), form, ...)

Arguments

data

MAgPIE object with data to fit.

initial_values

Initial values for the parameters to be optimized over.

form

Fit function for which least squares will be calaculated using the optim function.

...

Arguments passed on to the optim function. Useful to define bounds on fit coefficients.

Value

MAgPIE object with fit coefficients a, b, and d

Author(s)

David Klein


pik-piam/remulator documentation built on Oct. 19, 2023, 4:07 p.m.