--- title: "SRMERS-intro" author: "Qing Yin" output: rmarkdown::html_vignette vignette: > %\VignetteIndexEntry{SRMERS-intro} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- ```{r, include = FALSE} knitr::opts_chunk$set( collapse = TRUE, comment = "#>" ) ``` This R package is designed to perform the shape detection and mediation analysis using semi-parametric shape-restricted regression spline. For the shape detection, the method can help researchers select the most suitable shape to describe their data among increasing, decreasing, convex, or concave shapes. For the mediation analysis, the method can help researchers analytically estimate the direct and indirect effects when they have some prior knowledge on the relationship between the mediator and the outcome (increasing, decreasing, convex, or concave), while the exposure is assumed to be binary (exposed or non-exposed). Before conducting the analysis, please follow the following suggestions regarding your data set: (1) the data set should be complete, (2) you can use the function model.matrix() to transform factors into dummy variables, and (3) you can use the function data.frame() to make the data set into a data frame. In the examples below, please adjust arguments to match your final function interfaces. ```{r setup} library(SRMERS) ``` ```{r, eval = F} # shape detection under the fixed effect model 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 = 1000) # shape detection under the mixed effects model 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 = 1000) # mediation analysis 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) # mediation analysis using linear regressions (binary exposure) 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) # mediation analysis using linear regressions (continuous exposure) medModel <- LRMed2(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, eValueLow = 0.1, eValueHigh = 1.1) ```