Title: | Non-Parametric Models for Longitudinal Data Analysis |
---|---|
Description: | Support the book: Wu CO and Tian X (2018). Nonparametric Models for Longitudinal Data: With Implementation in R. (Chapman & Hall/CRC Monographs on Statistics & Applied Probability); Present global and local smoothing methods for the conditional-mean and conditional-distribution based nonparametric models with longitudinal Data. |
Authors: | Xin Tian, Colin Wu |
Maintainer: | Xin Tian <[email protected]> |
License: | GPL (>= 2) |
Version: | 1.2.0 |
Built: | 2025-02-16 04:00:47 UTC |
Source: | https://github.com/npmldabook/npmlda |
This dataset includes 557 depressed patients (total 7117 observations) in the cognitive behavior therapy arm in the Enhancing Recovery in Coronary Heart Disease Patients (ENRICHD) study.
data(BDIdata)
data(BDIdata)
A data frame with 7117 rows and 5 variables.
ID. Subject ID
time. Study visit time (in days) since randomization
BDI. Beck Depression Inventory (BDI) score
med. Antidepressant medication use
med.time. The starting time of medication
Wu, C. O., Tian, X. and Bang, H. A varying-coefficient model for the evaluation of time-varying concomitant intervention effects in longitudinal studies. Statistics in Medicine, 27:3042-3056, 2008.
Wu, C. O., Tian, X. and Jiang, W. A shared parameter model for the estimation of longitudinal concomitant intervention effects. Biostatistics, 12(4):737-749, 2011.
This dataset is from the Baltimore site of the Multi-center AIDS Cohort Study (BMACS), which included 400 homosexual men who were infected by the human immunodeficiency virus (HIV) between 1984 and 1991.
data(BMACS)
data(BMACS)
A data frame with 1817 rows and 6 variables.
ID. Subject ID
Time. Subject's study visit time
Smoke. Cigarette baseline smoking status
age. Age at study enrollment
preCD4. Pre-infection CD4 percentage
CD4. CD4 percentage at the time of visit
Kaslow, R. A., Ostrow, D. G., Detels, R., Phair, J. P., Polk, B. F. and Rinaldo, C. R. The Multicenter AIDS Cohort Study: rationale, organization and selected characteristics of the participants. American Journal of Epidemiology, 126:310-318, 1987.
Leave one-subject out Cross-validation score for local linear fit
CVlm(Xvec, Yvec, bw, ID, Wt)
CVlm(Xvec, Yvec, bw, ID, Wt)
Xvec , Yvec
|
numeric vectors of data values, Xvec and Yvec must have the same length. |
bw |
a bandwidth of the Epanechnikov kernel |
ID |
subject ID of the data value |
Wt |
a weight vector, may be subject-specific. a weight vector or a constant. For longitudinal data, Wt=1/N corresponds to measurement uniform weight and Wt=1/(nni) corresponds subject uniform weight. |
Leave one-subject out Cross-validation score for spline fit
CVspline(Xvec, Yvec, ID, nKnots, Degree, Wt)
CVspline(Xvec, Yvec, ID, nKnots, Degree, Wt)
Xvec , Yvec
|
numeric vectors of data values, Xvec and Yvec must have the same length. |
ID |
subject ID of the data value |
nKnots |
number of equally-spaced knots |
Degree |
degree of polynomial splines |
Wt |
a weight vector. For longitudinal data, Wt=1/N corresponds to measurement uniform weight and Wt=1/(nni) corresponds subject uniform weight. |
Wu, C.O. and Tian, X. Nonparametric Models for Longitudinal Data: With Implementation in R. Chapman & Hall/CRC. 2018.
Derivative of the function Xi(s)
DXi(s)
DXi(s)
s |
a number or a vector |
value of the function DXi with give s
DXi(c(-1000, -10,-5, 0, 5,10, 1000 ))
DXi(c(-1000, -10,-5, 0, 5,10, 1000 ))
This dataset consists of 20 patients with hematologicmalignancies who had allogeneic hematopoietic stem cell transplantation (HSCT) between 2006 and 2009 at the National Institutes of Health (NIH). The variables are as follows:
data(HSCT)
data(HSCT)
A data frame with 271 rows and 8 variables.
ID. Subject ID
Days. Subject's study visit time relative to time of transplant (day 0)
Granu. Granulocytes (K/uL)
LYM. Lymphocytes (K/uL)
MON. Monocytes (K/uL)
G-CSF. Granulocyte colony-stimulating factor level (pg/mL)
IL-15. IL-15 level (pg/mL)
MCP-1. monocyte chemotactic protein-1 level (pg/mL)
Melenhorst, J.J., Tian, X., Xu, D., Sandler, N.G., Scheinberg, P., Biancotto, A., et al. Cytopenia and leukocyte recovery shape cytokine fluctuations after myeloablative allogeneic hematopoietic stem cell transplantation. Haematologica, 97(6):867-73, 2012.
Nadaraya-Watson Kernel estimator
kernel.fit(Xint, Xvec, Yvec, bw, Kernel = "Ep", Wt = 1)
kernel.fit(Xint, Xvec, Yvec, bw, Kernel = "Ep", Wt = 1)
Xint |
a vector of x interval to generate the local linear fit |
Xvec , Yvec
|
numeric vectors of data values, Xvec and Yvec must have the same length. |
bw |
a bandwidth of the kernel |
Kernel |
a character string indicating which kernel function is to be used. Use of "Ep", "Bw", or "Nm" for Epanechnikov, Biweight or Normal kernel function. |
Wt |
a weight vector |
Fan, J. and Gijbels, I. Local Polynomial Modeling and Its Applications. Chapman & Hall, London, United Kingdom, 1996.
Wu, C.O. and Tian, X. Nonparametric Models for Longitudinal Data: With Implementation in R. Chapman & Hall/CRC. 2018
X <- seq(0, 1, len=100) Y <- (X- 0.5)^3 - 2*(X-0.5)^2+ rnorm(100, 0, 0.1) kernel.fit(seq(0,1,0.1), X, Y, Kernel="Ep", bw=0.1, Wt=1 )
X <- seq(0, 1, len=100) Y <- (X- 0.5)^3 - 2*(X-0.5)^2+ rnorm(100, 0, 0.1) kernel.fit(seq(0,1,0.1), X, Y, Kernel="Ep", bw=0.1, Wt=1 )
2-dim Kernel function for longitudinal data
Kernel2D(IDls, Xvec, Yvec, X01, X02, Bndwdth1, Bndwdth2)
Kernel2D(IDls, Xvec, Yvec, X01, X02, Bndwdth1, Bndwdth2)
IDls |
the vector of subject ID in a longitudinal sample |
Xvec |
Yvec numeric vectors of data values, Xvec and Yvec must have the same length |
X01 |
X02 two given values of Xvec |
Bndwdth1 , Bndwdth2
|
two given bandwidths |
2-dim kernel fit result
Wu, C.O. and Tian, X. Nonparametric Models for Longitudinal Data: With Implementation in R. Chapman & Hall/CRC. 2018.
3-dim Kernel function for longitudinal data to get Pr(y1(t1),y2(t2)|x(t1))
Kernel3D(IDls = ID, Y, Time, X, T1, T2, X0, Bndwdth1, Bndwdth2, Bndwdth3)
Kernel3D(IDls = ID, Y, Time, X, T1, T2, X0, Bndwdth1, Bndwdth2, Bndwdth3)
IDls |
the vector of subject ID in a longitudinal sample |
Y , X , Time
|
numeric vectors of outcome, covariate and time of the the same length |
T1 , T2
|
twp given time points |
X0 |
a given covariate value |
Bndwdth1 , Bndwdth2 , Bndwdth3
|
three bandwidths around two time and one covariate value |
3-dim Kernel function results
Wu, C.O. and Tian, X. Nonparametric Models for Longitudinal Data: With Implementation in R. Chapman & Hall/CRC. 2018.
3-dim Kernel function for longitudinal data to get Pr(y2(t2)|x(t1))
Kernel3D.S2(IDls = ID, Y, Time, X, T1, T2, X0, Bndwdth1, Bndwdth2, Bndwdth3)
Kernel3D.S2(IDls = ID, Y, Time, X, T1, T2, X0, Bndwdth1, Bndwdth2, Bndwdth3)
IDls |
the vector of subject ID in a longitudinal sample |
Y , X , Time
|
numeric vectors of outcome, covariate and time of the the same length |
T1 , T2
|
twp given time points |
X0 |
a given covariate value |
Bndwdth1 , Bndwdth2 , Bndwdth3
|
three bandwidths around two time and one covariate value |
3-dim Kernel function results
Wu, C.O. and Tian, X. Nonparametric Models for Longitudinal Data: With Implementation in R. Chapman & Hall/CRC. 2018.
Biweight kernel
Kh.Bw(datavec, Bndwdth)
Kh.Bw(datavec, Bndwdth)
datavec |
a numeric vector |
Bndwdth |
a bandwidth of the kernel |
kernel function result
# same usage as Kh.Ep
# same usage as Kh.Ep
Epanechnikov Kernel
Kh.Ep(datavec, Bndwdth)
Kh.Ep(datavec, Bndwdth)
datavec |
a numeric vector |
Bndwdth |
a bandwidth |
kernel function result
Kh.Ep(2:7,5)
Kh.Ep(2:7,5)
Normal kernel
Kh.Nm(datavec, Bndwdth)
Kh.Nm(datavec, Bndwdth)
datavec |
a numeric vector |
Bndwdth |
a bandwidth of the kernel |
kernel function result
Kh.Nm(2:7,5)
Kh.Nm(2:7,5)
Multiplicative Epanechnikov Kernel (2-dim)
Kh2D(datavec1, datavec2, Bndwdth1, Bndwdth2)
Kh2D(datavec1, datavec2, Bndwdth1, Bndwdth2)
datavec1 |
datavec2 two numeric vectors of same length |
Bndwdth1 |
Bndwdth2 two bandwidths for two vectors |
2-dim kernel function result
Kh2D(2:7, 2:7, 5, 5)
Kh2D(2:7, 2:7, 5, 5)
Multiplicative Epanechnikov Kernel (3-dim)
Kh3D(datavec1, datavec2, datavec3, Bndwdth1, Bndwdth2, Bndwdth3)
Kh3D(datavec1, datavec2, datavec3, Bndwdth1, Bndwdth2, Bndwdth3)
datavec1 |
datavec2, datavec3 three numeric vectors of same length |
Bndwdth1 |
Bndwdth2, Bndwdth3 three bandwidths for three vectors |
3-dim kernel function result
Local linear fit with Epanechnikov kernel
LocalLm(Xint, Xvec, Yvec, bw, Wt = 1)
LocalLm(Xint, Xvec, Yvec, bw, Wt = 1)
Xint |
a vector of x interval to generate the local linear fit |
Xvec , Yvec
|
numeric vectors of data values, Xvec and Yvec must have the same length. |
bw |
a bandwidth of the kernel |
Wt |
a weight vector |
data(BMACS) Time.int<- seq(0.1,5.9, by=0.1) LocalFit.Y <- with(BMACS, LocalLm(Time.int, Time, CD4, bw=0.9, Wt=1))
data(BMACS) Time.int<- seq(0.1,5.9, by=0.1) LocalFit.Y <- with(BMACS, LocalLm(Time.int, Time, CD4, bw=0.9, Wt=1))
Least square local linear fit
LocalLm.Beta(Tint, Tvec, X1, X2, X3, Yvec, Bndwdth, Weight)
LocalLm.Beta(Tint, Tvec, X1, X2, X3, Yvec, Bndwdth, Weight)
Tint |
a time interval |
Tvec , Yvec
|
numeric vectors of time and outcome values, Tvec and Yvec must have the same length. |
X1 , X2 , X3
|
three covariate vectors |
Bndwdth |
a bandwidth of the Epanechnikov kernel |
Weight |
the weight vector |
Wu, C.O. and Tian, X. Nonparametric Models for Longitudinal Data: With Implementation in R. Chapman & Hall/CRC. 2018.
data(NGHS) NGHS$Black <- (NGHS$RACE==2)*1 NGHS<- NGHS[!is.na(NGHS$SBP) & !is.na(NGHS$BMIPCT) & !is.na(NGHS$HTPCT ),] Ct <- data.frame(table(NGHS$ID)) names(Ct)<- c('ID', 'ni') NGHS<- merge(NGHS, Ct, by= 'ID') nID<- dim(Ct)[1] Age.grid <- seq(9, 19, by=0.5) #21 NGHS$HTPCTc<- NGHS$HTPCT-50 NGHS$BMIPCTc<- NGHS$BMIPCT-50 Beta <- with(NGHS, LocalLm.Beta(Age.grid, AGE, X1=Black, X2=HTPCTc, X3=BMIPCTc, SBP, Bndwdth=3.5, Weight=1/ni))
data(NGHS) NGHS$Black <- (NGHS$RACE==2)*1 NGHS<- NGHS[!is.na(NGHS$SBP) & !is.na(NGHS$BMIPCT) & !is.na(NGHS$HTPCT ),] Ct <- data.frame(table(NGHS$ID)) names(Ct)<- c('ID', 'ni') NGHS<- merge(NGHS, Ct, by= 'ID') nID<- dim(Ct)[1] Age.grid <- seq(9, 19, by=0.5) #21 NGHS$HTPCTc<- NGHS$HTPCT-50 NGHS$BMIPCTc<- NGHS$BMIPCT-50 Beta <- with(NGHS, LocalLm.Beta(Age.grid, AGE, X1=Black, X2=HTPCTc, X3=BMIPCTc, SBP, Bndwdth=3.5, Weight=1/ni))
Least square local linear fit at t0
LocalLm.Beta.t0(t0, Tvec, X1, X2, X3, Yvec, Bndwdth, Weight)
LocalLm.Beta.t0(t0, Tvec, X1, X2, X3, Yvec, Bndwdth, Weight)
t0 |
a given time point |
Tvec , Yvec
|
numeric vectors of time and outcome values, Tvec and Yvec must have the same length. |
X1 , X2 , X3
|
three covariate vectors |
Bndwdth |
a bandwidth of the Epanechnikov kernel |
Weight |
the weight vector |
Wu, C.O. and Tian, X. Nonparametric Models for Longitudinal Data: With Implementation in R. Chapman & Hall/CRC. 2018.
# see usage of LocalLm.Beta
# see usage of LocalLm.Beta
Local linear fit at X0 with Epanechnikov kernel
LocalLm.X0(Xvec, Yvec, X0, Bndwdth, Wt = 1)
LocalLm.X0(Xvec, Yvec, X0, Bndwdth, Wt = 1)
Xvec , Yvec
|
numeric vectors of data values, Xvec and Yvec must have the same length. |
X0 |
a given value |
Bndwdth |
a bandwidth of the kernel |
Wt |
a weight vector or a constant. For longitudinal data, Wt=1/N corresponds to measurement uniform weight and Wt=1/(nni) corresponds subject uniform weight. |
# see usage of LocalLm
# see usage of LocalLm
An equation solver with Newton's method with 1 variable
Newton1var(Z12vec, h0, Vh, HZB, Ind.Y, Diff = 1e-08, ORR, MaxIter = 100)
Newton1var(Z12vec, h0, Vh, HZB, Ind.Y, Diff = 1e-08, ORR, MaxIter = 100)
Z12vec |
2-dim covariate vector |
h0 , Vh , HZB
|
inital values |
Ind.Y |
outcome inidicator |
Diff |
limit to stop the interations |
ORR |
estimate of the odds ratio vector |
MaxIter |
maximum no. of interations |
The root of the equation
Wu, C.O. and Tian, X. Nonparametric Models for Longitudinal Data: With Implementation in R. Chapman & Hall/CRC. 2018.
An equation solver with Newton's method with 2 variables
Newton2var(Zij, b0, Ub, Indicator, difflmt = 1e-14, MaxIter = 100)
Newton2var(Zij, b0, Ub, Indicator, difflmt = 1e-14, MaxIter = 100)
Zij |
2-dim covariate vector |
b0 , Ub
|
inital values |
Indicator |
Indicator of Yi1> Yi2 |
difflmt |
limit to stop the interations |
MaxIter |
maximum no. of interations |
The root of the equation
Wu, C.O. and Tian, X. Nonparametric Models for Longitudinal Data: With Implementation in R. Chapman & Hall/CRC. 2018.
This dataset includes 2378 girls (total 19701 observations) enrolled in the National Heart, Lung, and Blood Institute's Growth and Health Study (NGHS). NGHS is a multicenter population-based cohort study aimed at evaluating the racial differences and longitudinal changes in childhood cardiovascular risk factors between Caucasian and African American girls during childhood and adolescence.
data(NGHS)
data(NGHS)
A data frame with 19701 rows and 12 variables.
ID. Subject ID
RACE. Subject's race (1=Caucasian, 2= African American)
AGE,HEIGHT,WEIGHT,BMI. Age, height, weight and BMI at study visit
BMIPCT, HTPCT. CDC Age-adjusted BMI percentile and height percentile at study visit
SBP,DBP. Systolic and diastolic blood pressure at study visit
TG,LDL. Triglyceride and Low-density lipoprotein (LDL) cholesterol at study visit
National Heart, Lung, and Blood Institute Growth and Health Research Group (NGHSRG). Obesity and cardiovascular disease risk factors in black and white girls: the NHLBI Growth and Health Study. American Journal of Public Health, 82:1613-1620, 1992.
Wu, C. O. and Tian, X. Nonparametric estimation of conditional distributions and rank-tracking probabilities with time-varying transformation models in longitudinal studies. Journal of the American Statistical Association, 108:971-982, 2013.
Title Nadaraya-Watson Kernel estimator at x0
NW.Kernel(Xvec, Yvec, X0, Kernel = "Ep", Bndwdth, Wt = 1)
NW.Kernel(Xvec, Yvec, X0, Kernel = "Ep", Bndwdth, Wt = 1)
Xvec , Yvec
|
numeric vectors of data values, Xvec and Yvec must have the same length. |
X0 |
a given value |
Kernel |
a character string indicating which kernel function is to be used. Use of "Ep", "Bw", or "Nm" for Epanechnikov, Biweight or Normal kernel function. |
Bndwdth |
a bandwidth of the kernel |
Wt |
a weight vector or a constant. For longitudinal data, Wt=1/N corresponds to measurement uniform weight and Wt=1/(nni) corresponds subject uniform weight. |
The kernel estimator at x0
Fan, J. and Gijbels, I. Local Polynomial Modeling and Its Applications. Chapman & Hall, London, United Kingdom, 1996.
Wu, C.O. and Tian, X. Nonparametric Models for Longitudinal Data. Chapman & Hall/CRC. To appear.
X <- seq(0, 1, len=100) Y <- (X- 0.5)^3 - 2*(X-0.5)^2+ rnorm(100, 0, 0.1) NW.WtKernel(X, Y, X0=0.5, Kernel="Ep", Bndwdth=0.3, Wt=1 ) NW.WtKernel(X, Y, X0=0.5, Kernel="Nm", Bndwdth=0.3, Wt=1 )
X <- seq(0, 1, len=100) Y <- (X- 0.5)^3 - 2*(X-0.5)^2+ rnorm(100, 0, 0.1) NW.WtKernel(X, Y, X0=0.5, Kernel="Ep", Bndwdth=0.3, Wt=1 ) NW.WtKernel(X, Y, X0=0.5, Kernel="Nm", Bndwdth=0.3, Wt=1 )
Title Nadaraya-Watson Kernel estimator at x0
NW.WtKernel(Xvec, Yvec, X0, Kernel = "Ep", Bndwdth, Wt = 1)
NW.WtKernel(Xvec, Yvec, X0, Kernel = "Ep", Bndwdth, Wt = 1)
Xvec , Yvec
|
numeric vectors of data values, Xvec and Yvec must have the same length. |
X0 |
a given value |
Kernel |
a character string indicating which kernel function is to be used. Use of "Ep", "Bw", or "Nm" for Epanechnikov, Biweight or Normal kernel function. |
Bndwdth |
a bandwidth of the kernel |
Wt |
a weight vector or a constant. For longitudinal data, Wt=1/N corresponds to measurement uniform weight and Wt=1/(nni) corresponds subject uniform weight. |
The kernel estimator at x0
Fan, J. and Gijbels, I. Local Polynomial Modeling and Its Applications. Chapman & Hall, London, United Kingdom, 1996.
Wu, C.O. and Tian, X. Nonparametric Models for Longitudinal Data: With Implementation in R. Chapman & Hall/CRC. 2018
X <- seq(0, 1, len=100) Y <- (X- 0.5)^3 - 2*(X-0.5)^2+ rnorm(100, 0, 0.1) NW.WtKernel(X, Y, X0=0.5, Kernel="Ep", Bndwdth=0.3, Wt=1 ) NW.WtKernel(X, Y, X0=0.5, Kernel="Nm", Bndwdth=0.3, Wt=1 )
X <- seq(0, 1, len=100) Y <- (X- 0.5)^3 - 2*(X-0.5)^2+ rnorm(100, 0, 0.1) NW.WtKernel(X, Y, X0=0.5, Kernel="Ep", Bndwdth=0.3, Wt=1 ) NW.WtKernel(X, Y, X0=0.5, Kernel="Nm", Bndwdth=0.3, Wt=1 )
Polynomial-spline fit with equally-spaced knots
spline.fit(Xint, Xvec, Yvec, nKnots = 2, Degree = 3, Wt = 1)
spline.fit(Xint, Xvec, Yvec, nKnots = 2, Degree = 3, Wt = 1)
Xint |
a vector of x interval to generate the local linear fit |
Xvec , Yvec
|
numeric vectors of data values, Xvec and Yvec must have the same length. |
nKnots |
number of equally-spaced knots |
Degree |
degree of polynomial splines |
Wt |
a weight vector or a constant. For longitudinal data, Wt=1/N corresponds to measurement uniform weight and Wt=1/(nni) corresponds subject uniform weight. |
Wu, C.O. and Tian, X. Nonparametric Models for Longitudinal Data: With Implementation in R. Chapman & Hall/CRC. 2018.
Function Xi(s)
Xi(s)
Xi(s)
s |
a number or a vector |
value of the function with give s
Xi(0) Xi(c(-1000, -10,-5, 0, 5,10, 1000 ))
Xi(0) Xi(c(-1000, -10,-5, 0, 5,10, 1000 ))