Package 'SRMERS'

Title: Semi-Parametric Shape-Restricted Fixed/Mixed Effect(s) Regression Spline
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)).
Authors: Qing Yin [aut, cre], Shyamal Das Peddada [aut], Jennifer Joan Adibi [aut], Jong-Hyeon Jeong [aut]
Maintainer: Qing Yin <[email protected]>
License: GPL-3
Version: 0.1.1
Built: 2026-05-14 06:45:11 UTC
Source: https://github.com/cran/SRMERS

Help Index


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)


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

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