A minimal function to perform total least squares regression
s.TLS(x, y = NULL, x.test = NULL, y.test = NULL, x.name = "x",
y.name = "y", print.plot = TRUE, plot.fitted = NULL,
plot.predicted = NULL, plot.theme = getOption("rt.fit.theme",
"lightgrid"), question = NULL, rtclass = NULL, verbose = TRUE,
outdir = NULL, save.mod = ifelse(!is.null(outdir), TRUE, FALSE), ...)
Numeric vector or matrix / data frame of features i.e. independent variables
Numeric vector of outcome, i.e. dependent variable
Numeric vector or matrix / data frame of testing set features
Columns must correspond to columns in x
Numeric vector of testing set outcome
Character: Name for feature set
Character: Name for outcome
Logical: if TRUE, produce plot using mplot3
Takes precedence over plot.fitted
and plot.predicted
Logical: if TRUE, plot True (y) vs Fitted
Logical: if TRUE, plot True (y.test) vs Predicted.
Requires x.test
and y.test
String: "zero", "dark", "box", "darkbox"
String: the question you are attempting to answer with this model, in plain language.
String: Class type to use. "S3", "S4", "RC", "R6"
Logical: If TRUE, print summary to screen.
Path to output directory.
If defined, will save Predicted vs. True plot, if available,
as well as full model output, if save.mod
is TRUE
Logical. If TRUE, save all output as RDS file in outdir
save.mod
is TRUE by default if an outdir
is defined. If set to TRUE, and no outdir
is defined, outdir defaults to paste0("./s.", mod.name)
Additional arguments
The main differences between a linear model and TLS is that the latter assumes error in the features as well as
the outcome. The solution is essentially the projection on the first principal axis.
Because there is no model, predict
and other methods are not currently working with s.TLS
These features may be added in the future