Description Usage Arguments Details Examples
Use optimization to estimate generalized linear models with arbitrary loss function
1 2 |
formula |
an object of class |
data |
an optional data frame, list or environment (or object coercible by
|
loss |
the loss function taking three arguments: target values |
invlink |
inverse link function (see |
... |
additional parameters passed to |
subset |
an optional vector specifying a subset of observations to be used in the fitting process. |
weights |
an optional vector of 'prior weights' to be used in the fitting process.
Should be |
na.action |
a function which indicates what should happen when the data contain
|
start |
starting values for the parameters in the linear predictor. |
optimLm
is a wrapper around optim
function that can be
used to estimate the parameters of generalized linear model
β = argmin{ loss(Y, invlink(Xβ)) }
where invlink is an inverse link function (see family
)
and loss is a user-specified loss function.
1 2 3 4 5 6 7 8 9 10 11 | myloss <- function(x, y, w) {
r <- x-y
out <- numeric(length(r))
out[r<0] <- r[r<0]^2
out[r>=0] <- abs(r[r>=0])
sum(w * out)
}
optimLm(mpg ~ ., data = mtcars, loss = myloss)
optimLm(mpg ~ ., data = mtcars, loss = huberloss(epsilon = 4))
optimLm(mpg ~ ., data = mtcars, loss = thresholdloss(epsilon = 4))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.