| Type: | Package |
| Title: | Semi-Parametric Shape-Restricted Fixed/Mixed Effect(s) Regression Spline |
| Version: | 0.1.1 |
| Maintainer: | Qing Yin <qiy25@pitt.edu> |
| Imports: | splines2, stats, lme4, nloptr, dplyr, MASS, coneproj, Matrix |
| Description: | Select the most suitable shape to describe the relationship between the exposure and the outcome among increasing, decreasing, convex, and concave shapes (Yin et al. (2021) <doi:10.1007/s13571-020-00246-7>); estimate the direct and indirect effects with prior knowledge on the relationship between the mediator and the outcome with binary exposure (Yin et al. (2024) <doi:10.1007/s13571-024-00336-w>); estimate the direct and indirect effects using linear regression-based approach (VanderWeele (2015, ISBN:9780199325870)). |
| License: | GPL-3 |
| Encoding: | UTF-8 |
| LazyData: | true |
| RoxygenNote: | 7.3.3 |
| Depends: | R (≥ 4.4.0) |
| Suggests: | knitr, rmarkdown, testthat (≥ 3.0.0) |
| Config/testthat/edition: | 3 |
| VignetteBuilder: | knitr |
| NeedsCompilation: | no |
| Packaged: | 2026-01-06 14:29:06 UTC; qingyin |
| Author: | Qing Yin [aut, cre], Shyamal Das Peddada [aut], Jennifer Joan Adibi [aut], Jong-Hyeon Jeong [aut] |
| Repository: | CRAN |
| Date/Publication: | 2026-01-13 18:30:07 UTC |
P values for shapes obtained from semi-parametric shape-restricted fixed effect regression splines.
Description
P values for shapes obtained from semi-parametric shape-restricted fixed effect regression splines.
Usage
FERS(
y,
xMain,
xConf = NULL,
dataset,
knotType = 2,
preKnot = NULL,
nBasis = 5,
nIter
)
Arguments
y |
The name of the outcome. |
xMain |
The name of the main effect. |
xConf |
The name vector of the confounders. |
dataset |
A data frame. |
knotType |
The knot type: 1=equal-spaced, 2=quantile, 3=pre-specified. |
preKnot |
The pre-specified knots. |
nBasis |
The number of bases. |
nIter |
The number of iterations. |
Value
A list of weights of beta distribution and p-values.
Examples
shape <- FERS(y = "ySim", xMain = "hormone",
xConf = c("age", "invwt", "race2", "race3", "race4", "race5",
"season2", "season3", "season4", "smoking1", "ovum1", "diabetes1"),
dataset = data.sim.fixed, nBasis = 5, nIter = 50)
shape
P values for shapes obtained from semi-parametric shape-restricted fixed effect regression splines with factor-by-curve interaction.
Description
P values for shapes obtained from semi-parametric shape-restricted fixed effect regression splines with factor-by-curve interaction.
Usage
FERSInt(
y,
xExp,
xMed,
xConf = NULL,
dataset,
knotType = 2,
preKnot = NULL,
nBasis = 5,
nIter
)
Arguments
y |
The name of the outcome. |
xExp |
The name of the exposure (must be a binary variable). |
xMed |
The name of the mediator (must be a continuous variable). |
xConf |
The name vector of the confounders. |
dataset |
A data frame. |
knotType |
The knot type: 1=equal-spaced, 2=quantile, 3=pre-specified. |
preKnot |
The pre-specified knots. |
nBasis |
The number of bases. |
nIter |
The number of iterations. |
Value
A list of weights of beta distribution and p-values for both exposure groups.
Note
This function has not been validated through simulation studies. Please use with caution. shape <- FERSInt(y = "ySim", xExp = "pesticide1", xMed = "hormone", xConf = c("pesticide1", "age", "invwt", "race2", "race3", "race4", "race5", "season2", "season3", "season4", "smoking1", "ovum1", "diabetes1"), dataset = data.sim.fixed.int, nBasis = 5, nIter = 50) shape
Calculate the CDE, NDE and NIE (linear models, binary exposure).
Description
Calculate the CDE, NDE and NIE (linear models, binary exposure).
Usage
LRMed(data, exposure, mediator, outcome, confounderVec, mValue)
Arguments
data |
A data frame. |
exposure |
The name of the exposure (must be a binary variable). |
mediator |
The name of the mediator (must be a continuous variable). |
outcome |
The name of the outcome (must be a continuous variable). |
confounderVec |
The name vector of the confounders. |
mValue |
The controlled mediator value for CDE estimation. |
Value
A list of exposure-outcome model, exposure-mediator model, CDE, NDE and NIE and their asymptotic variances.
Examples
medModel <- LRMed(data = data.sim.med,
exposure = "pesticide1", mediator = "hormone", outcome = "ySim",
confounderVec = c("age", "invwt", "race2", "race3", "race4", "race5",
"season2", "season3", "season4", "smoking1", "ovum1",
"diabetes1"),
mValue = 0.15)
medModel
Calculate the CDE, NDE and NIE (linear models, continuous exposure).
Description
Calculate the CDE, NDE and NIE (linear models, continuous exposure).
Usage
LRMed2(
data,
exposure,
mediator,
outcome,
confounderVec,
mValue,
eValueLow,
eValueHigh
)
Arguments
data |
A data frame. |
exposure |
The name of the exposure (must be a continuous variable). |
mediator |
The name of the mediator (must be a continuous variable). |
outcome |
The name of the outcome (must be a continuous variable). |
confounderVec |
The name vector of the confounders. |
mValue |
The controlled mediator value for CDE estimation. |
eValueLow |
The low reference level of exposure. |
eValueHigh |
The high reference level of exposure. |
Value
A list of exposure-outcome model, exposure-mediator model, CDE, NDE and NIE and their asymptotic variances.
Examples
medModel <- LRMed2(data = data.sim.med,
exposure = "pesticideCont", mediator = "hormone", outcome = "ySim",
confounderVec = c("age", "invwt", "race2", "race3", "race4", "race5",
"season2", "season3", "season4", "smoking1", "ovum1",
"diabetes1"),
mValue = 0.15, eValueLow = 0.1, eValueHigh = 1.1)
medModel
P values for shapes obtained from semi-parametric shape-restricted mixed effects regression splines.
Description
P values for shapes obtained from semi-parametric shape-restricted mixed effects regression splines.
Usage
MERS(
y,
xMain,
xConf = NULL,
xRand,
dataset,
knotType = 2,
preKnot = NULL,
nBasis = 5,
nIter
)
Arguments
y |
The name of the outcome. |
xMain |
The name of the main effect. |
xConf |
The name vector of the confounders. |
xRand |
The name of the random effect. |
dataset |
A data frame. |
knotType |
The knot type: 1=equal-spaced, 2=quantile, 3=pre-specified. |
preKnot |
The pre-specified knots. |
nBasis |
The number of bases. |
nIter |
The number of iterations. |
Value
A list of weights of beta distribution and p-values.
Examples
shape <- MERS(y = "ySim", xMain = "hormone",
xConf = c("age", "invwt", "race2", "race3", "race4", "race5",
"season2", "season3", "season4", "smoking1", "ovum1", "diabetes1"),
xRand = "cluster",
dataset = data.sim.mixed, nBasis = 5, nIter = 50)
shape
Fit a semi-parametric shape-restricted fixed effect regression spline with factor-by-curve interaction.
Description
Fit a semi-parametric shape-restricted fixed effect regression spline with factor-by-curve interaction.
Usage
SRSplineFERInt(
lmFormula,
dataset,
varNameExp,
varNameMed,
knotType = 2,
preKnot = NULL,
nBasis = 5,
EffMain = "I",
EffInt = "I"
)
Arguments
lmFormula |
A linear model formula. |
dataset |
A data frame. |
varNameExp |
The name of the exposure (must be a binary variable). |
varNameMed |
The name of the mediator (must be a continuous variable). |
knotType |
The knot type: 1=equal-spaced, 2=quantile, 3=pre-specified. |
preKnot |
The pre-specified knots. |
nBasis |
The number of bases. |
EffMain |
The spline type for main effect |
EffInt |
The spline type for interaction effect |
Value
A list of knots, data set, lm model, summary of lm model, coefficient estimates of bases, covariance of coefficient estimates of bases, projected coefficient estimates, test statistic.
Fit a semi-parametric shape-restricted fixed effect regression spline with factor-by-curve interaction.
Description
Fit a semi-parametric shape-restricted fixed effect regression spline with factor-by-curve interaction.
Usage
SRSplineFERInt2(
lmFormula,
dataset,
varNameExp,
varNameMed,
knotType = 2,
preKnot = NULL,
nBasis = 5,
Eff0 = "I",
Eff1 = "I"
)
Arguments
lmFormula |
A linear model formula. |
dataset |
A data frame. |
varNameExp |
The name of the exposure (must be a binary variable). |
varNameMed |
The name of the mediator (must be a continuous variable). |
knotType |
The knot type: 1=equal-spaced, 2=quantile, 3=pre-specified. |
preKnot |
The pre-specified knots. |
nBasis |
The number of bases. |
Eff0 |
The spline type for main effect |
Eff1 |
The spline type for interaction effect |
Value
A list of knots, data set, lm model, summary of lm model, coefficient estimates of bases, covariance of coefficient estimates of bases, projected coefficient estimates, test statistic.
Calculate the CDE, NDE and NIE.
Description
Calculate the CDE, NDE and NIE.
Usage
SRSplineMed(
data,
nBasis,
exposure,
mediator,
outcome,
confounderVec,
shapeExp,
shapeNonExp,
mValue,
varAsymp = FALSE
)
Arguments
data |
A data frame. |
nBasis |
The number of bases. |
exposure |
The name of the exposure (must be a binary variable). |
mediator |
The name of the mediator (must be a continuous variable). |
outcome |
The name of the outcome (must be a continuous variable). |
confounderVec |
The name vector of the confounders. |
shapeExp |
The shape of mediator in exposure group ("increasing", "decreasing", "convex", or "concave"). |
shapeNonExp |
The shape of mediator in non-exposure group ("increasing", "decreasing", "convex", or "concave"). |
mValue |
The controlled mediator value for CDE estimation. |
varAsymp |
Whether to output the asymptotic variance (T/F) |
Value
A list of exposure-outcome model, exposure-mediator model, knot sequence, coefficient vector of exposure spline, coefficient vector of non-exposure spline, residuals, sds and coefficients, CDE, NDE and NIE and their asymptotic variances.
Examples
medModel <- SRSplineMed(data = data.sim.med, nBasis = 5,
exposure = "pesticide1", mediator = "hormone", outcome = "ySim",
confounderVec = c("age", "invwt", "race2", "race3", "race4", "race5",
"season2", "season3", "season4", "smoking1", "ovum1",
"diabetes1"),
shapeExp = "concave", shapeNonExp = "increasing", mValue = 0.15,
varAsymp = TRUE)
medModel
Calculate the CDE, NDE and NIE of bootstrapped data.
Description
Calculate the CDE, NDE and NIE of bootstrapped data.
Usage
SRSplineMedBoot(
data,
nBasis,
exposure,
mediator,
mediatorSim,
outcomeSim,
confounderVec,
shapeExp,
shapeNonExp,
mValue
)
Arguments
data |
A data frame. |
nBasis |
The number of bases. |
exposure |
The name of the exposure (must be a binary variable). |
mediator |
The name of the mediator (must be a continuous variable). |
mediatorSim |
The name of the simulated mediator (must be a continuous variable). |
outcomeSim |
The name of the simulated outcome (must be a continuous variable). |
confounderVec |
The name vector of the confounders. |
shapeExp |
The shape of mediator in exposure group ("increasing", "decreasing", "convex", or "concave"). |
shapeNonExp |
The shape of mediator in non-exposure group ("increasing", "decreasing", "convex", or "concave"). |
mValue |
The controlled mediator value for CDE estimation. |
Value
A list of CDE, NDE and NIE.
Calculate the expectation of a fixed effect regression spline (convexity).
Description
Calculate the expectation of a fixed effect regression spline (convexity).
Usage
cSplineExp(t, theta, sigma2, gamma0, gamma1, gamma2, a, c)
Arguments
t |
The knot sequence vector in exposure-outcome model. |
theta |
The coefficient vector of C-spline bases in exposure-outcome model. |
sigma2 |
The residual standard deviation of exposure-mediator model. |
gamma0 |
The coefficient of intercept of exposure-mediator model. |
gamma1 |
The coefficient of exposure of exposure-mediator model. |
gamma2 |
The coefficient vector of confounders of exposure-mediator model. |
a |
The value of exposure (0/1). |
c |
The values of confounders. |
Value
The expectation of a fixed effect regression spline.
Calculate the derivatives of coefficients of a fixed effect regression spline (convexity).
Description
Calculate the derivatives of coefficients of a fixed effect regression spline (convexity).
Usage
cSplineExpDeriv(t, theta, sigma2, gamma0, gamma1, gamma2, a, c)
Arguments
t |
The knot sequence vector in exposure-outcome model. |
theta |
The coefficient vector of C-spline bases in exposure-outcome model. |
sigma2 |
The residual standard deviation of exposure-mediator model. |
gamma0 |
The coefficient of intercept of exposure-mediator model. |
gamma1 |
The coefficient of exposure of exposure-mediator model. |
gamma2 |
The coefficient vector of confounders of exposure-mediator model. |
a |
The value of exposure (0/1). |
c |
The values of confounders. |
Value
A list of derivatives of beta, gamma and sigma2^2.
Fit a semi-parametric shape-restricted fixed effect regression spline (convexity).
Description
Fit a semi-parametric shape-restricted fixed effect regression spline (convexity).
Usage
cSplineFER(
lmFormula,
dataset,
varName,
knotType = 2,
preKnot = NULL,
nBasis = 5,
convex = TRUE
)
Arguments
lmFormula |
A linear model formula. |
dataset |
A data frame. |
varName |
The name of the main effect. |
knotType |
The knot type: 1=equal-spaced, 2=quantile, 3=pre-specified. |
preKnot |
The pre-specified knots. |
nBasis |
The number of bases. |
convex |
Convex shape or Concave shape: T=Convex, F=Concave |
Value
A list of knots, data set, lm model, summary of lm model, coefficient estimates of bases, covariance of coefficient estimates of bases, combined coefficient estimates, test statistic.
Generate C-Spline Basis
Description
Generate C-Spline Basis
Usage
cSplineGen(
dataset,
varName,
knotType = 1,
preKnot = NULL,
nBasis = 5,
plot = FALSE
)
Arguments
dataset |
A data frame. |
varName |
The name of the main effect. |
knotType |
The knot type: 1=equal-spaced, 2=quantile, 3=pre-specified. |
preKnot |
The pre-specified knots. |
nBasis |
The number of bases. |
plot |
Plot the basis function or not: T=yes, F=no. |
Value
A list of knots, bases, data set.
Fit a semi-parametric shape-restricted mixed effects regression spline (convexity).
Description
Fit a semi-parametric shape-restricted mixed effects regression spline (convexity).
Usage
cSplineMER(
lmmFormula,
dataset,
varName,
knotType = 2,
preKnot = NULL,
nBasis = 5,
convex = TRUE
)
Arguments
lmmFormula |
A linear mixed effect model formula. |
dataset |
A data frame. |
varName |
The name of the main effect. |
knotType |
The knot type: 1=equal-spaced, 2=quantile, 3=pre-specified. |
preKnot |
The pre-specified knots. |
nBasis |
The number of bases. |
convex |
Convex shape or Concave shape: T=Convex, F=Concave |
Value
A list of knots, data set, lmm model, summary of lmm model, coefficient estimates of bases, covariance of coefficient estimates of bases, combined coefficient estimates, test statistic.
Calculate the predicted value of a fixed effect regression spline (convexity).
Description
Calculate the predicted value of a fixed effect regression spline (convexity).
Usage
cSplinePred(t, theta, m)
Arguments
t |
The knot sequence vector in exposure-outcome model. |
theta |
The coefficient vector of C-spline bases in exposure-outcome model. |
m |
The mediator value within min(t) and max(t). |
Value
The predicted value of a fixed effect regression spline.
Calculate the derivatives of coefficients of a fixed effect regression spline (convexity).
Description
Calculate the derivatives of coefficients of a fixed effect regression spline (convexity).
Usage
cSplinePredDeriv(t, theta, m)
Arguments
t |
The knot sequence vector in exposure-outcome model. |
theta |
The coefficient vector of C-spline bases in exposure-outcome model. |
m |
The mediator value within min(t) and max(t). |
Value
The derivatives of beta.
Simulated dataset for SRMERS FERS example
Description
Simulated dataset for SRMERS FERS example
Usage
data(data.sim.fixed)
Format
A dataframe with 245 rows and 14 variables
- hormone
continuous variable (main x)
- age
continuous variable (confounder x)
- invwt
continuous variable (confounder x)
- race2
binary variable (confounder x)
- race3
binary variable (confounder x)
- race4
binary variable (confounder x)
- race5
binary variable (confounder x)
- season2
binary variable (confounder x)
- season3
binary variable (confounder x)
- season4
binary variable (confounder x)
- smoking1
binary variable (confounder x)
- ovum1
binary variable (confounder x)
- diabetes1
binary variable (confounder x)
- ySim
continuous varible (y)
Simulated dataset for SRMERS FERSInt example
Description
Simulated dataset for SRMERS FERSInt example
Usage
data(data.sim.fixed.int)
Format
A dataframe with 500 rows and 15 variables
- hormone
continuous variable (mediator)
- age
continuous variable (confounder x)
- invwt
continuous variable (confounder x)
- race2
binary variable (confounder x)
- race3
binary variable (confounder x)
- race4
binary variable (confounder x)
- race5
binary variable (confounder x)
- season2
binary variable (confounder x)
- season3
binary variable (confounder x)
- season4
binary variable (confounder x)
- smoking1
binary variable (confounder x)
- ovum1
binary variable (confounder x)
- diabetes1
binary variable (confounder x)
- pesticide1
binary variable (exposure)
- ySim
continuous varible (y)
Simulated dataset for SRMERS SRSplineMed, LRMed, LRMed2 example
Description
Simulated dataset for SRMERS SRSplineMed, LRMed, LRMed2 example
Usage
data(data.sim.med)
Format
A dataframe with 500 rows and 16 variables
- hormone
continuous variable (mediator)
- age
continuous variable (confounder x)
- invwt
continuous variable (confounder x)
- race2
binary variable (confounder x)
- race3
binary variable (confounder x)
- race4
binary variable (confounder x)
- race5
binary variable (confounder x)
- season2
binary variable (confounder x)
- season3
binary variable (confounder x)
- season4
binary variable (confounder x)
- smoking1
binary variable (confounder x)
- ovum1
binary variable (confounder x)
- diabetes1
binary variable (confounder x)
- pesticide1
binary variable (exposure)
- ySim
continuous varible (y)
- pesticideCont
continuous variable (exposure)
Simulated dataset for SRMERS MERS example
Description
Simulated dataset for SRMERS MERS example
Usage
data(data.sim.mixed)
Format
A dataframe with 245 rows and 15 variables
- cluster
categorical variable (random factor)
- hormone
continuous variable (main x)
- age
continuous variable (confounder x)
- invwt
continuous variable (confounder x)
- race2
binary variable (confounder x)
- race3
binary variable (confounder x)
- race4
binary variable (confounder x)
- race5
binary variable (confounder x)
- season2
binary variable (confounder x)
- season3
binary variable (confounder x)
- season4
binary variable (confounder x)
- smoking1
binary variable (confounder x)
- ovum1
binary variable (confounder x)
- diabetes1
binary variable (confounder x)
- ySim
continuous varible (y)
Asymptotic null distribution of the test statistic
Description
Asymptotic null distribution of the test statistic
Usage
distributionAsymp(
nIter,
nBasis,
sigmai = NULL,
sigmac = NULL,
testStatIncr = NULL,
testStatDecr = NULL,
testStatConv = NULL,
testStatConc = NULL
)
Arguments
nIter |
The number of iterations. |
nBasis |
The number of bases. |
sigmai |
The covariance matrix of coefficient estimates of I-Spline bases (monotonicity) |
sigmac |
The covariance matrix of coefficient estimates of C-Spline bases (convexity) |
testStatIncr |
The test statistic generated from iSplineFER/iSpineMER |
testStatDecr |
The test statistic generated from iSplineFER/iSpineMER |
testStatConv |
The test statistic generated from cSplineFER/cSpineMER |
testStatConc |
The test statistic generated from cSplineFER/cSpineMER |
Value
A list of weights of beta distribution and p-values.
Bootstrap a null distribution of the test statistic for fixed effect model
Description
Bootstrap a null distribution of the test statistic for fixed effect model
Usage
distributionBootFER(
nBoot,
seed,
parametric = TRUE,
FERSObject1,
FERSObject2,
splineRule,
lmFormula,
varName,
knotType = 1,
nBasis = 5,
increasing = TRUE,
convex = TRUE,
testStat = NULL
)
Arguments
nBoot |
The number of bootstrap iterations. |
seed |
The seed. |
parametric |
The method of noise bootstrap: T=resample from estimated noise, F=resample from normal |
FERSObject1 |
The lm model under null distribution. |
FERSObject2 |
The lm model fitted using iSplineFER or cSplineFER |
splineRule |
iSplineFER or cSplineFER |
lmFormula |
A linear model formula (same as lmFormula in iSplineFER or cSplineFER). |
varName |
The name of the main effect (same as varName in iSplineFER or cSplineFER). |
knotType |
The knot type: 1=equal-spaced and 2=quantile (same as knotType in iSplineFER or cSplineFER). |
nBasis |
The number of bases (same as nBasis in iSplineFER or cSplineFER). |
increasing |
Increasing shape or Decreasing shape: T=Increasing, F=Decreasing |
convex |
Convex shape or Concave shape: T=Convex, F=Concave |
testStat |
The test statistic generated from iSplineFER or cSplineFER |
Value
A list of null distribution of test statistic and p value.
Bootstrap a null distribution of the test statistic for mixed effect model
Description
Bootstrap a null distribution of the test statistic for mixed effect model
Usage
distributionBootMER(
nBoot,
seed,
parametric = TRUE,
MERSObject1,
MERSObject2,
randomFormula,
splineRule,
lmmFormula,
varName,
knotType = 1,
nBasis = 5,
increasing = TRUE,
convex = TRUE,
testStat = NULL
)
Arguments
nBoot |
The number of bootstrap iterations. |
seed |
The seed. |
parametric |
The method of blup and noise bootstrap: T=resample from estimated blup and noise, F=resample from normal |
MERSObject1 |
The lmm model under null distribution. |
MERSObject2 |
The lmm model fitted using iSplineMER or cSplineMER |
randomFormula |
The formula used to generate random effect matrix (in the form of ~random+0) |
splineRule |
iSplineMER or cSplineMER |
lmmFormula |
A linear mixed effect model formula (same as lmmFormula in iSplineMER or cSplineFMER). |
varName |
The name of the main effect (same as varName in iSplineMER or cSplineMER). |
knotType |
The knot type: 1=equal-spaced and 2=quantile (same as knotType in iSplineMER or cSplineMER). |
nBasis |
The number of bases (same as nBasis in iSplineMER or cSplineMER). |
increasing |
Increasing shape or Decreasing shape: T=Increasing, F=Decreasing |
convex |
Convex shape or Concave shape: T=Convex, F=Concave |
testStat |
The test statistic generated from iSplineMER or cSplineMER |
Value
A list of null distribution of test statistic and p value.
Calculate the expectation of a fixed effect regression spline (monotonicity).
Description
Calculate the expectation of a fixed effect regression spline (monotonicity).
Usage
iSplineExp(t, theta, sigma2, gamma0, gamma1, gamma2, a, c)
Arguments
t |
The knot sequence vector in exposure-outcome model. |
theta |
The coefficient vector of I-spline bases in exposure-outcome model. |
sigma2 |
The residual standard deviation of exposure-mediator model. |
gamma0 |
The coefficient of intercept of exposure-mediator model. |
gamma1 |
The coefficient of exposure of exposure-mediator model. |
gamma2 |
The coefficient vector of confounders of exposure-mediator model. |
a |
The value of exposure (0/1). |
c |
The values of confounders. |
Value
The expectation of a fixed effect regression spline.
Calculate the derivatives of coefficients of a fixed effect regression spline (monotonicity).
Description
Calculate the derivatives of coefficients of a fixed effect regression spline (monotonicity).
Usage
iSplineExpDeriv(t, theta, sigma2, gamma0, gamma1, gamma2, a, c)
Arguments
t |
The knot sequence vector in exposure-outcome model. |
theta |
The coefficient vector of I-spline bases in exposure-outcome model. |
sigma2 |
The residual standard deviation of exposure-mediator model. |
gamma0 |
The coefficient of intercept of exposure-mediator model. |
gamma1 |
The coefficient of exposure of exposure-mediator model. |
gamma2 |
The coefficient vector of confounders of exposure-mediator model. |
a |
The value of exposure (0/1). |
c |
The values of confounders. |
Value
A list of derivatives of beta, gamma and sigma2^2.
Fit a semi-parametric shape-restricted fixed effect regression spline (monotonicity).
Description
Fit a semi-parametric shape-restricted fixed effect regression spline (monotonicity).
Usage
iSplineFER(
lmFormula,
dataset,
varName,
knotType = 2,
preKnot = NULL,
nBasis = 5,
increasing = TRUE
)
Arguments
lmFormula |
A linear model formula. |
dataset |
A data frame. |
varName |
The name of the main effect. |
knotType |
The knot type: 1=equal-spaced, 2=quantile, 3=pre-specified. |
preKnot |
The pre-specified knots. |
nBasis |
The number of bases. |
increasing |
Increasing shape or Decreasing shape: T=Increasing, F=Decreasing |
Value
A list of knots, data set, lm model, summary of lm model, coefficient estimates of bases, covariance of coefficient estimates of bases, combined coefficient estimates, test statistic.
Generate I-Spline Basis
Description
Generate I-Spline Basis
Usage
iSplineGen(
dataset,
varName,
knotType = 1,
preKnot = NULL,
nBasis = 5,
plot = FALSE
)
Arguments
dataset |
A data frame. |
varName |
The name of the main effect. |
knotType |
The knot type: 1=equal-spaced, 2=quantile, 3=pre-specified. |
preKnot |
The pre-specified knots. |
nBasis |
The number of bases. |
plot |
Plot the basis function or not: T=yes, F=no. |
Value
A list of knots, bases, data set.
Fit a semi-parametric shape-restricted mixed effects regression spline (monotonicity).
Description
Fit a semi-parametric shape-restricted mixed effects regression spline (monotonicity).
Usage
iSplineMER(
lmmFormula,
dataset,
varName,
knotType = 2,
preKnot = NULL,
nBasis = 5,
increasing = TRUE
)
Arguments
lmmFormula |
A linear mixed effect model formula. |
dataset |
A data frame. |
varName |
The name of the main effect. |
knotType |
The knot type: 1=equal-spaced, 2=quantile, 3=pre-specified. |
preKnot |
The pre-specified knots. |
nBasis |
The number of bases. |
increasing |
Increasing shape or Decreasing shape: T=Increasing, F=Decreasing |
Value
A list of knots, data set, lmm model, summary of lmm model, coefficient estimates of bases, covariance of coefficient estimates of bases, combined coefficient estimates, test statistic.
Calculate the predicted value of a fixed effect regression spline (monotonicity).
Description
Calculate the predicted value of a fixed effect regression spline (monotonicity).
Usage
iSplinePred(t, theta, m)
Arguments
t |
The knot sequence vector in exposure-outcome model. |
theta |
The coefficient vector of I-spline bases in exposure-outcome model. |
m |
The mediator value within min(t) and max(t). |
Value
The predicted value of a fixed effect regression spline.
Calculate the derivatives of coefficients of a fixed effect regression spline (monotonicity).
Description
Calculate the derivatives of coefficients of a fixed effect regression spline (monotonicity).
Usage
iSplinePredDeriv(t, theta, m)
Arguments
t |
The knot sequence vector in exposure-outcome model. |
theta |
The coefficient vector of I-spline bases in exposure-outcome model. |
m |
The mediator value within min(t) and max(t). |
Value
The derivatives of beta.
Generate y using existed X, coefficients of X, variance of random effect and variance of noise
Description
Generate y using existed X, coefficients of X, variance of random effect and variance of noise
Usage
ySimGen(
dataset,
seed,
coefVec,
fixMat,
randomVar = NULL,
randomSD = NULL,
noiseSD
)
Arguments
dataset |
A data frame. |
seed |
The seed. |
coefVec |
The coefficient vector of the fixed effect matrix. |
fixMat |
The fixed effect matrix. |
randomVar |
The random effect variable in the data set. |
randomSD |
The SD of random effect. |
noiseSD |
The SD of noise. |
Value
A data set with generated y.