Optimization and model fitting Flashcards
optim(par, fn, method = c(“Nelder-Mead”, “BFGS”, “CG”, “L-BFGS-B”, “SANN”)
general-purpose optimization; par is initial values, fn is function to optimize (normally minimize)
nlm(f,p)
minimize function f using a Newton-type algorithm with starting values p
lm(formula)
it linear models; formula is typically of the form response termA + termB + …; use I(x*y) + I(xˆ2) for terms made of nonlinear components
glm(formula,family=)
it generalized linear models, specified by giv- ing a symbolic description of the linear predictor and a description of the error distribution; family is a description of the error distribution and link function to be used in the model; see ?family
nls(formula)
nonlinear least-squares estimates of the nonlinear model parameters
approx(x,y=)
linearly interpolate given data points; x can be an xy plot- ting structure
spline(x,y=)
cubic spline interpolation
loess(formula)
it a polynomial surface using local fitting
Many of the formula-based modeling functions have several common argu- ments: data= the data frame for the formula variables, subset= a subset of variables used in the fit, na.action= action for missing values: “na.fail”, “na.omit”, or a function. The following generics often apply to model fitting functions:
predict(fit,…)
predictions from fit based on input data
df.residual(fit)
returns the number of residual degrees of freedom
coef(fit)
returns the estimated coefficients (sometimes with their
standard-errors)
residuals(fit)
returns the residuals
deviance(fit)
returns the deviance
fitted(fit)
returns the fitted values
logLik(fit)
computes the logarithm of the likelihood and the number of
parameters