Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
701d4f3
commit ede799f
Showing
19 changed files
with
243 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,20 @@ | ||
Package: depend.truncation | ||
Type: Package | ||
Title: Statistical Inference for Parametric and Semiparametric Models | ||
Based on Dependently Truncated Data | ||
Version: 2.8 | ||
Date: 2017-08-11 | ||
Title: Statistical Methods for the Analysis of Dependently Truncated | ||
Data | ||
Version: 3.0 | ||
Date: 2018-02-27 | ||
Author: Takeshi Emura | ||
Maintainer: Takeshi Emura <takeshiemura@gmail.com> | ||
Description: Suppose that one can observe bivariate random variables (X, Y) only when X<=Y holds. Data (Xj, Yj), subject to Xj<=Yj, for all j=1,...,n, are called truncated data. For truncated data, several different approaches are implemented for statistical inference on (X, Y), when X and Y are dependent. Also included is truncated data on the number of deaths at each year (1963-1980) for Japanese male centenarians. | ||
Description: Estimation and testing methods for dependently truncated data. | ||
Semi-parametric methods are based on Emura et al. (2011)<Stat Sinica 21:349-67>, Emura & Wang (2012)<doi:10.1016/j.jmva.2012.03.012>, | ||
and Emura & Murotani (2015)<doi:10.1007/s11749-015-0432-8>. | ||
Parametric approaches are based on Emura & Konno (2012)<doi:10.1007/s00362-014-0626-2> and Emura & Pan (2017)<doi:10.1007/s00362-017-0947-z>. | ||
A regression approach is based on Emura & Wang (2016)<doi:10.1007/s10463-015-0526-9>. Quasi-independence tests are based on Emura & Wang (2010)<doi:10.1016/j.jmva.2009.07.006>. | ||
Right-truncated data for Japanese male centenarians are given by Emura & Murotani (2015)<doi:10.1007/s11749-015-0432-8>. | ||
License: GPL-2 | ||
Depends: mvtnorm | ||
NeedsCompilation: no | ||
Packaged: 2017-08-11 10:29:43 UTC; user | ||
Packaged: 2018-02-27 09:46:18 UTC; user | ||
Repository: CRAN | ||
Date/Publication: 2017-08-11 10:30:02 UTC | ||
Date/Publication: 2018-02-27 12:43:41 UTC |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
Logrank.stat=function(x.trunc,z.trunc,d){ | ||
m=length(x.trunc) | ||
#######Lynden-Bell's estimator###### | ||
t=c(x.trunc,z.trunc) ;t.o=t[order(t)] ;d.o=c(rep(0,m),rep(1,m))[order(t)] | ||
dd.o=c(rep(0,m),d)[order(t)] ;r.diag=numeric(2*m) | ||
for(i in 1:(2*m)){ | ||
r.diag[i]=sum( (x.trunc<=t.o[i])&(z.trunc>=t.o[i]) ) | ||
} | ||
sc.diag=cumprod( 1-d.o*(1-dd.o)/r.diag*(r.diag>1) ) | ||
sc=(sc.diag[d.o==1])[rank(z.trunc)] | ||
|
||
#######estimating truncation proportion###### | ||
x.o=sort(x.trunc)[-1] | ||
r.diag=numeric(m-1) | ||
for(i in 1:(m-1)){ | ||
r.diag[i]=sum((x.trunc<=x.o[i])&(z.trunc>=x.o[i])) | ||
} | ||
hat.c=m*prod((1-1/r.diag)[r.diag>1]) | ||
|
||
######summarizing data(making risk set on grids)##### | ||
r.point=sckm.point=r.grid=sckm.grid=0 | ||
for(i in 1:m){ | ||
x=x.trunc[i] ;z=z.trunc[i] | ||
if(d[i]==1){ | ||
r.point=c(r.point,sum((x.trunc<=x)&(z.trunc>=z))) | ||
sckm.point=c(sckm.point,sc[i]) | ||
} | ||
index=(x.trunc<=x)&(z.trunc>x)&(z.trunc<=z)&(d==1) | ||
num=sum(index) | ||
if(num>0){ | ||
r.vec=numeric(num); sckm.vec<-numeric(num) | ||
for(j in 1:num){ | ||
zz=z.trunc[index][j] | ||
r.vec[j]=sum( (x.trunc<=x)&(z.trunc>=zz) ) | ||
sckm.vec[j]=(sc[index])[j] | ||
} | ||
r.grid=c(r.grid,r.vec); sckm.grid=c(sckm.grid,sckm.vec) | ||
} | ||
} | ||
r.point=r.point[-1] ;sckm.point=sckm.point[-1] ;r.grid=r.grid[-1] | ||
sckm.grid=sckm.grid[-1] | ||
|
||
######computing the logrank statistics####### | ||
L0=length(r.point)-sum(1/r.grid) # Logrank stat. rho=0 | ||
L1=sum(r.point/sckm.point)/m-sum(1/sckm.grid)/m # Gehan's stat. rho=1 | ||
Llog=sum(1/log(hat.c*r.point/sckm.point/m))-sum(1/log(hat.c*r.grid/sckm.grid/m)/r.grid) | ||
c(L0,L1,Llog) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
Logrank.stat.tie=function(x.trunc,z.trunc,d){ | ||
m=length(x.trunc) | ||
x.grid=sort(as.numeric(levels(factor(x.trunc)))) | ||
num.x=length(x.grid) | ||
############ truncation proportion ############ | ||
x.min=min(x.trunc) | ||
R1=sum((x.trunc<=x.min)&(z.trunc>=x.min)) | ||
hat.c=m/R1 | ||
for(i in 2:num.x){ | ||
v=x.grid[i] | ||
Nx=sum((x.trunc==v)) | ||
Rx=sum((x.trunc<=v)&(z.trunc>=v)) | ||
if(Rx>1){hat.c=hat.c*(1-Nx/Rx)} | ||
} | ||
|
||
############ Log-rank statistics ############ | ||
L0=0;L1=0;Llog=0 | ||
for(i in 1:num.x){ | ||
xx=x.grid[i] | ||
z.max=max(z.trunc[as.logical((x.trunc==xx))]) | ||
temp.z=(z.trunc>=xx)&(x.trunc<=xx)&(z.trunc<=z.max) | ||
z.grid=as.numeric(levels(factor(z.trunc[temp.z]))) | ||
num.z=length(z.grid) | ||
for(j in 1:num.z){ | ||
zz=z.grid[j] | ||
Sc=1 | ||
z.order=sort( as.numeric(levels(factor(z.trunc))) ) | ||
num.c=sum( z.order<zz ) | ||
if(num.c>0){ | ||
for(k in 1:num.c){ | ||
u=z.order[k] | ||
Nc=sum( (1-d)[(z.trunc==u)] ) | ||
Rc=sum((x.trunc<=u)&(z.trunc>=u)) | ||
if(Rc>1){Sc=Sc*(1-Nc/Rc)} | ||
} | ||
} | ||
n11=sum((x.trunc==xx)&(z.trunc==zz)&(d==1)) | ||
n10=sum((x.trunc==xx)&(z.trunc>=zz)) | ||
n01=sum((x.trunc<=xx)&(z.trunc==zz)&(d==1)) | ||
R=sum((x.trunc<=xx)&(z.trunc>=zz)) | ||
L0=L0+n11-n10*n01/R | ||
hat.v=R/m/Sc | ||
L1=L1+hat.v*(n11-n10*n01/R) | ||
Llog=Llog-1/log(hat.c*hat.v)*(n11-n10*n01/R) | ||
} | ||
} | ||
c(L0,L1,Llog) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
\name{Logrank.stat} | ||
\alias{Logrank.stat} | ||
%- Also NEED an '\alias' for EACH other topic documented here. | ||
\title{ | ||
The weighted log-rank statistics for testing quasi-independence (without ties in data) | ||
} | ||
\description{ | ||
The three log-rank statistics (L_0, L_1, and L_log) corresponding to 3 different weights. | ||
} | ||
\usage{ | ||
Logrank.stat(x.trunc, z.trunc, d) | ||
} | ||
%- maybe also 'usage' for other objects documented here. | ||
\arguments{ | ||
\item{x.trunc}{vector of variables satisfying x.trunc<=z.trunc} | ||
\item{z.trunc}{vector of variables satisfying x.trunc<=z.trunc} | ||
\item{d}{censoring indicator(0=censoring,1=failure) for z.trunc} | ||
} | ||
\details{ | ||
If there is no tie in the data, the function "Logrank.stat.tie" and "Logrank.stat" give identical results. | ||
However, "Logrank.stat" is computationally more efficient. The simulations of Emura & Wang (2010) are | ||
based on "Logrank.stat" since simulated data are generated from continuous distributions. The real data analyses | ||
of Emura & Wang (2010) are based on "Logrank.stat.tie" since there are many ties in the data. | ||
} | ||
\value{ | ||
\item{L0}{Logrank statistics (most powerfull to detect the Clayton copula type dependence)} | ||
\item{L1}{Logrank statistics (most powerfull to detect the Frank copula type dependence)} | ||
\item{Llog}{Logrank statistics (most powerfull to detect the Gumbel copula type dependence)} | ||
} | ||
\references{ | ||
Emura T, Wang W (2010) Testing quasi-independence for truncation data. Journal of Multivariate Analysis 101, 223-239 | ||
} | ||
\author{Takeshi Emura} | ||
|
||
\examples{ | ||
x.trunc=c(10,5,7,1,3,9) | ||
z.trunc=c(12,11,8,6,4,13) | ||
d=c(1,1,1,1,0,1) | ||
Logrank.stat(x.trunc,z.trunc,d) | ||
} | ||
% Add one or more standard keywords, see file 'KEYWORDS' in the | ||
% R documentation directory. | ||
\keyword{ Copula } | ||
\keyword{ Quasi-independence test }% __ONLY ONE__ keyword per line |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
\name{Logrank.stat.tie} | ||
\alias{Logrank.stat.tie} | ||
%- Also NEED an '\alias' for EACH other topic documented here. | ||
\title{ | ||
The weighted log-rank statistics for testing quasi-independence (with ties in data) | ||
} | ||
\description{ | ||
The three log-rank statistics (L_0, L_1, and L_log) corresponding to 3 different weights. | ||
} | ||
\usage{ | ||
Logrank.stat.tie(x.trunc, z.trunc, d) | ||
} | ||
%- maybe also 'usage' for other objects documented here. | ||
\arguments{ | ||
\item{x.trunc}{vector of variables satisfying x.trunc<=z.trunc} | ||
\item{z.trunc}{vector of variables satisfying x.trunc<=z.trunc} | ||
\item{d}{censoring indicator(0=censoring,1=failure) for z.trunc} | ||
} | ||
\details{ | ||
If there is no tie in the data, the function "Logrank.stat.tie" and "Logrank.stat" give identical results. | ||
However, "Logrank.stat" is computationally more efficient. The simulations of Emura & Wang (2010) are | ||
based on "Logrank.stat" since simulated data are generated from continuous distributions. The real data analyses | ||
of Emura & Wang (2010) are based on "Logrank.stat.tie" since there are many ties in the data. | ||
} | ||
\value{ | ||
\item{L0}{Logrank statistics (most powerfull to detect the Clayton copula type dependence)} | ||
\item{L1}{Logrank statistics (most powerfull to detect the Frank copula type dependence)} | ||
\item{Llog}{Logrank statistics (most powerfull to detect the Gumbel copula type dependence)} | ||
} | ||
\references{ | ||
Emura T, Wang W (2010) Testing quasi-independence for truncation data. Journal of Multivariate Analysis 101, 223-239 | ||
} | ||
\author{Takeshi Emura} | ||
|
||
\examples{ | ||
x.trunc=c(10,5,7,1,3,9) | ||
z.trunc=c(12,11,8,6,4,13) | ||
d=c(1,1,1,1,0,1) | ||
Logrank.stat.tie(x.trunc,z.trunc,d) | ||
Logrank.stat(x.trunc,z.trunc,d) ## since there is no tie, the results are the same. | ||
} | ||
% Add one or more standard keywords, see file 'KEYWORDS' in the | ||
% R documentation directory. | ||
\keyword{ Copula } | ||
\keyword{ Quasi-independence test }% __ONLY ONE__ keyword per line |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.