View source: R/advanced-models.R
| nlregress | R Documentation |
Fits flexible nonlinear predictor shapes without requiring users to construct spline bases manually.
nlregress(y,
x,
covariates = NULL,
data = NULL,
spline = c("natural",
"bspline",
"polynomial",
"linear"),
df = 4,
degree = 3,
knots = NULL,
boundary_knots = NULL,
family = c("gaussian",
"binomial",
"poisson"),
event = NULL,
robust = FALSE,
diagnosis = FALSE,
level = 0.95,
digits = 3,
p_digits = 3,
show = TRUE,
console = FALSE)
y |
Outcome variable. |
x |
Numeric predictor whose functional form is modeled flexibly. |
covariates |
Optional additional covariates, including |
data |
Data frame or active data. |
spline |
Natural spline, B-spline, raw polynomial, or linear form. |
df |
Spline degrees of freedom when knots are not supplied. |
degree |
B-spline/polynomial degree. |
knots |
Optional internal knots. |
boundary_knots |
Optional two boundary knots. |
family |
Gaussian, binomial, or Poisson model. |
event |
Event category for binary binomial/Poisson outcomes. |
robust |
Request robust covariance when available. |
diagnosis |
Logical; if |
level, digits, p_digits, show, console |
Confidence, formatting and display controls. |
The fitted model is stored as the active model and can be used immediately by margins(), predict() and lincom().
An R4VN result object, invisibly.
qregress, margins
d <- data.frame(
age = seq(20, 75, by = 5),
bmi = c(20, 21, 22, 24, 23, 25, 26, 27, 29, 28, 30, 31),
sex = factor(rep(c("Female", "Male"), 6)),
y = c(48, 52, 55, 61, 60, 66, 69, 73, 78, 80, 85, 89),
outcome = c(0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1)
)
nlregress(y, age, data = d, spline = "natural", df = 3, show = FALSE)
nlregress(y, age, covariates = vars(sex, bmi), data = d,
spline = "natural", knots = c(35, 50), show = FALSE)
nlregress(outcome, age, data = d, family = "binomial", event = 1,
show = FALSE)
nlregress(y, age, data = d, spline = "bspline", df = 4, diagnosis = TRUE, show = FALSE)
nlregress(y, age, data = d, spline = "polynomial", degree = 2, show = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.