View source: R/plsi.lr.auto.constraint.R
| plsi.lr.auto.constraint | R Documentation |
Same model as plsi.lr.v2(), but the link function is estimated with a
penalized regression spline (mgcv::gam, REML smoothing-parameter
selection) instead of a fixed-df natural spline. This removes the need to
hand-tune spline.num: you supply an upper bound on basis complexity
(k), and REML shrinks unneeded wiggliness toward a straight line
automatically. Effective degrees of freedom actually used by the fitted
link function are reported in si.fun.edf.
plsi.lr.auto.constraint(
data,
Y.name,
X.name,
Z.name,
k = 10,
bs = "cr",
initial.random.num = 5,
seed = 2026
)
data |
A data set including all needed variables |
Y.name |
Variable name for scalar outcome |
X.name |
Variable name vector for exposures |
Z.name |
Variable name vector for confounders |
k |
Upper bound on basis dimension for the smooth link function
(analogous to |
bs |
Smooth basis type passed to |
initial.random.num |
Number of random initials for the single-index direction search |
seed |
A single integer used to seed the RNG so results (random initials and downstream optim() convergence) are reproducible. Set to NULL to skip seeding and use whatever RNG state is already active in the calling environment. Default is 2026. |
The single-index coefficient \beta is constrained to \|\beta\| = 1
and \beta_1 > 0 for identifiability. Rather than optimizing over
\beta directly and projecting/normalizing after the fact, the search
is reparameterized in terms of \sigma = (\sigma_1, \dots, \sigma_{p-1})
via \beta(\sigma) = \{(1 - \|\sigma\|^2)^{1/2}, \sigma_1, \dots,
\sigma_{p-1}\}^T. Both constraints hold automatically for any
\sigma with \|\sigma\| < 1, so optim() runs unconstrained
over \sigma and \beta_1 > 0, \|\beta\| = 1 never need to be
imposed after the fact. Standard errors for \beta are obtained from
the Hessian in \sigma-space via the delta method.
The anchor exposure – the one assigned \beta_1, the coordinate
constrained > 0 – is chosen as the candidate exposure with the
largest absolute correlation with Y.name (not the largest
signed/positive correlation), so an exposure strongly but negatively
associated with the outcome can still be selected as the anchor. Which
exposure was selected, and its correlation with Y.name, is reported
in attr(si.coefficient, "note") and in anchor.note of the
returned list.
A list of model estimation and prediction results, structured
analogously to plsi.lr.v2()'s output.
Yuyan Wang
## Not run:
# example to run plsi.lr.auto.constraint
data(nhanes.new)
data <- nhanes.new
Y.name <- "log.triglyceride"
X.name <- c("X1_trans.b.carotene", "X2_retinol", "X3_g.tocopherol", "X4_a.tocopherol",
"X5_PCB99", "X6_PCB156", "X7_PCB206",
"X8_3.3.4.4.5.pncb", "X9_1.2.3.4.7.8.hxcdf", "X10_2.3.4.6.7.8.hxcdf")
Z.name <- c("AGE.c", "SEX.Female", "RACE.NH.Black",
"RACE.MexicanAmerican", "RACE.OtherRace", "RACE.Hispanic" )
k <- 10
bs <- "cr"
initial.random.num <- 1
seed = 2026
model_lr_auto <- plsi.lr.auto.constraint(data = data,
Y.name = Y.name, X.name = X.name, Z.name = Z.name,
k = k, bs = bs, initial.random.num = initial.random.num, seed = seed)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.