1,935 NEWS.md

Large diffs are not rendered by default.

503 R/coxre.r

Large diffs are not rendered by default.

653 R/ehr.r

Large diffs are not rendered by default.

@@ -1,166 +1,166 @@
#
# event : A Library of Special Functions for Event Histories
# Copyright (C) 1998, 1999, 2000, 2001 J.K. Lindsey
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
# SYNOPSIS
#
# hboxcox(y,m,s,f)
# hburr(y,m,s,f)
# hcauchy(y,m,s)
# hexp(y,m)
# hgextval(y,s,m,f)
# hgamma(y,s,m)
# hggamma(y,s,m,f)
# hhjorth(y,m,s,f)
# hinvgauss(y,m,s)
# hlaplace(y,m,s)
# hlnorm(y,m,s)
# hlogis(y,m,s)
# hglogis(y,m,s,f)
# hnorm(y,m,s)
# hpareto(y,m,s)
# hstudent(y,m,s,f)
# hweibull(y,s,m)
# hgweibull(y,s,m,f)
# hskewlaplace(y,s,m,f)
#
# DESCRIPTION
#
# Functions for various log hazards or intensities

# for log distributions, subtract log(y) from the intensity function

### Box-Cox intensity
###
# f=1 gives truncated normal
hboxcox <- function(y,m,s,f) {
y1 <- y^f/f
-(y1-m)^2/s/2+(f-1)*log(y)-log(2*pi*s)/2-log(1-pnorm(y1,m,sqrt(s))+(f<0)*(1-pnorm(0,m,sqrt(s))))}

### Burr intensity
###
hburr <- function(y,m,s,f) {
y1 <- y/m
y2 <- y1^s
log(f*s/m)+(s-1)*log(y1)-log(1+y2)}

### Cauchy intensity
###
hcauchy <- function(y,m,s) log(dcauchy(y,m,s))-log(1-pcauchy(y,m,s))

### exponential intensity
###
hexp <- function(y,rate)
if(length(rate)==1)rep(log(rate),length(y)) else log(rate)

### generalized extreme value intensity
###
# f=1 gives truncated extreme value
hgextval <- function(y,s,m,f) {
y1 <- y^f/f
ey <-exp(y1)
log(s)+s*(y1-log(m))-(ey/m)^s+(f-1)*log(y)-log(1-pweibull(ey,s,m)-(f<0)*exp(-m^-s))}

### gamma intensity
###
hgamma <- function(y,shape,rate=1,scale=1/rate)
dgamma(y,shape,scale=scale,log=TRUE)-
pgamma(y,shape,scale=scale,lower=FALSE,log=TRUE)

### generalized gamma intensity
###
hggamma <- function(y,s,m,f) {
t <- m/s
u <- t^f
y1 <- y^f
v <- s*f
-v*log(t)-y1/u+log(f)+(v-1)*log(y)-lgamma(s)-
log(1-pgamma(y1,s,scale=u))}

### Hjorth intensity
###
hhjorth <- function(y,m,s,f) log(y/m^2+f/(1+s*y))

### inverse Gaussian intensity
###
hinvgauss <- function(y,m,s) {
t <- y/m
v <- sqrt(y*s)
-((t-1)^2/(y*s)+log(2*s*pi*y^3))/2-log(1-pnorm((t-1)/v)
-exp(2/(m*s))*pnorm(-(t+1)/v))}
### Laplace intensity
###
hlaplace <- function(y,m=0,s=1){
plp <- function(u){
t <- exp(-abs(u))/2
ifelse(u<0,t,1-t)}
-abs(y-m)/s-log(2*s)-log(1-plp((y-m)/s))}

### log normal intensity
###
hlnorm <- function(y,m,s) dlnorm(y,m,s,TRUE)-plnorm(y,m,s,FALSE,TRUE)

### logistic intensity
###
hlogis <- function(y,m,s) dlogis(y,m,s,TRUE)-plogis(y,m,s,FALSE,TRUE)

### generalized logistic intensity
###
# f=1 gives hlogis
hglogis <- function(y,m,s,f) {
y1 <- (y-m)/s
ey <- exp(-y1)
-log(s/f)-y1-(f+1)*log(1+ey)-log(1-(1+ey)^-f)}

### normal intensity
###
hnorm <- function(y,m,s) dnorm(y,m,s,TRUE)-pnorm(y,m,s,FALSE,TRUE)

### Pareto intensity
###
hpareto <- function(y,m,s) (s+1)/(m*s+y)

### Student t intensity
###
hstudent <- function(y,m,s,f){
pst <- function(u,f){
t <- 0.5*pbeta(f/(f+u^2),f/2,0.5)
ifelse(u<0,t,1-t)}
t <- (f+1)/2
u <- (y-m)/s
lgamma(t)-lgamma(f/2)-log(f)/2-(t)*log(1+u^2/f)
-log(pi)/2-log(1-pst(u,f))}
### Weibull intensity
###
hweibull <- function(y,s,m) log(s)+(s-1)*log(y)-s*log(m)

### generalized Weibull intensity
###
# Mudholkar, Srivastava, & Freimer (1995) Technometrics 37: 436-445
hgweibull <- function(y,s,m,f) {
y1 <- y/m
y2 <- y1^s
y3 <- exp(-y2)
log(s*f/m)+(s-1)*log(y1)+(f-1)*log(1-y3)-y2-log(1-(1-y3)^f)}

### skew Laplace intensity
###
hskewlaplace <- function(y,m=0,s=1,f=1){
plp <- function(u)
ifelse(u>0,1-exp(-f*abs(u))/(1+f^2),f^2*exp(-abs(u)/f)/(1+f^2))
log(f)+ifelse(y>m,-f*(y-m),(y-m)/f)/s-log((1+f^2)*s)-
log(1-plp((y-m)/s))}
#
# event : A Library of Special Functions for Event Histories
# Copyright (C) 1998, 1999, 2000, 2001 J.K. Lindsey
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
# SYNOPSIS
#
# hboxcox(y,m,s,f)
# hburr(y,m,s,f)
# hcauchy(y,m,s)
# hexp(y,m)
# hgextval(y,s,m,f)
# hgamma(y,s,m)
# hggamma(y,s,m,f)
# hhjorth(y,m,s,f)
# hinvgauss(y,m,s)
# hlaplace(y,m,s)
# hlnorm(y,m,s)
# hlogis(y,m,s)
# hglogis(y,m,s,f)
# hnorm(y,m,s)
# hpareto(y,m,s)
# hstudent(y,m,s,f)
# hweibull(y,s,m)
# hgweibull(y,s,m,f)
# hskewlaplace(y,s,m,f)
#
# DESCRIPTION
#
# Functions for various log hazards or intensities

# for log distributions, subtract log(y) from the intensity function

### Box-Cox intensity
###
# f=1 gives truncated normal
hboxcox <- function(y,m,s,f) {
y1 <- y^f/f
-(y1-m)^2/s/2+(f-1)*log(y)-log(2*pi*s)/2-log(1-pnorm(y1,m,sqrt(s))+(f<0)*(1-pnorm(0,m,sqrt(s))))}

### Burr intensity
###
hburr <- function(y,m,s,f) {
y1 <- y/m
y2 <- y1^s
log(f*s/m)+(s-1)*log(y1)-log(1+y2)}

### Cauchy intensity
###
hcauchy <- function(y,m,s) log(dcauchy(y,m,s))-log(1-pcauchy(y,m,s))

### exponential intensity
###
hexp <- function(y,rate)
if(length(rate)==1)rep(log(rate),length(y)) else log(rate)

### generalized extreme value intensity
###
# f=1 gives truncated extreme value
hgextval <- function(y,s,m,f) {
y1 <- y^f/f
ey <-exp(y1)
log(s)+s*(y1-log(m))-(ey/m)^s+(f-1)*log(y)-log(1-pweibull(ey,s,m)-(f<0)*exp(-m^-s))}

### gamma intensity
###
hgamma <- function(y,shape,rate=1,scale=1/rate)
dgamma(y,shape,scale=scale,log=TRUE)-
pgamma(y,shape,scale=scale,lower.tail=FALSE,log.p=TRUE)

### generalized gamma intensity
###
hggamma <- function(y,s,m,f) {
t <- m/s
u <- t^f
y1 <- y^f
v <- s*f
-v*log(t)-y1/u+log(f)+(v-1)*log(y)-lgamma(s)-
log(1-pgamma(y1,s,scale=u))}

### Hjorth intensity
###
hhjorth <- function(y,m,s,f) log(y/m^2+f/(1+s*y))

### inverse Gaussian intensity
###
hinvgauss <- function(y,m,s) {
t <- y/m
v <- sqrt(y*s)
-((t-1)^2/(y*s)+log(2*s*pi*y^3))/2-log(1-pnorm((t-1)/v)
-exp(2/(m*s))*pnorm(-(t+1)/v))}
### Laplace intensity
###
hlaplace <- function(y,m=0,s=1){
plp <- function(u){
t <- exp(-abs(u))/2
ifelse(u<0,t,1-t)}
-abs(y-m)/s-log(2*s)-log(1-plp((y-m)/s))}

### log normal intensity
###
hlnorm <- function(y,m,s) dlnorm(y,m,s,TRUE)-plnorm(y,m,s,FALSE,TRUE)

### logistic intensity
###
hlogis <- function(y,m,s) dlogis(y,m,s,TRUE)-plogis(y,m,s,FALSE,TRUE)

### generalized logistic intensity
###
# f=1 gives hlogis
hglogis <- function(y,m,s,f) {
y1 <- (y-m)/s
ey <- exp(-y1)
-log(s/f)-y1-(f+1)*log(1+ey)-log(1-(1+ey)^-f)}

### normal intensity
###
hnorm <- function(y,m,s) dnorm(y,m,s,TRUE)-pnorm(y,m,s,FALSE,TRUE)

### Pareto intensity
###
hpareto <- function(y,m,s) (s+1)/(m*s+y)

### Student t intensity
###
hstudent <- function(y,m,s,f){
pst <- function(u,f){
t <- 0.5*pbeta(f/(f+u^2),f/2,0.5)
ifelse(u<0,t,1-t)}
t <- (f+1)/2
u <- (y-m)/s
lgamma(t)-lgamma(f/2)-log(f)/2-(t)*log(1+u^2/f)
-log(pi)/2-log(1-pst(u,f))}
### Weibull intensity
###
hweibull <- function(y,s,m) log(s)+(s-1)*log(y)-s*log(m)

### generalized Weibull intensity
###
# Mudholkar, Srivastava, & Freimer (1995) Technometrics 37: 436-445
hgweibull <- function(y,s,m,f) {
y1 <- y/m
y2 <- y1^s
y3 <- exp(-y2)
log(s*f/m)+(s-1)*log(y1)+(f-1)*log(1-y3)-y2-log(1-(1-y3)^f)}

### skew Laplace intensity
###
hskewlaplace <- function(y,m=0,s=1,f=1){
plp <- function(u)
ifelse(u>0,1-exp(-f*abs(u))/(1+f^2),f^2*exp(-abs(u)/f)/(1+f^2))
log(f)+ifelse(y>m,-f*(y-m),(y-m)/f)/s-log((1+f^2)*s)-
log(1-plp((y-m)/s))}
1,567 R/kalsurv.r

Large diffs are not rendered by default.

950 R/km.r

Large diffs are not rendered by default.

@@ -1,180 +1,183 @@
#
# event : A Library of Special Functions for Event Histories
# Copyright (C) 1998, 1999, 2000, 2001 J.K. Lindsey
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public Licence as published by
# the Free Software Foundation; either version 2 of the Licence, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public Licence for more details.
#
# You should have received a copy of the GNU General Public Licence
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
# SYNOPSIS
#
# pbirth(frequencies, p, intensity="negative binomial",
# type="spectral decomposition", print.level=0, ndigit=10,
# gradtol=0.00001, steptol=0.00001, fscale=1, iterlim=100,
# typsize=abs(p), stepmax=10*sqrt(p%*%p))
#
# DESCRIPTION
#
# Function to fit overdispersed count data as a birth process

pbirth <- function(frequencies, p, intensity="negative binomial",
type="spectral decomposition", print.level=0, ndigit=10,
gradtol=0.00001, steptol=0.00001, fscale=1, iterlim=100,
typsize=abs(p), stepmax=10*sqrt(p%*%p)){
call <- sys.call()
#
# find distribution and method
#
intensity <- match.arg(intensity,c("binomial","binomial exponential",
"binomial logistic","binomial total","Poisson","Poisson exponential",
"negative binomial","gen negative binomial"))
type <- match.arg(type,c("spectral decomposition","series approximation"))
#
# set up frequencies
#
if(is.vector(frequencies))frequencies <- matrix(frequencies,nrow=1)
n <- dim(frequencies)[2]-1
nr <- dim(frequencies)[1]
np <- length(p)
n1 <- NULL
for(i in 1:nr)n1 <- c(n1,length(frequencies[i,!is.na(frequencies[i,])])-1)
#
# create appropriate intensity function
#
lambda <- switch(intensity,
"binomial"=function(p,nn,n) (n-nn)*exp(p[1]),
"binomial exponential"=function(p,nn,n) (n-nn)*exp(p[1]+p[2]*nn),
"binomial logistic"=function(p,nn,n)
(n-nn)*exp(p[1])/(1+exp(p[2]+p[3]*nn)),
"binomial total"=function(p,nn,n)
(n-nn)*exp(p[1]+p[4]*n)/(1+exp(p[2]+p[3]*nn)),
"Poisson"=function(p,nn,n) rep(exp(p[1]),length(nn)),
"Poisson exponential"=function(p,nn,n) exp(p[1]+p[2]*nn),
"negative binomial"=function(p,nn,n) exp(p[1])*(exp(p[2])+nn),
"gen negative binomial"=
function(p,nn,n) exp(p[1])*(exp(p[2])+nn)^(1-exp(p[3])))
#
# create probability functions
#
x <- matrix(0,n+1,n+1)
i1 <- matrix(1:(n+1),n+1,2)
i2 <- cbind(1:n,2:(n+1))
prob <- function(p,n) {
x[i1[1:(n+1),]] <- -lambda(p,0:n,n)
x[i2[1:n,,drop=FALSE]] <- lambda(p,0:(n-1),n)
pr <- mexp(x[1:(n+1),1:(n+1)],type=type)[1,]}
# z <- eigen(x[1:(n+1),1:(n+1)],sym=FALSE)
# pr <- (z$vectors%*%diag(exp(z$values))%*%solve(z$vectors))[1,]}
prob1 <- function(p){
pr <- NULL
for(i in 1:nr)pr <- c(pr,prob(p,n1[i]))}
#
# call nlm to optimize
#
freq <- as.vector(t(frequencies))
freq <- freq[!is.na(freq)]
like <- function(p) -sum(freq*log(prob1(p)),na.rm=TRUE)
z0 <- nlm(like,p=p, hessian=TRUE, print.level=print.level,
typsize=typsize, ndigit=ndigit, gradtol=gradtol, stepmax=stepmax,
steptol=steptol, iterlim=iterlim, fscale=fscale)
#
# calculate se's
#
if(np==1)cov <- 1/z0$hessian
else {
a <- if(any(is.na(z0$hessian))||any(abs(z0$hessian)==Inf))0
else qr(z0$hessian)$rank
if(a==np)cov <- solve(z0$hessian)
else cov <- matrix(NA,ncol=np,nrow=np)}
se <- sqrt(diag(cov))
nn <- sum(frequencies)
#
# back transform coefficients
#
p <- z0$estimate
pr <- prob(p,n)
pt <- vector(mode="double",np)
pr1 <- exp(-exp(p[1]))
if(intensity=="binomial")pt <- 1-pr1
else if(intensity=="Poisson")pt <- sum(pr*0:n)
else if(intensity=="negative binomial"||intensity=="gen negative binomial"){
pr2 <- exp(p[2])
pt[1] <- pr2/pr1-pr2
pt[2] <- pr2
if(intensity=="gen negative binomial")pt[3] <- 1-exp(p[3])}
else pt <- exp(-exp(p))
#
# create values from intensity function
#
an <- switch(intensity,
"binomial"=rep(exp(p[1]),n+1),
"binomial exponential"=exp(p[1]+p[2]*0:n),
"binomial logistic"=exp(p[1])/(1+exp(p[2]+p[3]*0:n)),
"binomial total"=exp(p[1]+p[4]*n)/(1+exp(p[2]+p[3]*0:n)),
"Poisson"=rep(exp(p[1]),n+1),
"Poisson exponential"=exp(p[1]+p[2]*0:n),
"negative binomial"=exp(p[1])*(exp(p[2])+0:n),
"gen negative binomial"=
exp(p[1])*(exp(p[2])+0:n)^(1-exp(p[3])))
fitted.values <- nn*pr
residuals <- (frequencies-fitted.values)/sqrt(fitted.values)
z1 <- list(
call=call,
intensity=intensity,
lambda=lambda,
an=an,
frequencies=frequencies,
maxlike=z0$minimum,
aic=z0$minimum+np,
fitted.values=fitted.values,
prob=pr,
residuals=residuals,
initial.values=p,
coefficients=p,
pt=pt,
se=se,
cov=cov,
corr=cov/(se%o%se),
gradient=z0$gradient,
iterations=z0$iterations,
error=z0$error,
code=z0$code)
class(z1) <- "pbirth"
return(z1)}

### standard method
###

deviance.pbirth <- function(z) 2*z$maxlike

### print method
###
print.pbirth <- function(z){
np <- length(z$coefficients)
cat("\nCall:",deparse(z$call),sep="\n")
cat("\n")
t <- deparse(z$lambda)
cat(z$intensity,"intensity function:",t[2:length(t)],sep="\n")
cat("-Log likelihood ",z$maxlike,"\n")
cat("AIC ",z$aic,"\n")
cat("Iterations ",z$iterations,"\n\n")
cat("Coefficients:\n")
coef.table <- cbind(z$coefficients,z$se,z$pt)
dn <- paste("p",1:np,sep="")
dimnames(coef.table) <- list(dn,c("estimate","se","parameter"))
print.default(coef.table,digits=4,print.gap=2)
if(np>1){
cat("\nCorrelations:\n")
dimnames(z$corr) <- list(seq(1,np),seq(1,np))
print.default(z$corr,digits=4)}
invisible(z)}
#
# event : A Library of Special Functions for Event Histories
# Copyright (C) 1998, 1999, 2000, 2001 J.K. Lindsey
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public Licence as published by
# the Free Software Foundation; either version 2 of the Licence, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public Licence for more details.
#
# You should have received a copy of the GNU General Public Licence
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
# SYNOPSIS
#
# pbirth(frequencies, p, intensity="negative binomial",
# type="spectral decomposition", print.level=0, ndigit=10,
# gradtol=0.00001, steptol=0.00001, fscale=1, iterlim=100,
# typsize=abs(p), stepmax=10*sqrt(p%*%p))
#
# DESCRIPTION
#
# Function to fit overdispersed count data as a birth process

pbirth <- function(frequencies, p, intensity="negative binomial",
type="spectral decomposition", print.level=0, ndigit=10,
gradtol=0.00001, steptol=0.00001, fscale=1, iterlim=100,
typsize=abs(p), stepmax=10*sqrt(p%*%p)){
call <- sys.call()
#
# find distribution and method
#
intensity <- match.arg(intensity,c("binomial","binomial exponential",
"binomial logistic","binomial total","Poisson","Poisson exponential",
"negative binomial","gen negative binomial"))
type <- match.arg(type,c("spectral decomposition","series approximation"))
#
# set up frequencies
#
if(is.vector(frequencies))frequencies <- matrix(frequencies,nrow=1)
n <- dim(frequencies)[2]-1
nr <- dim(frequencies)[1]
np <- length(p)
n1 <- NULL
for(i in 1:nr)n1 <- c(n1,length(frequencies[i,!is.na(frequencies[i,])])-1)
#
# create appropriate intensity function
#
lambda <- switch(intensity,
"binomial"=function(p,nn,n) (n-nn)*exp(p[1]),
"binomial exponential"=function(p,nn,n) (n-nn)*exp(p[1]+p[2]*nn),
"binomial logistic"=function(p,nn,n)
(n-nn)*exp(p[1])/(1+exp(p[2]+p[3]*nn)),
"binomial total"=function(p,nn,n)
(n-nn)*exp(p[1]+p[4]*n)/(1+exp(p[2]+p[3]*nn)),
"Poisson"=function(p,nn,n) rep(exp(p[1]),length(nn)),
"Poisson exponential"=function(p,nn,n) exp(p[1]+p[2]*nn),
"negative binomial"=function(p,nn,n) exp(p[1])*(exp(p[2])+nn),
"gen negative binomial"=
function(p,nn,n) exp(p[1])*(exp(p[2])+nn)^(1-exp(p[3])))
#
# create probability functions
#
x <- matrix(0,n+1,n+1)
i1 <- matrix(1:(n+1),n+1,2)
i2 <- cbind(1:n,2:(n+1))
prob <- function(p,n) {
x[i1[1:(n+1),]] <- -lambda(p,0:n,n)
x[i2[1:n,,drop=FALSE]] <- lambda(p,0:(n-1),n)
pr <- mexp(x[1:(n+1),1:(n+1)],type=type)[1,]
pr}
# z <- eigen(x[1:(n+1),1:(n+1)],sym=FALSE)
# pr <- (z$vectors%*%diag(exp(z$values))%*%solve(z$vectors))[1,]}
prob1 <- function(p){
pr <- NULL
for(i in 1:nr)pr <- c(pr,prob(p,n1[i]))
pr}
#
# call nlm to optimize
#
freq <- as.vector(t(frequencies))
freq <- freq[!is.na(freq)]
like <- function(p) -sum(freq*log(prob1(p)),na.rm=TRUE)
z0 <- nlm(like,p=p, hessian=TRUE, print.level=print.level,
typsize=typsize, ndigit=ndigit, gradtol=gradtol, stepmax=stepmax,
steptol=steptol, iterlim=iterlim, fscale=fscale)
#
# calculate se's
#
if(np==1)cov <- 1/z0$hessian
else {
a <- if(any(is.na(z0$hessian))||any(abs(z0$hessian)==Inf))0
else qr(z0$hessian)$rank
if(a==np)cov <- solve(z0$hessian)
else cov <- matrix(NA,ncol=np,nrow=np)}
se <- sqrt(diag(cov))
nn <- sum(frequencies)
#
# back transform coefficients
#
p <- z0$estimate
pr <- prob(p,n)
pt <- vector(mode="double",np)
pr1 <- exp(-exp(p[1]))
if(intensity=="binomial")pt <- 1-pr1
else if(intensity=="Poisson")pt <- sum(pr*0:n)
else if(intensity=="negative binomial"||intensity=="gen negative binomial"){
pr2 <- exp(p[2])
pt[1] <- pr2/pr1-pr2
pt[2] <- pr2
if(intensity=="gen negative binomial")pt[3] <- 1-exp(p[3])}
else pt <- exp(-exp(p))
#
# create values from intensity function
#
an <- switch(intensity,
"binomial"=rep(exp(p[1]),n+1),
"binomial exponential"=exp(p[1]+p[2]*0:n),
"binomial logistic"=exp(p[1])/(1+exp(p[2]+p[3]*0:n)),
"binomial total"=exp(p[1]+p[4]*n)/(1+exp(p[2]+p[3]*0:n)),
"Poisson"=rep(exp(p[1]),n+1),
"Poisson exponential"=exp(p[1]+p[2]*0:n),
"negative binomial"=exp(p[1])*(exp(p[2])+0:n),
"gen negative binomial"=
exp(p[1])*(exp(p[2])+0:n)^(1-exp(p[3])))
fitted.values <- nn*pr
residuals <- (frequencies-fitted.values)/sqrt(fitted.values)
z1 <- list(
call=call,
intensity=intensity,
lambda=lambda,
an=an,
frequencies=frequencies,
maxlike=z0$minimum,
aic=z0$minimum+np,
fitted.values=fitted.values,
prob=pr,
residuals=residuals,
initial.values=p,
coefficients=p,
pt=pt,
se=se,
cov=cov,
corr=cov/(se%o%se),
gradient=z0$gradient,
iterations=z0$iterations,
error=z0$error,
code=z0$code)
class(z1) <- "pbirth"
return(z1)}

### standard method
###

deviance.pbirth <- function(object, ...) 2*object$maxlike

### print method
###
print.pbirth <- function(x, ...){
z <- x ## legacy / S3methods consistency
np <- length(z$coefficients)
cat("\nCall:",deparse(z$call),sep="\n")
cat("\n")
t <- deparse(z$lambda)
cat(z$intensity,"intensity function:",t[2:length(t)],sep="\n")
cat("-Log likelihood ",z$maxlike,"\n")
cat("AIC ",z$aic,"\n")
cat("Iterations ",z$iterations,"\n\n")
cat("Coefficients:\n")
coef.table <- cbind(z$coefficients,z$se,z$pt)
dn <- paste("p",1:np,sep="")
dimnames(coef.table) <- list(dn,c("estimate","se","parameter"))
print.default(coef.table,digits=4,print.gap=2)
if(np>1){
cat("\nCorrelations:\n")
dimnames(z$corr) <- list(seq(1,np),seq(1,np))
print.default(z$corr,digits=4)}
invisible(z)}
1,465 R/survkit.r

Large diffs are not rendered by default.

@@ -0,0 +1,10 @@

[![Travis-CI Build Status](https://travis-ci.org/swihart/event.svg?branch=master)](https://travis-ci.org/swihart/event) [![CRAN\_Status\_Badge](http://www.r-pkg.org/badges/version/event)](https://cran.r-project.org/package=event) ![downloads](http://cranlogs.r-pkg.org/badges/grand-total/event)

<!-- README.md is generated from README.Rmd. Please edit README.Rmd (this file)-->
`event` R package
=================

This package is intended to be the developmental version to the CRAN version of [Jim Lindsey's event](http://www.commanster.eu/rcode.html). The .zip files listed on his homepage have been listed as version 1.0 since 2005. For the subsequent maintenance on this github and CRAN, we will start at 1.1.0.

To compare this version with the static v1.0 files on [Jim Lindsey's Homepage](http://www.commanster.eu/rcode.html), it may be useful to use [the compare page for this repo's two branches](https://github.com/swihart/event/compare/jim-lindsey-homepage-version-1.0...master?diff=split&name=master).
@@ -0,0 +1,59 @@
# event R package
Bruce Swihart
November 2016

## Resubmission 1
I removed survkit.r/.Rd/.f. Turns out survkit is available as of 2013 in a nice update
from the original authors of survkit.f. Added this info to NEWS.

## Test environments
* local OS X install: R version 3.3.2 (2016-10-31)
* ubuntu 12.04 (on travis-ci): R version 3.3.1 (2016-06-21)
* win-builder: R Under development (unstable) (2016-11-29 r71708)

## R CMD check results
There were no ERRORs or WARNINGs.

There was 1 NOTE:

* 1st submission (Package was archived on CRAN, see Miscellaneous)

## Downstream dependencies
There are currently no downstream dependencies for this package.

## Miscellaneous
As per the CRAN Repository Policy Version Revision 3577,

* Explain any change in the maintainer’s email address and if possible send confirmation from the previous address (by a separate email to CRAN@R-project.org) or explain why it is not possible.

This Package was archived on CRAN. I am resurrecting it.
I have Jim Lindsey's permission to be maintainer of his packages on CRAN. Currently he has them in .zip files on his homepage: http://www.commanster.eu/rcode.html. He does not have access to the original email address he used when this package was on CRAN, and thus cannot send a separate confirmation email. However, you can contact him at James Lindsey <jlindsey@gen.unimaas.nl>.

He sent this confirmation message on 2016-11-24:

---------- Forwarded message ----------
From: James Lindsey <jlindsey@gen.unimaas.nl>
Date: Thu, Nov 24, 2016 at 9:26 AM
Subject: transferring maintainer role to Bruce Swihart for 'rmutil', 'repeated', 'gnlm', 'growth', 'event', 'stable'
To: CRAN@r-project.org, ligges@statistik.tu-dortmund.de, Kurt.Hornik@wu.ac.at
Cc: bruce.swihart@gmail.com


Dear CRAN,

Bruce Swihart is taking on the role of maintainer for my R-packages which have been available on my homepage, http://www.commanster.eu/rcode.html. Some of these R-packages were on CRAN but have since been archived.
I know it is CRAN repository policy to email confirmation from the previous maintainer's email address (jlindsey@luc.ac.be), but alas I can't due to LUC changing its name.

Please accept this email as confirmation of the maintainer role changing for R packages 'rmutil', 'repeated', 'gnlm', 'growth', 'event', 'stable'.

Regards,
Jim Lindsey









@@ -1,43 +1,50 @@
\name{autointensity}
\title{Plot Autointensity Function of a Point Process}
\usage{
autointensity(times, window=NULL, maxlag=total/10,
ylab="Conditional probability", xlab="Lag",
main="Autointensity function", xlim=c(0,max(times)),
ylim=c(0,if(plotse)max(se1)else max(z$density)),
lty=1, plot=TRUE, plotse=TRUE, add=FALSE, ...)
}
\description{
\code{autointensity} plots the autointensity function of a point
process, including a solid horizontal line indicating the constant
intensity of a Poisson process.
}
\arguments{
\item{times}{Vector of times between events.}
\item{window}{Width of grouping interval.}
\item{maxlag}{Maximum lag to be calculated, by default the maximum
interevent time.}
\item{plot}{If FALSE, values are returned but the function is not
plotted.}
\item{plotse}{If TRUE, plots pointwise two-standard error bands around
the curve.}
\item{add}{If TRUE, add curve to an existing plot.}
\item{others}{Plotting control options.}
}
\value{
A list containing the coordinates of the plotted function and the
standard error bands.
}
\references{
Guttorp, P. (1995) Stochastic Modeling of Scientific Data. Chapman &
Hall, pp. 229, 238-240.
}
\author{J.K. Lindsey}
\seealso{
\code{\link[event]{cprocess}}.
}
\examples{
times <- rgamma(100,2,scale=4)
autointensity(times, window=3)
}
\keyword{hplot}
\name{autointensity}
\title{Plot Autointensity Function of a Point Process}
\usage{
autointensity(times, window=NULL, maxlag=max(times),
ylab="Conditional probability", xlab="Lag",
main="Autointensity function", xlim=c(0,max(times)),
ylim=c(0,if(plotse)max(se1)else max(z$density)),
lty=1, plot=TRUE, plotse=TRUE, add=FALSE, ...)
}
\alias{autointensity}
\description{
\code{autointensity} plots the autointensity function of a point
process, including a solid horizontal line indicating the constant
intensity of a Poisson process.
}
\arguments{
\item{times}{Vector of times between events.}
\item{window}{Width of grouping interval.}
\item{maxlag}{Maximum lag to be calculated, by default the maximum
interevent time.}
\item{plot}{If FALSE, values are returned but the function is not
plotted.}
\item{plotse}{If TRUE, plots pointwise two-standard error bands around
the curve.}
\item{add}{If TRUE, add curve to an existing plot.}
\item{ylab}{Plotting control options.}
\item{xlab}{Plotting control options.}
\item{main}{Plotting control options.}
\item{xlim}{Plotting control options.}
\item{ylim}{Plotting control options.}
\item{lty}{Plotting control options.}
\item{...}{Plotting control options.}
}
\value{
A list containing the coordinates of the plotted function and the
standard error bands.
}
\references{
Guttorp, P. (1995) Stochastic Modeling of Scientific Data. Chapman &
Hall, pp. 229, 238-240.
}
\author{J.K. Lindsey}
\seealso{
\code{\link[event]{cprocess}}.
}
\examples{
times <- rgamma(100,2,scale=4)
autointensity(times, window=3)
}
\keyword{hplot}
@@ -1,31 +1,37 @@
\name{bp}
\title{Create a Vector of Cumulative Numbers of Previous Events
for a Point Process (Birth Processes)}
\alias{bp}
\usage{
bp(y, id, censor=1)
}
\arguments{
\item{y}{Vector of times.}
\item{id}{Vector of corresponding individual identifiers for who had
which sequence of times.}
\item{censor}{Vector of censoring indicators.}
}
\value{
\code{bp} creates a vector of length \code{sum(y)} of cumulative
numbers of previous events for each individual for use in fitting
birth processes with \code{\link{ehr}}. Add one if the process starts
at an event.
}
\author{J.K. Lindsey}
\seealso{
\code{\link{ehr}}, \code{\link{ident}}, \code{\link{pp}}, \code{\link{tccov}},
\code{\link{tpast}}, \code{\link{ttime}}, \code{\link{tvcov}}.
}
\examples{
y <- c(5,3,2,4)
i <- c(1,1,2,2)
birth <- bp(y, i)
birth
}
\keyword{manip}
\name{bp}
\title{Create a Vector of Cumulative Numbers of Previous Events
for a Point Process (Birth Processes)}
\alias{bp}
\usage{
bp(y, id, censor=1)
}
\arguments{
\item{y}{Vector of times.}
\item{id}{Vector of corresponding individual identifiers for who had
which sequence of times.}
\item{censor}{Vector of censoring indicators.}
}
\description{
\code{bp} creates a vector of length \code{sum(y)} of cumulative
numbers of previous events for each individual for use in fitting
birth processes with \code{\link{ehr}}. Add one if the process starts
at an event.
}
\value{
\code{bp} creates a vector of length \code{sum(y)} of cumulative
numbers of previous events for each individual for use in fitting
birth processes with \code{\link{ehr}}. Add one if the process starts
at an event.
}
\author{J.K. Lindsey}
\seealso{
\code{\link{ehr}}, \code{\link{ident}}, \code{\link{pp}}, \code{\link{tccov}},
\code{\link{tpast}}, \code{\link{ttime}}, \code{\link{tvcov}}.
}
\examples{
y <- c(5,3,2,4)
i <- c(1,1,2,2)
birth <- bp(y, i)
birth
}
\keyword{manip}
@@ -1,66 +1,74 @@
\name{coxre}
\title{Cox Proportional Hazards Model with Random Effect}
\alias{coxre}
\usage{
coxre(response, censor, nest=NULL, cov=NULL, stratified=FALSE,
cumul=FALSE,estimate=1, iter=10, print.level=0, ndigit=10,
gradtol=0.00001, steptol=0.00001, iterlim=100, fscale=1,
typsiz=abs(estimate), stepmax=estimate)
}
\description{
\code{coxre} fits a Cox proportional hazards model to event history
data using a gamma distribution random effect. The parameter, gamma,
is the variance of this mixing distribution.

If a matrix of response times is supplied, the model can be stratified
by columns, i.e. a different intensity function is fitted for each
column. To fit identical intensity functions to all response types,
give the times as a vector.
}
\arguments{
\item{response}{Vector or matrix of times to events, with one column
per type of response (or subunit).}
\item{censor}{Corresponding vector or matrix of censoring indicators.
If NULL all values are set to one.}
\item{nest}{Vector indicating to which unit each observation belongs.}
\item{cov}{One covariate}
\item{stratified}{If TRUE, a model stratified on type of response
(the columns of response) is fitted instead of proportional intensities.}
\item{cumul}{Set to TRUE if response times are from a common origin
instead of times to (or between) events.}
\item{estimate}{Initial estimate of the frailty parameter.}
\item{iter}{Maximum number of iterations allowed for the inner EM loop.}
\item{others}{Plotting control options.}
}
\author{D.G. Clayton and J.K. Lindsey}
\references{
Clayton, D. (1987) The analysis of event history data: a review of
progress and outstanding problems. Statistics in Medicine 7: 819-841
}
\seealso{
\code{\link[event]{kalsurv}}.
}
\examples{
# 11 individuals, each with 5 responses
y <- matrix(c(51,36,50,35,42,
27,20,26,17,27,
37,22,41,37,30,
42,36,32,34,27,
27,18,33,14,29,
43,32,43,35,40,
41,22,36,25,38,
38,21,31,20,16,
36,23,27,25,28,
26,31,31,32,36,
29,20,25,26,25),ncol=5,byrow=TRUE)
# Different intensity functions
coxre(response=y, censor=matrix(rep(1,55),ncol=5), nest=1:11,
est=0.7, stratified=TRUE)
# Proportional intensity functions for the five responses
coxre(response=y, censor=matrix(rep(1,55),ncol=5), nest=1:11,
est=0.7, stratified=FALSE)
# Identical intensity functions
coxre(response=as.vector(t(y)), censor=rep(1,55),
nest=rep(1:11,rep(5,11)), est=0.7)
}
\keyword{models}
\name{coxre}
\title{Cox Proportional Hazards Model with Random Effect}
\alias{coxre}
\alias{print.llrf}
\usage{
coxre(response, censor, nest=NULL, cov=NULL, stratified=FALSE,
cumul=FALSE,estimate=1, iter=10, print.level=0, ndigit=10,
gradtol=0.00001, steptol=0.00001, iterlim=100, fscale=1,
typsize=abs(estimate), stepmax=estimate)
}
\description{
\code{coxre} fits a Cox proportional hazards model to event history
data using a gamma distribution random effect. The parameter, gamma,
is the variance of this mixing distribution.

If a matrix of response times is supplied, the model can be stratified
by columns, i.e. a different intensity function is fitted for each
column. To fit identical intensity functions to all response types,
give the times as a vector.
}
\arguments{
\item{response}{Vector or matrix of times to events, with one column
per type of response (or subunit).}
\item{censor}{Corresponding vector or matrix of censoring indicators.
If NULL all values are set to one.}
\item{nest}{Vector indicating to which unit each observation belongs.}
\item{cov}{One covariate}
\item{stratified}{If TRUE, a model stratified on type of response
(the columns of response) is fitted instead of proportional intensities.}
\item{cumul}{Set to TRUE if response times are from a common origin
instead of times to (or between) events.}
\item{estimate}{Initial estimate of the frailty parameter.}
\item{iter}{Maximum number of iterations allowed for the inner EM loop.}
\item{print.level}{\code{nlm} control options.}
\item{ndigit}{\code{nlm} control options.}
\item{gradtol}{\code{nlm} control options.}
\item{steptol}{\code{nlm} control options.}
\item{iterlim}{\code{nlm} control options.}
\item{fscale}{\code{nlm} control options.}
\item{typsize}{\code{nlm} control options.}
\item{stepmax}{\code{nlm} control options.}
}
\author{D.G. Clayton and J.K. Lindsey}
\references{
Clayton, D. (1987) The analysis of event history data: a review of
progress and outstanding problems. Statistics in Medicine 7: 819-841
}
\seealso{
\code{\link[event]{kalsurv}}.
}
\examples{
# 11 individuals, each with 5 responses
y <- matrix(c(51,36,50,35,42,
27,20,26,17,27,
37,22,41,37,30,
42,36,32,34,27,
27,18,33,14,29,
43,32,43,35,40,
41,22,36,25,38,
38,21,31,20,16,
36,23,27,25,28,
26,31,31,32,36,
29,20,25,26,25),ncol=5,byrow=TRUE)
# Different intensity functions
coxre(response=y, censor=matrix(rep(1,55),ncol=5), nest=1:11,
est=0.7, stratified=TRUE)
# Proportional intensity functions for the five responses
coxre(response=y, censor=matrix(rep(1,55),ncol=5), nest=1:11,
est=0.7, stratified=FALSE)
# Identical intensity functions
coxre(response=as.vector(t(y)), censor=rep(1,55),
nest=rep(1:11,rep(5,11)), est=0.7)
}
\keyword{models}
@@ -1,30 +1,35 @@
\name{cprocess}
\title{Plot Counting Process Data}
\alias{cprocess}
\usage{
cprocess(times=NULL, events=NULL, number=FALSE, lty=NULL, xlim=NULL,
ylim=NULL, xlab="Time", ylab="Counts", ...)
}
\description{
\code{cprocess} plots the cumulative number of events (the counting
process) over time for each vector in the list. One or both of
\code{times} and \code{events} can be supplied.
}
\arguments{
\item{times}{Vector of times between events, a list of such
vectors, or a \code{repeated} object.}
\item{events}{Vector of counts of events, a list of such vectors, or a
\code{repeated} object.}
\item{number}{If TRUE, the counting processes are numbered
consecutively on the graph.}
\item{others}{Plotting control options.}
}
\author{J.K. Lindsey}
\seealso{
\code{\link[rmutil]{read.list}}, \code{\link[rmutil]{rmna}}.
}
\examples{
times <- rgamma(20,2,scale=4)
cprocess(times)
}
\keyword{hplot}
\name{cprocess}
\title{Plot Counting Process Data}
\alias{cprocess}
\usage{
cprocess(times=NULL, events=NULL, number=FALSE, lty=NULL, xlim=NULL,
ylim=NULL, xlab="Time", ylab="Counts", ...)
}
\description{
\code{cprocess} plots the cumulative number of events (the counting
process) over time for each vector in the list. One or both of
\code{times} and \code{events} can be supplied.
}
\arguments{
\item{times}{Vector of times between events, a list of such
vectors, or a \code{repeated} object.}
\item{events}{Vector of counts of events, a list of such vectors, or a
\code{repeated} object.}
\item{number}{If TRUE, the counting processes are numbered
consecutively on the graph.}
\item{ylab}{Plotting control options.}
\item{xlab}{Plotting control options.}
\item{xlim}{Plotting control options.}
\item{ylim}{Plotting control options.}
\item{lty}{Plotting control options.}
\item{...}{Plotting control options.}
}
\author{J.K. Lindsey}
\seealso{
\code{\link[rmutil]{read.list}}, \code{\link[rmutil]{rmna}}.
}
\examples{
times <- rgamma(20,2,scale=4)
cprocess(times)
}
\keyword{hplot}
@@ -1,100 +1,110 @@
\name{ehr}
\title{Regression Models for Event History Intensity Functions}
\alias{ehr}
\usage{
ehr(point, lambda=NULL, linear=NULL, plambda=NULL, delta=1,
envir=parent.frame(), print.level=0, typsiz=rep(1,length(plambda)),
ndigit=10, gradtol=0.00001, iterlim=100, fscale=1,
stepmax=max(10*sqrt(plambda\%*\%plambda),10), steptol=0.0004)
}
\description{
\code{ehr} fits an intensity function to event histories, where point is
produced by \code{point <- pp(y)} and \code{lambda} is the user-defined
log intensity function.

Nonlinear regression models for \code{lambda} can be supplied as
formulae where parameters are unknowns. Factor variables cannot be
used and parameters must be scalars. (See \code{\link[rmutil]{finterp}}.)
}
\arguments{
\item{point}{A point process vector produced by \code{\link[event]{pp}}.}
\item{lambda}{User-specified function of \code{p}, and possibly
\code{linear}, giving the regression equation for the intensity or a
formula beginning with ~, specifying either a linear regression
function in the Wilkinson and Rogers notation or a general function
with named unknown parameters. The function may contain a
linear part that must simply be given the name, \code{linear}, in the
function. If no function is supplied, the intensity is taken to be
constant (a homogeneous Poisson process).}
\item{linear}{A formula beginning with ~ specifying the linear part of
the regression function.}
\item{plambda}{Vector of initial parameter estimates. If \code{lambda}
is a formula with unknown parameters, their estimates must be supplied
either in their order of appearance in the expression or in a named list.}
\item{delta}{If any time intervals are different from unity, a vector
of time intervals.}
\item{envir}{Environment in which model formulae are to be
interpreted or a data object of class, repeated, tccov, or tvcov.
If \code{point} has class \code{repeated}, it is used as the
environment.}
\item{others}{Arguments controlling \code{\link{nlm}}.}
}
\references{
Lindsey, J.K. (1995) Fitting parametric counting processes by
using log linear models. Journal of the Royal Statistical
Society C44, 201-212.
}
\author{J.K. Lindsey}
\seealso{
\code{\link[event]{bp}}, \code{\link[rmutil]{finterp}},
\code{\link[event]{ident}}, \code{\link[event]{pp}},
\code{\link[event]{tccov}}, \code{\link[event]{tpast}},
\code{\link[event]{ttime}}, \code{\link[event]{tvcov}}.
}
\examples{
y <- c(5,3,2,4)
# event indicator
py <- pp(y)
# time since previous event
ptime <- tpast(y)
# individual ID
i <- c(1,1,2,2)
id <- ident(y, i)
# times and corresponding covariate values
tx <- c(2,3,1,2,2,2,2)
x <- c(1,2,2,1,2,2,1)
zcov <- tvcov(y, x, tx)
# Poisson process
ehr(py, plambda=1)
# Weibull process
lambda1 <- function(p) p[1]+p[2]*log(ptime)
ehr(py, lambda=lambda1, plambda=c(1,1))
# or
ehr(py, lambda=~log(ptime), plambda=c(1,1))
# or
ehr(py, lambda=~b0+b1*log(ptime), plambda=list(b0=1,b1=1))
# Poisson process with time-varying covariate
lambda2 <- function(p) p[1]+p[2]*zcov
ehr(py, lambda=lambda2, plambda=c(1,1))
# or
ehr(py, lambda=~zcov, plambda=c(1,1))
# or
ehr(py, lambda=~c0+c1*zcov, plambda=list(c0=1,c1=1))
# Weibull process with time-varying covariate
lambda3 <- function(p) p[1]+p[2]*log(ptime)+p[3]*zcov
ehr(py, lambda=lambda3, plambda=c(1,1,1))
# or
ehr(py, lambda=~log(ptime)+zcov, plambda=c(1,1,1))
# or
ehr(py, lambda=~c0+b1*log(ptime)+c1*zcov, plambda=list(c0=1,c1=1,b1=1))
# gamma process with time-varying covariate
lambda4 <- function(p) hgamma(ptime, p[1], exp(p[2]+p[3]*zcov))
ehr(py, lambda=lambda4, plambda=c(1,1,1))
# or
ehr(py, lambda=~hgamma(ptime, b1, exp(c0+c1*zcov)),
plambda=list(c0=1,c1=1,b1=1))
# or
lambda5 <- function(p, linear) hgamma(ptime, p[1], exp(linear))
ehr(py, lambda=lambda5, linear=~zcov, plambda=c(1,1,1))
}
\keyword{models}
\name{ehr}
\title{Regression Models for Event History Intensity Functions}
\alias{ehr}
\alias{print.intensity}
\alias{deviance.intensity}
\alias{vdm}
\usage{
ehr(point, lambda=NULL, linear=NULL, plambda=NULL, delta=1,
envir=parent.frame(), print.level=0, typsize=rep(1,length(plambda)),
ndigit=10, gradtol=0.00001, iterlim=100, fscale=1,
stepmax=max(10*sqrt(plambda\%*\%plambda),10), steptol=0.0004)
}
\description{
\code{ehr} fits an intensity function to event histories, where point is
produced by \code{point <- pp(y)} and \code{lambda} is the user-defined
log intensity function.

Nonlinear regression models for \code{lambda} can be supplied as
formulae where parameters are unknowns. Factor variables cannot be
used and parameters must be scalars. (See \code{\link[rmutil]{finterp}}.)
}
\arguments{
\item{point}{A point process vector produced by \code{\link[event]{pp}}.}
\item{lambda}{User-specified function of \code{p}, and possibly
\code{linear}, giving the regression equation for the intensity or a
formula beginning with ~, specifying either a linear regression
function in the Wilkinson and Rogers notation or a general function
with named unknown parameters. The function may contain a
linear part that must simply be given the name, \code{linear}, in the
function. If no function is supplied, the intensity is taken to be
constant (a homogeneous Poisson process).}
\item{linear}{A formula beginning with ~ specifying the linear part of
the regression function.}
\item{plambda}{Vector of initial parameter estimates. If \code{lambda}
is a formula with unknown parameters, their estimates must be supplied
either in their order of appearance in the expression or in a named list.}
\item{delta}{If any time intervals are different from unity, a vector
of time intervals.}
\item{envir}{Environment in which model formulae are to be
interpreted or a data object of class, repeated, tccov, or tvcov.
If \code{point} has class \code{repeated}, it is used as the
environment.}
\item{print.level}{\code{nlm} control options.}
\item{ndigit}{\code{nlm} control options.}
\item{gradtol}{\code{nlm} control options.}
\item{steptol}{\code{nlm} control options.}
\item{iterlim}{\code{nlm} control options.}
\item{fscale}{\code{nlm} control options.}
\item{typsize}{\code{nlm} control options.}
\item{stepmax}{\code{nlm} control options.}
}
\references{
Lindsey, J.K. (1995) Fitting parametric counting processes by
using log linear models. Journal of the Royal Statistical
Society C44, 201-212.
}
\author{J.K. Lindsey}
\seealso{
\code{\link[event]{bp}}, \code{\link[rmutil]{finterp}},
\code{\link[event]{ident}}, \code{\link[event]{pp}},
\code{\link[event]{tccov}}, \code{\link[event]{tpast}},
\code{\link[event]{ttime}}, \code{\link[event]{tvcov}}.
}
\examples{
y <- c(5,3,2,4)
# event indicator
py <- pp(y)
# time since previous event
ptime <- tpast(y)
# individual ID
i <- c(1,1,2,2)
id <- ident(y, i)
# times and corresponding covariate values
tx <- c(2,3,1,2,2,2,2)
x <- c(1,2,2,1,2,2,1)
zcov <- tvcov(y, x, tx)
# Poisson process
ehr(py, plambda=1)
# Weibull process
lambda1 <- function(p) p[1]+p[2]*log(ptime)
ehr(py, lambda=lambda1, plambda=c(1,1))
# or
ehr(py, lambda=~log(ptime), plambda=c(1,1))
# or
ehr(py, lambda=~b0+b1*log(ptime), plambda=list(b0=1,b1=1))
# Poisson process with time-varying covariate
lambda2 <- function(p) p[1]+p[2]*zcov
ehr(py, lambda=lambda2, plambda=c(1,1))
# or
ehr(py, lambda=~zcov, plambda=c(1,1))
# or
ehr(py, lambda=~c0+c1*zcov, plambda=list(c0=1,c1=1))
# Weibull process with time-varying covariate
lambda3 <- function(p) p[1]+p[2]*log(ptime)+p[3]*zcov
ehr(py, lambda=lambda3, plambda=c(1,1,1))
# or
ehr(py, lambda=~log(ptime)+zcov, plambda=c(1,1,1))
# or
ehr(py, lambda=~c0+b1*log(ptime)+c1*zcov, plambda=list(c0=1,c1=1,b1=1))
# gamma process with time-varying covariate
lambda4 <- function(p) hgamma(ptime, p[1], exp(p[2]+p[3]*zcov))
ehr(py, lambda=lambda4, plambda=c(1,1,1))
# or
ehr(py, lambda=~hgamma(ptime, b1, exp(c0+c1*zcov)),
plambda=list(c0=1,c1=1,b1=1))
# or
lambda5 <- function(p, linear) hgamma(ptime, p[1], exp(linear))
ehr(py, lambda=lambda5, linear=~zcov, plambda=c(1,1,1))
}
\keyword{models}
@@ -1,77 +1,77 @@
\name{event}
\title{Event History Analysis Library}
\alias{event}
\description{
\code{\link[event]{autointensity}} Plot Autointensity Function of a Point Process

\code{\link[event]{bp}} Create a Vector of Cumulative Numbers of Previous Events for a Point Process

\code{\link[event]{coxre}} Cox Proportional Hazards Model with Random Effect

\code{\link[event]{cprocess}} Counting Process Plot

\code{\link[event]{ehr}} Fit an Intensity Function to Event Histories

\code{\link[event]{hboxcox}} Log Hazard Function for a Box-Cox Process

\code{\link[event]{hburr}} Log Hazard Function for a Burr Process

\code{\link[event]{hcauchy}} Log Hazard Function for a Cauchy Process

\code{\link[event]{hexp}} Log Hazard Function for an Exponential (Poisson) Process

\code{\link[event]{hgamma}} Log Hazard Function for a Gamma Process

\code{\link[event]{hgextval}} Log Hazard Function for an Extreme Value Process

\code{\link[event]{hggamma}} Log Hazard Function for a Generalized Gamma Process

\code{\link[event]{hglogis}} Log Hazard Function for a Generalized Logistic Process

\code{\link[event]{hgweibull}} Log Hazard Function for a Generalized Weibull Process

\code{\link[event]{hhjorth}} Log Hazard Function for a Hjorth Process

\code{\link[event]{hinvgauss}} Log Hazard Function for a Inverse Gauss Process

\code{\link[event]{hlaplace}} Log Hazard Function for a Laplace Process

\code{\link[event]{hlnorm}} Log Hazard Function for a Log Normal Process

\code{\link[event]{hlogis}} Log Hazard Function for a Logistic Process

\code{\link[event]{hnorm}} Log Hazard Function for a Normal Process

\code{\link[event]{hpareto}} Log Hazard Function for a Pareto Process

\code{\link[event]{hskewlaplace}} Log Hazard Function for a Skew Laplace Process

\code{\link[event]{hstudent}} Log Hazard Function for a Student Process

\code{\link[event]{hweibull}} Log Hazard Function for a Weibull Process

\code{\link[event]{ident}} Create an Individual Identification Vector for a Point Process

\code{\link[event]{kalsurv}} Generalized Repeated Measurements Models for Event Histories

\code{\link[event]{km}} Kaplan-Meier Survival Curves

\code{\link[event]{pbirth}} Fit Overdispersed Count Data as a Birth Process

\code{\link[event]{pp}} Create a Point Process Vector from Times between Events

\code{\link[event]{read.list}} Read a List of Matrices of Unbalanced Repeated Measurements from a File

\code{\link[event]{read.surv}} Read a List of Vectors of Event Histories from a File

\code{\link[event]{survkit}} Weibull and Cox Models with Random Effects

\code{\link[event]{tccov}} Create a Vector of Time-constant Covariates for a Point Process

\code{\link[event]{tpast}} Create a Vector of Times Past since Previous Events for a Point Process

\code{\link[event]{ttime}} Create a Vector of Total Time Elapsed for each Individual for a Point Process

\code{\link[event]{tvcov}} Create a Vector of Time-varying Covariates for a Point Process
}
\keyword{documentation}
\name{event}
\title{Event History Analysis Library}
\alias{event}
\description{
\code{\link[event]{autointensity}} Plot Autointensity Function of a Point Process

\code{\link[event]{bp}} Create a Vector of Cumulative Numbers of Previous Events for a Point Process

\code{\link[event]{coxre}} Cox Proportional Hazards Model with Random Effect

\code{\link[event]{cprocess}} Counting Process Plot

\code{\link[event]{ehr}} Fit an Intensity Function to Event Histories

\code{\link[event]{hboxcox}} Log Hazard Function for a Box-Cox Process

\code{\link[event]{hburr}} Log Hazard Function for a Burr Process

\code{\link[event]{hcauchy}} Log Hazard Function for a Cauchy Process

\code{\link[event]{hexp}} Log Hazard Function for an Exponential (Poisson) Process

\code{\link[event]{hgamma}} Log Hazard Function for a Gamma Process

\code{\link[event]{hgextval}} Log Hazard Function for an Extreme Value Process

\code{\link[event]{hggamma}} Log Hazard Function for a Generalized Gamma Process

\code{\link[event]{hglogis}} Log Hazard Function for a Generalized Logistic Process

\code{\link[event]{hgweibull}} Log Hazard Function for a Generalized Weibull Process

\code{\link[event]{hhjorth}} Log Hazard Function for a Hjorth Process

\code{\link[event]{hinvgauss}} Log Hazard Function for a Inverse Gauss Process

\code{\link[event]{hlaplace}} Log Hazard Function for a Laplace Process

\code{\link[event]{hlnorm}} Log Hazard Function for a Log Normal Process

\code{\link[event]{hlogis}} Log Hazard Function for a Logistic Process

\code{\link[event]{hnorm}} Log Hazard Function for a Normal Process

\code{\link[event]{hpareto}} Log Hazard Function for a Pareto Process

\code{\link[event]{hskewlaplace}} Log Hazard Function for a Skew Laplace Process

\code{\link[event]{hstudent}} Log Hazard Function for a Student Process

\code{\link[event]{hweibull}} Log Hazard Function for a Weibull Process

\code{\link[event]{ident}} Create an Individual Identification Vector for a Point Process

\code{\link[event]{kalsurv}} Generalized Repeated Measurements Models for Event Histories

\code{\link[event]{km}} Kaplan-Meier Survival Curves

\code{\link[event]{pbirth}} Fit Overdispersed Count Data as a Birth Process

\code{\link[event]{pp}} Create a Point Process Vector from Times between Events

\code{\link[rmutil]{read.list}} Read a List of Matrices of Unbalanced Repeated Measurements from a File

\code{\link[rmutil]{read.surv}} Read a List of Vectors of Event Histories from a File

\code{\link[event]{survkit}} Weibull and Cox Models with Random Effects

\code{\link[event]{tccov}} Create a Vector of Time-constant Covariates for a Point Process

\code{\link[event]{tpast}} Create a Vector of Times Past since Previous Events for a Point Process

\code{\link[event]{ttime}} Create a Vector of Total Time Elapsed for each Individual for a Point Process

\code{\link[event]{tvcov}} Create a Vector of Time-varying Covariates for a Point Process
}
\keyword{documentation}
@@ -0,0 +1,40 @@
\name{hboxcox}
\title{Log Hazard Function for a Box-Cox Process}
\usage{
hboxcox(y, m, s, f)
}
\alias{hboxcox}
\description{
This function provides information about the Box-Cox
distribution with location parameter equal to \code{m}, dispersion
equal to \code{s}, and power transformation equal to \code{f}: log hazard.
(See `rmutil` for the d/p/q/r boxcox functions density,
cumulative distribution, quantiles, and random generation).

The Box-Cox distribution has density
\deqn{
f(y) =
\frac{1}{\sqrt{2 \pi \sigma^2}} \exp(-((y^\nu/\nu-\mu)^2/(2 \sigma^2)))/
(1-I(\nu<0)-sign(\nu)*pnorm(0,\mu,sqrt(\sigma)))}{
f(y) = 1/sqrt(2 pi s^2) exp(-((y^f/f - mu)^2/(2 s^2)))/
(1-I(f<0)-sign(f)*pnorm(0,m,sqrt(s)))}
where \eqn{\mu}{m} is the location parameter of the distribution,
\eqn{\sigma}{s} is the dispersion, \eqn{\nu}{f} is the family
parameter, \eqn{I()} is the indicator function, and \eqn{y>0}.

\eqn{\nu=1}{f=1} gives a truncated normal distribution.
}
\arguments{
\item{y}{vector of responses.}
\item{m}{vector of location parameters.}
\item{s}{vector of dispersion parameters.}
\item{f}{vector of power parameters.}
}
\author{J.K. Lindsey}
\seealso{
\code{\link{dnorm}} for the normal or Gaussian distribution.
}
\examples{
hboxcox(2, 5, 5, 2)
}
\keyword{distribution}
@@ -0,0 +1,33 @@
\name{hburr}
\title{Log Hazard Function for a Burr Process}
\usage{
hburr(y, m, s, f)
}
\alias{hburr}
\description{
These functions provide information about the Burr distribution with
location parameter equal to \code{m}, dispersion equal to
\code{s}, and family parameter equal to \code{f}: log hazard.
(See `rmutil` for the d/p/q/r boxcox functions density,
cumulative distribution, quantiles, and random generation).

The Burr distribution has density
\deqn{
f(y) = \frac{\nu \sigma (y / \mu)^{\sigma-1}}
{\mu (1+(y/\mu)^\sigma)^{\nu+1}}}{
f(y) = f s (y/m)^(s-1)/(m (1+(y/m)^s)^(f+1))}
where \eqn{\mu}{m} is the location parameter of the distribution,
\eqn{\sigma}{s} is the dispersion, and \eqn{\nu}{f} is the family
parameter.
}
\arguments{
\item{y}{vector of responses.}
\item{m}{vector of location parameters.}
\item{s}{vector of dispersion parameters.}
\item{f}{vector of family parameters.}
}
\author{J.K. Lindsey}
\examples{
hburr(2, 5, 1, 2)
}
\keyword{distribution}
@@ -1,30 +1,31 @@
\name{hcauchy}
\title{Hazard Function for a Cauchy Process}
\alias{hcauchy}
\usage{
hcauchy(y, m, s)
}
\arguments{
\item{y}{Vector of times.}
\item{m}{Location parameter.}
\item{s}{Dispersion parameter.}
}
\value{
\code{hcauchy} returns the log hazard function for a Cauchy process with
the given parameter values.
}
\author{J.K. Lindsey}
\seealso{
\code{\link[rmutil]{hboxcox}}, \code{\link[rmutil]{hburr}},
\code{\link[event]{hexp}}, \code{\link[rmutil]{hgextval}},
\code{\link[event]{hgamma}}, \code{\link[rmutil]{hggamma}},
\code{\link[rmutil]{hhjorth}}, \code{\link[rmutil]{hinvgauss}},
\code{\link[rmutil]{hlaplace}}, \code{\link[event]{hlnorm}},
\code{\link[event]{hlogis}}, \code{\link[rmutil]{hglogis}},
\code{\link[event]{hnorm}}, \code{\link[event]{hstudent}},
\code{\link[event]{hweibull}}, \code{\link[rmutil]{hgweibull}}.
}
\examples{
hcauchy(1:10, 3, 2)
}
\keyword{distribution}
\name{hcauchy}
\title{ Log Hazard Function for a Cauchy Process}
\alias{hcauchy}
\usage{
hcauchy(y, m, s)
}
\description{ Log Hazard Function for a Cauchy Process}
\arguments{
\item{y}{Vector of times.}
\item{m}{Location parameter.}
\item{s}{Dispersion parameter.}
}
\value{
\code{hcauchy} returns the log hazard function for a Cauchy process with
the given parameter values.
}
\author{J.K. Lindsey}
\seealso{
\code{\link[event]{hboxcox}}, \code{\link[event]{hburr}},
\code{\link[event]{hexp}}, \code{\link[event]{hgextval}},
\code{\link[event]{hgamma}}, \code{\link[event]{hggamma}},
\code{\link[event]{hhjorth}}, \code{\link[event]{hinvgauss}},
\code{\link[event]{hlaplace}}, \code{\link[event]{hlnorm}},
\code{\link[event]{hlogis}}, \code{\link[event]{hglogis}},
\code{\link[event]{hnorm}}, \code{\link[event]{hstudent}},
\code{\link[event]{hweibull}}, \code{\link[event]{hgweibull}}.
}
\examples{
hcauchy(1:10, 3, 2)
}
\keyword{distribution}
@@ -1,29 +1,30 @@
\name{hexp}
\title{Hazard Function for a Poisson Process}
\alias{hexp}
\usage{
hexp(y, rate)
}
\arguments{
\item{y}{Vector of times.}
\item{rate}{Vector of rates.}
}
\value{
\code{hexp} returns the log hazard function for a Poisson process with
the given parameter value.
}
\author{J.K. Lindsey}
\seealso{
\code{\link[rmutil]{hboxcox}}, \code{\link[rmutil]{hburr}},
\code{\link[event]{hexp}}, \code{\link[rmutil]{hgextval}},
\code{\link[event]{hgamma}}, \code{\link[rmutil]{hggamma}},
\code{\link[rmutil]{hhjorth}}, \code{\link[rmutil]{hinvgauss}},
\code{\link[rmutil]{hlaplace}}, \code{\link[event]{hlnorm}},
\code{\link[event]{hlogis}}, \code{\link[rmutil]{hglogis}},
\code{\link[event]{hnorm}}, \code{\link[event]{hstudent}},
\code{\link[event]{hweibull}}, \code{\link[rmutil]{hgweibull}}.
}
\examples{
hexp(1:10, 3)
}
\keyword{distribution}
\name{hexp}
\title{Log Hazard Function for a Poisson Process}
\alias{hexp}
\usage{
hexp(y, rate)
}
\description{Log Hazard Function for a Poisson Process}
\arguments{
\item{y}{Vector of times.}
\item{rate}{Vector of rates.}
}
\value{
\code{hexp} returns the log hazard function for a Poisson process with
the given parameter value.
}
\author{J.K. Lindsey}
\seealso{
\code{\link[event]{hboxcox}}, \code{\link[event]{hburr}},
\code{\link[event]{hexp}}, \code{\link[event]{hgextval}},
\code{\link[event]{hgamma}}, \code{\link[event]{hggamma}},
\code{\link[event]{hhjorth}}, \code{\link[event]{hinvgauss}},
\code{\link[event]{hlaplace}}, \code{\link[event]{hlnorm}},
\code{\link[event]{hlogis}}, \code{\link[event]{hglogis}},
\code{\link[event]{hnorm}}, \code{\link[event]{hstudent}},
\code{\link[event]{hweibull}}, \code{\link[event]{hgweibull}}.
}
\examples{
hexp(1:10, 3)
}
\keyword{distribution}
@@ -1,31 +1,32 @@
\name{hgamma}
\title{Hazard Function for a Gamma Process}
\alias{hgamma}
\usage{
hgamma(y, shape, rate=1, scale=1/rate)
}
\arguments{
\item{y}{Vector of times.}
\item{shape}{Shape parameter.}
\item{rate}{Rate parameter.}
\item{scale}{Scale parameter.}
}
\value{
\code{hgamma} returns the log hazard function for a gamma process with
the given parameter values.
}
\author{J.K. Lindsey}
\seealso{
\code{\link[rmutil]{hboxcox}}, \code{\link[rmutil]{hburr}},
\code{\link[event]{hexp}}, \code{\link[rmutil]{hgextval}},
\code{\link[event]{hcauchy}}, \code{\link[rmutil]{hggamma}},
\code{\link[rmutil]{hhjorth}}, \code{\link[rmutil]{hinvgauss}},
\code{\link[rmutil]{hlaplace}}, \code{\link[event]{hlnorm}},
\code{\link[event]{hlogis}}, \code{\link[rmutil]{hglogis}},
\code{\link[event]{hnorm}}, \code{\link[event]{hstudent}},
\code{\link[event]{hweibull}}, \code{\link[rmutil]{hgweibull}}.
}
\examples{
hgamma(1:10, 3, 2)
}
\keyword{distribution}
\name{hgamma}
\title{Log Hazard Function for a Gamma Process}
\alias{hgamma}
\usage{
hgamma(y, shape, rate=1, scale=1/rate)
}
\description{Log Hazard Function for a Gamma Process}
\arguments{
\item{y}{Vector of times.}
\item{shape}{Shape parameter.}
\item{rate}{Rate parameter.}
\item{scale}{Scale parameter.}
}
\value{
\code{hgamma} returns the log hazard function for a gamma process with
the given parameter values.
}
\author{J.K. Lindsey}
\seealso{
\code{\link[event]{hboxcox}}, \code{\link[event]{hburr}},
\code{\link[event]{hexp}}, \code{\link[event]{hgextval}},
\code{\link[event]{hcauchy}}, \code{\link[event]{hggamma}},
\code{\link[event]{hhjorth}}, \code{\link[event]{hinvgauss}},
\code{\link[event]{hlaplace}}, \code{\link[event]{hlnorm}},
\code{\link[event]{hlogis}}, \code{\link[event]{hglogis}},
\code{\link[event]{hnorm}}, \code{\link[event]{hstudent}},
\code{\link[event]{hweibull}}, \code{\link[event]{hgweibull}}.
}
\examples{
hgamma(1:10, 3, 2)
}
\keyword{distribution}
@@ -0,0 +1,43 @@
\name{hgextval}
\title{ Log Hazard Function for an Extreme Value Process}
\usage{
hgextval(y, s, m, f)
}
\alias{hgextval}
\description{
These functions provide information about the generalized extreme
value distribution with location parameter equal to \code{m}, dispersion
equal to \code{s}, and family parameter equal to \code{f}:log hazard.
(See `rmutil` for the d/p/q/r boxcox functions density,
cumulative distribution, quantiles, and random generation).

The generalized extreme value distribution has density
\deqn{
f(y) =
y^{\nu-1} \exp(y^\nu/\nu) \frac{\sigma}{\mu}
\frac{\exp(y^\nu/\nu)}{\mu^{\sigma-1}/(1-I(\nu>0)+sign(\nu)
exp(-\mu^-\sigma))}\exp(-(\exp(y^\nu\nu)/\mu)^\sigma)}{
f(y) = y^(f-1) exp(y^f/f) (s/m) (exp(y^f/f)/m)^(s-1)
exp(-(exp(y^f/f)/m)^s)/(1-I(f>0)+sign(f) exp(-m^-s))}

where \eqn{\mu}{m} is the location parameter of the distribution,
\eqn{\sigma}{s} is the dispersion, \eqn{\nu}{f} is the family
parameter, \eqn{I()} is the indicator function, and \eqn{y>0}.

\eqn{\nu=1}{f=1} a truncated extreme value distribution.
}
\arguments{
\item{y}{vector of responses.}
\item{m}{vector of location parameters.}
\item{s}{vector of dispersion parameters.}
\item{f}{vector of family parameters.}
}
\author{J.K. Lindsey}

\seealso{
\code{\link{dweibull}} for the Weibull distribution.
}
\examples{
hgextval(1, 2, 1, 2)
}
\keyword{distribution}
@@ -0,0 +1,44 @@
\name{hggamma}
\title{Log Hazard Function for a Generalized Gamma Process}
\usage{
hggamma(y, s, m, f)
}
\alias{hggamma}
\description{
These functions provide information about the generalized gamma
distribution with scale parameter equal to \code{m}, shape equal
to \code{s}, and family parameter equal to \code{f}: log hazard.
(See `rmutil` for the d/p/q/r boxcox functions density,
cumulative distribution, quantiles, and random generation).

The generalized gamma distribution has density
\deqn{
f(y) = \frac{\nu y^{\nu-1}}
{(\mu/\sigma)^{\nu\sigma} Gamma(\sigma)} y^{\nu(\sigma-1)}
\exp(-(y \sigma/\mu)^\nu)}{
f(y) = fy^(f-1)/((m/s)^(fs) Gamma(s)) y^(f(s-1)) exp(-(y s/m)^f)}

where \eqn{\mu}{m} is the scale parameter of the distribution,
\eqn{\sigma}{s} is the shape, and \eqn{\nu}{f} is the family
parameter.

\eqn{\nu=1}{f=1} yields a gamma distribution, \eqn{\sigma=1}{s=1} a
Weibull distribution, and \eqn{\sigma=\infty}{s=infinity} a
log normal distribution.
}
\arguments{
\item{y}{vector of responses.}
\item{m}{vector of location parameters.}
\item{s}{vector of dispersion parameters.}
\item{f}{vector of family parameters.}
}
\author{J.K. Lindsey}
\seealso{
\code{\link{dgamma}} for the gamma distribution,
\code{\link{dweibull}} for the Weibull distribution, \code{\link{dlnorm}}
for the log normal distribution.
}
\examples{
hggamma(2, 5, 4, 2)
}
\keyword{distribution}
@@ -0,0 +1,41 @@
\name{hglogis}
\title{Log Hazard Function for a Generalized Logistic Process}
\usage{
hglogis(y, m, s, f)
}
\alias{hglogis}
\description{
These functions provide information about the generalized logistic
distribution with location parameter equal to \code{m}, dispersion equal
to \code{s}, and family parameter equal to \code{f}: log hazard.
(See `rmutil` for the d/p/q/r boxcox functions density,
cumulative distribution, quantiles, and random generation).

The generalized logistic distribution has density
\deqn{
f(y) =
\frac{\nu \sqrt{3} \exp(-\sqrt{3} (y-\mu)/(\sigma \pi))}{
\sigma \pi (1+\exp(-\sqrt{3} (y-\mu)/(\sigma \pi)))^{\nu+1}}}{
f(y) = f sqrt(3) exp(-sqrt(3) (y-m)/(s pi))/
(s pi (1+exp(-sqrt(3) (y-m)/(s pi)))^(f+1))}

where \eqn{\mu}{m} is the location parameter of the distribution,
\eqn{\sigma}{s} is the dispersion, and \eqn{\nu}{f} is the family
parameter.

\eqn{\nu=1}{f=1} gives a logistic distribution.
}
\arguments{
\item{y}{vector of responses.}
\item{m}{vector of location parameters.}
\item{s}{vector of dispersion parameters.}
\item{f}{vector of family parameters.}
}
\author{J.K. Lindsey}
\seealso{
\code{\link{dlogis}} for the logistic distribution.
}
\examples{
hglogis(5, 5, 1, 2)
}
\keyword{distribution}
@@ -0,0 +1,44 @@
\name{hgweibull}
\title{Log Hazard Function for a Generalized Weibull Process}
\usage{
hgweibull(y, s, m, f)
}
\alias{hgweibull}
\description{
These functions provide information about the generalized Weibull
distribution, also called the exponentiated Weibull, with scale
parameter equal to \code{m}, shape equal to \code{s}, and family
parameter equal to \code{f}: log hazard.
(See `rmutil` for the d/p/q/r boxcox functions density,
cumulative distribution, quantiles, and random generation).

The generalized Weibull distribution has density
\deqn{
f(y) = \frac{\sigma \nu y^{\sigma-1} (1-\exp(-(y/\mu)^\sigma))^{\nu-1}
\exp(-(y/\mu)^\sigma)}{\mu^\sigma}}{
f(y) = s f y^(s-1) (1-exp(-(y/m)^s))^(f-1) exp(-(y/m)^s)/m^s}

where \eqn{\mu}{m} is the scale parameter of the distribution,
\eqn{\sigma}{s} is the shape, and \eqn{\nu}{f} is the family
parameter.

\eqn{\nu=1}{f=1} gives a Weibull distribution, for
\eqn{\sigma=1}{s=1}, \eqn{\nu<0}{f<0} a generalized F distribution,
and for \eqn{\sigma>0}{s>0}, \eqn{\nu\leq0}{f<=0} a Burr type XII distribution.
}
\arguments{
\item{y}{vector of responses.}
\item{m}{vector of location parameters.}
\item{s}{vector of dispersion parameters.}
\item{f}{vector of family parameters.}
}
\author{J.K. Lindsey}
\seealso{
\code{\link{dweibull}} for the Weibull distribution,
\code{\link{df}} for the F distribution,
\code{\link[rmutil]{dburr}} for the Burr distribution.
}
\examples{
hgweibull(5, 1, 3, 2)
}
\keyword{distribution}
@@ -0,0 +1,35 @@
\name{hhjorth}
\title{Log Hazard Function for a Hjorth Process}
\usage{
hhjorth(y, m, s, f)
}
\alias{hhjorth}
\description{
These functions provide information about the Hjorth
distribution with location parameter equal to \code{m}, dispersion equal
to \code{s}, and family parameter equal to \code{f}: log hazard.
(See `rmutil` for the d/p/q/r boxcox functions density,
cumulative distribution, quantiles, and random generation).


The Hjorth distribution has density
\deqn{
f(y) = (1+\sigma y)^{-\nu/\sigma} \exp(-(y/\mu)^2/2)
(\frac{y}{\mu^2}+\frac{\nu}{1+\sigma y})}{
f(y) = (1+s y)^(-f/s) exp(-(y/m)^2/2) (y/m^2+f/(1+s y))}

where \eqn{\mu}{m} is the location parameter of the distribution,
\eqn{\sigma}{s} is the dispersion, and \eqn{\nu}{f} is the family
parameter.
}
\arguments{
\item{y}{vector of responses.}
\item{m}{vector of location parameters.}
\item{s}{vector of dispersion parameters.}
\item{f}{vector of family parameters.}
}
\author{J.K. Lindsey}
\examples{
hhjorth(5, 5, 5, 2)
}
\keyword{distribution}
@@ -0,0 +1,35 @@
\name{hinvgauss}
\title{Log Hazard Function for a Inverse Gauss Process}
\usage{
hinvgauss(y, m, s)
}
\alias{hinvgauss}
\description{
These functions provide information about the inverse Gaussian
distribution with mean equal to \code{m} and dispersion equal to
\code{s}: log hazard.
(See `rmutil` for the d/p/q/r boxcox functions density,
cumulative distribution, quantiles, and random generation).

The inverse Gaussian distribution has density
\deqn{
f(y) =
\frac{1}{\sqrt{2\pi\sigma y^3}} e^{-(y-\mu)^2/(2 y \sigma m^2)}}{
f(y) = 1/sqrt(2 pi s y^3) e^-((y - m)^2/(2 y s m^2))}
where \eqn{\mu}{m} is the mean of the distribution and
\eqn{\sigma}{s} is the dispersion.
}
\arguments{
\item{y}{vector of responses.}
\item{m}{vector of means.}
\item{s}{vector of dispersion parameters.}
}
\author{J.K. Lindsey}
\seealso{
\code{\link{dnorm}} for the normal distribution and
\code{\link{dlnorm}} for the \emph{Log}normal distribution.
}
\examples{
hinvgauss(5, 5, 1)
}
\keyword{distribution}
@@ -0,0 +1,34 @@
\name{hlaplace}
\title{Log Hazard Function for a Laplace Process}
\usage{
hlaplace(y, m=0, s=1)
}
\alias{hlaplace}
\description{
These functions provide information about the Laplace distribution
with location parameter equal to \code{m} and dispersion equal to
\code{s}: log hazard.
(See `rmutil` for the d/p/q/r boxcox functions density,
cumulative distribution, quantiles, and random generation).

The Laplace distribution has density
\deqn{
f(y) = \frac{\exp(-abs(y-\mu)/\sigma)}{(2\sigma)}}{
f(y) = exp(-abs(y-m)/s)/(2*s)}
where \eqn{\mu}{m} is the location parameter of the distribution and
\eqn{\sigma}{s} is the dispersion.
}
\arguments{
\item{y}{vector of responses.}
\item{m}{vector of location parameters.}
\item{s}{vector of dispersion parameters.}
}
\author{J.K. Lindsey}
\seealso{
\code{\link{dexp}} for the exponential distribution and
\code{\link{dcauchy}} for the Cauchy distribution.
}
\examples{
hlaplace(5, 2, 1)
}
\keyword{distribution}
@@ -1,30 +1,31 @@
\name{hlnorm}
\title{Hazard Function for a Log Normal Process}
\alias{hlnorm}
\usage{
hlnorm(y, m, s)
}
\arguments{
\item{y}{Vector of times.}
\item{m}{Mean parameter.}
\item{s}{Variance parameter.}
}
\value{
\code{hlnorm} returns the log hazard function for a log normal
process with the given parameter values.
}
\author{J.K. Lindsey}
\seealso{
\code{\link[rmutil]{hboxcox}}, \code{\link[rmutil]{hburr}},
\code{\link[event]{hexp}}, \code{\link[rmutil]{hgextval}},
\code{\link[event]{hcauchy}}, \code{\link[event]{hgamma}},
\code{\link[rmutil]{hggamma}}, \code{\link[rmutil]{hhjorth}},
\code{\link[rmutil]{hinvgauss}}, \code{\link[rmutil]{hlaplace}},
\code{\link[event]{hlogis}}, \code{\link[rmutil]{hglogis}},
\code{\link[event]{hnorm}}, \code{\link[event]{hstudent}},
\code{\link[event]{hweibull}}, \code{\link[rmutil]{hgweibull}}.
}
\examples{
hlnorm(1:10, 3, 2)
}
\keyword{distribution}
\name{hlnorm}
\title{Log Hazard Function for a Log Normal Process}
\alias{hlnorm}
\usage{
hlnorm(y, m, s)
}
\description{Log Hazard Function for a Log Normal Process}
\arguments{
\item{y}{Vector of times.}
\item{m}{Mean parameter.}
\item{s}{Variance parameter.}
}
\value{
\code{hlnorm} returns the log hazard function for a log normal
process with the given parameter values.
}
\author{J.K. Lindsey}
\seealso{
\code{\link[event]{hboxcox}}, \code{\link[event]{hburr}},
\code{\link[event]{hexp}}, \code{\link[event]{hgextval}},
\code{\link[event]{hcauchy}}, \code{\link[event]{hgamma}},
\code{\link[event]{hggamma}}, \code{\link[event]{hhjorth}},
\code{\link[event]{hinvgauss}}, \code{\link[event]{hlaplace}},
\code{\link[event]{hlogis}}, \code{\link[event]{hglogis}},
\code{\link[event]{hnorm}}, \code{\link[event]{hstudent}},
\code{\link[event]{hweibull}}, \code{\link[event]{hgweibull}}.
}
\examples{
hlnorm(1:10, 3, 2)
}
\keyword{distribution}
@@ -1,28 +1,29 @@
\name{hlogis}
\title{Hazard Function for a Logistic Process}
\alias{hlogis}
\usage{
hlogis(y, m, s)
}
\arguments{
\item{y}{Vector of times.}
\item{m}{Location parameter.}
\item{s}{Scale parameter.}
}
\value{
\code{hlogis} returns the log hazard function for a logistic
process with the given parameter values.
}
\author{J.K. Lindsey}
\seealso{
\code{\link{hboxcox}}, \code{\link{hburr}}, \code{\link{hexp}},
\code{\link{hgextval}}, \code{\link{hcauchy}}, \code{\link{hgamma}},
\code{\link{hggamma}}, \code{\link{hhjorth}}, \code{\link{hinvgauss}},
\code{\link{hlaplace}}, \code{\link{hlnorm}}, \code{\link{hglogis}},
\code{\link{hnorm}}, \code{\link{hstudent}}, \code{\link{hweibull}},
\code{\link{hgweibull}}.
}
\examples{
hlogis(1:10, 3, 2)
}
\keyword{distribution}
\name{hlogis}
\title{Log Hazard Function for a Logistic Process}
\alias{hlogis}
\usage{
hlogis(y, m, s)
}
\description{Log Hazard Function for a Logistic Process}
\arguments{
\item{y}{Vector of times.}
\item{m}{Location parameter.}
\item{s}{Scale parameter.}
}
\value{
\code{hlogis} returns the log hazard function for a logistic
process with the given parameter values.
}
\author{J.K. Lindsey}
\seealso{
\code{\link{hboxcox}}, \code{\link{hburr}}, \code{\link{hexp}},
\code{\link{hgextval}}, \code{\link{hcauchy}}, \code{\link{hgamma}},
\code{\link{hggamma}}, \code{\link{hhjorth}}, \code{\link{hinvgauss}},
\code{\link{hlaplace}}, \code{\link{hlnorm}}, \code{\link{hglogis}},
\code{\link{hnorm}}, \code{\link{hstudent}}, \code{\link{hweibull}},
\code{\link{hgweibull}}.
}
\examples{
hlogis(1:10, 3, 2)
}
\keyword{distribution}
@@ -1,30 +1,31 @@
\name{hnorm}
\title{Hazard Function for a Normal Process}
\alias{hnorm}
\usage{
hnorm(y, m, s)
}
\arguments{
\item{y}{Vector of times.}
\item{m}{Mean parameter.}
\item{s}{Variance parameter.}
}
\value{
\code{hnorm} returns the log hazard function for a normal
process with the given parameter values.
}
\author{J.K. Lindsey}
\seealso{
\code{\link[rmutil]{hboxcox}}, \code{\link[rmutil]{hburr}},
\code{\link[event]{hexp}}, \code{\link[rmutil]{hgextval}},
\code{\link[event]{hcauchy}}, \code{\link[event]{hgamma}},
\code{\link[rmutil]{hggamma}}, \code{\link[rmutil]{hhjorth}},
\code{\link[rmutil]{hinvgauss}}, \code{\link[rmutil]{hlaplace}},
\code{\link[event]{hlogis}}, \code{\link[rmutil]{hglogis}},
\code{\link[event]{hlnorm}}, \code{\link[event]{hstudent}},
\code{\link[event]{hweibull}}, \code{\link[rmutil]{hgweibull}}.
}
\examples{
hnorm(1:10, 3, 2)
}
\keyword{distribution}
\name{hnorm}
\title{Log Hazard Function for a Normal Process}
\alias{hnorm}
\usage{
hnorm(y, m, s)
}
\description{Log Hazard Function for a Normal Process}
\arguments{
\item{y}{Vector of times.}
\item{m}{Mean parameter.}
\item{s}{Variance parameter.}
}
\value{
\code{hnorm} returns the log hazard function for a normal
process with the given parameter values.
}
\author{J.K. Lindsey}
\seealso{
\code{\link[event]{hboxcox}}, \code{\link[event]{hburr}},
\code{\link[event]{hexp}}, \code{\link[event]{hgextval}},
\code{\link[event]{hcauchy}}, \code{\link[event]{hgamma}},
\code{\link[event]{hggamma}}, \code{\link[event]{hhjorth}},
\code{\link[event]{hinvgauss}}, \code{\link[event]{hlaplace}},
\code{\link[event]{hlogis}}, \code{\link[event]{hglogis}},
\code{\link[event]{hlnorm}}, \code{\link[event]{hstudent}},
\code{\link[event]{hweibull}}, \code{\link[event]{hgweibull}}.
}
\examples{
hnorm(1:10, 3, 2)
}
\keyword{distribution}
@@ -0,0 +1,36 @@
\name{hpareto}
\title{Log Hazard Function for a Pareto Process}
\usage{
hpareto(y, m, s)
}
\alias{hpareto}
\description{
These functions provide information about the Pareto distribution
with location parameter equal to \code{m} and dispersion equal to
\code{s}: log hazard.
(See `rmutil` for the d/p/q/r boxcox functions density,
cumulative distribution, quantiles, and random generation).

The Pareto distribution has density
\deqn{
f(y) = \frac{\sigma }{\mu (\sigma-1)(1 + y/(\mu (\sigma-1)))^{\sigma+1}}}{
f(y) = s (1 + y/(m (s-1)))^(-s-1)/(m (s-1))}
where \eqn{\mu}{m} is the mean parameter of the distribution and
\eqn{\sigma}{s} is the dispersion.

This distribution can be obtained as a mixture distribution from the
exponential distribution using a gamma mixing distribution.
}
\arguments{
\item{y}{vector of responses.}
\item{m}{vector of location parameters.}
\item{s}{vector of dispersion parameters.}
}
\author{J.K. Lindsey}
\seealso{
\code{\link{dexp}} for the exponential distribution.
}
\examples{
hpareto(5, 2, 2)
}
\keyword{distribution}
@@ -0,0 +1,50 @@
\name{hskewlaplace}
\title{Log Hazard Function for a Skew Laplace Process}
\usage{
hskewlaplace(y, m=0, s=1, f=1)
}
\alias{hskewlaplace}
\description{
These functions provide information about the skew Laplace distribution
with location parameter equal to \code{m}, dispersion equal to
\code{s}, and skew equal to \code{f}: log hazard.
(See `rmutil` for the d/p/q/r boxcox functions density,
cumulative distribution, quantiles, and random generation).
For \code{f=1}, this is an ordinary (symmetric) Laplace distribution.

The skew Laplace distribution has density
\deqn{
f(y) = \frac{\nu\exp(-\nu(y-\mu)/\sigma)}{(1+\nu^2)\sigma}}{
f(y) = f*exp(-f*(y-m)/s)/((1+f^2)*s)}
if \eqn{y\ge\mu}{y>=m} and else
\deqn{
f(y) = \frac{\nu\exp((y-\mu)/(\nu\sigma))}{(1+\nu^2)\sigma}}{
f(y) = f*exp((y-m)/(f*s))/((1+f^2)*s)}
where \eqn{\mu}{m} is the location parameter of the distribution,
\eqn{\sigma}{s} is the dispersion, and \eqn{\nu}{f} is the skew.

The mean is given by \eqn{\mu+\frac{\sigma(1-\nu^2)}{\sqrt{2}\nu}}{m
+ (s * (1 - f^2)) / (sqrt(2) * f)}
and the variance by \eqn{\frac{\sigma^2(1+\nu^4)}{2\nu^2}}{(s^2
* (1 + f^4)) / (2 * f^2)}.

Note that this parametrization of the skew (family) parameter is
different than that used for the multivariate skew Laplace
distribution in 'growth::elliptic'.
}
\arguments{
\item{y}{vector of responses.}
\item{m}{vector of location parameters.}
\item{s}{vector of dispersion parameters.}
\item{f}{vector of skew parameters.}
}
\author{J.K. Lindsey}
\seealso{
\code{\link{dexp}} for the exponential distribution,
\code{\link{dcauchy}} for the Cauchy distribution, and
\code{\link[rmutil]{dlaplace}} for the Laplace distribution.
}
\examples{
hskewlaplace(5, 2, 1, 0.5)
}
\keyword{distribution}
@@ -1,31 +1,32 @@
\name{hstudent}
\title{Hazard Function for a Student t Process}
\alias{hstudent}
\usage{
hstudent(y, m, s, f)
}
\arguments{
\item{y}{Vector of times.}
\item{m}{Location parameter.}
\item{s}{Scale parameter.}
\item{f}{Degrees of freedom.}
}
\value{
\code{hstudent} returns the log hazard function for a Student t
process with the given parameter values.
}
\author{J.K. Lindsey}
\seealso{
\code{\link[rmutil]{hboxcox}}, \code{\link[rmutil]{hburr}},
\code{\link[event]{hexp}}, \code{\link[rmutil]{hgextval}},
\code{\link[event]{hcauchy}}, \code{\link[event]{hgamma}},
\code{\link[rmutil]{hggamma}}, \code{\link[rmutil]{hhjorth}},
\code{\link[rmutil]{hinvgauss}}, \code{\link[rmutil]{hlaplace}},
\code{\link[event]{hlogis}}, \code{\link[rmutil]{hglogis}},
\code{\link[event]{hnorm}}, \code{\link[event]{hnorm}},
\code{\link[event]{hweibull}}, \code{\link[rmutil]{hgweibull}}.
}
\examples{
hstudent(1:10, 3, 2, 5)
}
\keyword{distribution}
\name{hstudent}
\title{Log Hazard Function for a Student t Process}
\alias{hstudent}
\usage{
hstudent(y, m, s, f)
}
\description{Log Hazard Function for a Student t Process}
\arguments{
\item{y}{Vector of times.}
\item{m}{Location parameter.}
\item{s}{Scale parameter.}
\item{f}{Degrees of freedom.}
}
\value{
\code{hstudent} returns the log hazard function for a Student t
process with the given parameter values.
}
\author{J.K. Lindsey}
\seealso{
\code{\link[event]{hboxcox}}, \code{\link[event]{hburr}},
\code{\link[event]{hexp}}, \code{\link[event]{hgextval}},
\code{\link[event]{hcauchy}}, \code{\link[event]{hgamma}},
\code{\link[event]{hggamma}}, \code{\link[event]{hhjorth}},
\code{\link[event]{hinvgauss}}, \code{\link[event]{hlaplace}},
\code{\link[event]{hlogis}}, \code{\link[event]{hglogis}},
\code{\link[event]{hnorm}}, \code{\link[event]{hnorm}},
\code{\link[event]{hweibull}}, \code{\link[event]{hgweibull}}.
}
\examples{
hstudent(1:10, 3, 2, 5)
}
\keyword{distribution}
@@ -1,30 +1,31 @@
\name{hweibull}
\title{Hazard Function for a Weibull Process}
\alias{hweibull}
\usage{
hweibull(y, s, m)
}
\arguments{
\item{y}{Vector of times.}
\item{s}{Shape parameter.}
\item{m}{Scale parameter.}
}
\value{
\code{hweibull} returns the log hazard function for a Weibull
process with the given parameter values.
}
\author{J.K. Lindsey}
\seealso{
\code{\link[rmutil]{hboxcox}}, \code{\link[rmutil]{hburr}},
\code{\link[event]{hexp}}, \code{\link[rmutil]{hgextval}},
\code{\link[event]{hcauchy}}, \code{\link[event]{hgamma}},
\code{\link[rmutil]{hggamma}}, \code{\link[rmutil]{hhjorth}},
\code{\link[rmutil]{hinvgauss}}, \code{\link[rmutil]{hlaplace}},
\code{\link[event]{hlogis}}, \code{\link[rmutil]{hglogis}},
\code{\link[event]{hlnorm}}, \code{\link[event]{hnorm}},
\code{\link[event]{hstudent}}, \code{\link[rmutil]{hgweibull}}.
}
\examples{
hweibull(1:10, 1.5, 2)
}
\keyword{distribution}
\name{hweibull}
\title{Log Hazard Function for a Weibull Process}
\alias{hweibull}
\usage{
hweibull(y, s, m)
}
\description{Log Hazard Function for a Weibull Process}
\arguments{
\item{y}{Vector of times.}
\item{s}{Shape parameter.}
\item{m}{Scale parameter.}
}
\value{
\code{hweibull} returns the log hazard function for a Weibull
process with the given parameter values.
}
\author{J.K. Lindsey}
\seealso{
\code{\link[event]{hboxcox}}, \code{\link[event]{hburr}},
\code{\link[event]{hexp}}, \code{\link[event]{hgextval}},
\code{\link[event]{hcauchy}}, \code{\link[event]{hgamma}},
\code{\link[event]{hggamma}}, \code{\link[event]{hhjorth}},
\code{\link[event]{hinvgauss}}, \code{\link[event]{hlaplace}},
\code{\link[event]{hlogis}}, \code{\link[event]{hglogis}},
\code{\link[event]{hlnorm}}, \code{\link[event]{hnorm}},
\code{\link[event]{hstudent}}, \code{\link[event]{hgweibull}}.
}
\examples{
hweibull(1:10, 1.5, 2)
}
\keyword{distribution}
@@ -1,30 +1,35 @@
\name{ident}
\title{Create an Individual Identification Vector for a Point Process}
\alias{ident}
\usage{
ident(y, id)
}
\arguments{
\item{y}{Vector of times.}
\item{id}{Vector of corresponding individual identifiers for who had
which sequence of times.}
}
\value{
\code{ident} creates a vector of length \code{sum(y)} by repeating the
values of individual identifiers for the times for use with
\code{\link[event]{ehr}}.
}
\author{J.K. Lindsey}
\seealso{
\code{\link[event]{bp}}, \code{\link[event]{ehr}},
\code{\link[event]{pp}}, \code{\link[event]{tccov}},
\code{\link[event]{tpast}}, \code{\link[event]{ttime}},
\code{\link[event]{tvcov}}.
}
\examples{
y <- c(5,3,2,4)
i <- c(1,1,2,2)
id <- ident(y, i)
id
}
\keyword{manip}
\name{ident}
\title{Create an Individual Identification Vector for a Point Process}
\alias{ident}
\usage{
ident(y, id)
}
\description{
\code{ident} creates a vector of length \code{sum(y)} by repeating the
values of individual identifiers for the times for use with
\code{\link[event]{ehr}}.
}
\arguments{
\item{y}{Vector of times.}
\item{id}{Vector of corresponding individual identifiers for who had
which sequence of times.}
}
\value{
\code{ident} creates a vector of length \code{sum(y)} by repeating the
values of individual identifiers for the times for use with
\code{\link[event]{ehr}}.
}
\author{J.K. Lindsey}
\seealso{
\code{\link[event]{bp}}, \code{\link[event]{ehr}},
\code{\link[event]{pp}}, \code{\link[event]{tccov}},
\code{\link[event]{tpast}}, \code{\link[event]{ttime}},
\code{\link[event]{tvcov}}.
}
\examples{
y <- c(5,3,2,4)
i <- c(1,1,2,2)
id <- ident(y, i)
id
}
\keyword{manip}

Large diffs are not rendered by default.

110 man/km.Rd
@@ -1,50 +1,60 @@
\name{km}
\title{Kaplan-Meier Survivor Curves}
\usage{
km(times, censor, group=1, freq=1, cdf=FALSE)
plot.km(z, add=FALSE, xlim, ylim=c(0,1), main=NULL, xlab="Time",
ylab=NULL, lty=NULL, ...)
plot.intensity.km(z, add=FALSE, xlab="Time", ylab="Intensity", type="l",
lty=NULL, ...)
plot.dist.km(z)
}
\alias{km}
\alias{plot.km}
\alias{plot.intensity.km}
\alias{plot.dist}
\alias{plot.dist.km}
\description{
\code{km} calculates the Kaplan-Meier estimates for survival.

To plot the survivor curve, use \code{plot()}; for the empirical
intensity curve, use \code{plot.intensity()}; for diagnostic curves to
choose a distribution to which the data might belong, use \code{plot.dist()}.
}
\arguments{
\item{times}{Vector of times to events or a list of vectors of such
times for different individuals.}
\item{censor}{Vector of censoring indicators corresponding to the
vector of times or to the last time in each vector of a list.}
\item{group}{Vector indicating to which group each individual belongs.}
\item{freq}{Vector of frequencies for grouped data.}
\item{cdf}{If TRUE, calculate the cdf instead of the survivor curve.}
\item{z}{An object produced by \code{km}.}
}
\value{
A matrix with class, \code{km}, containing the Kaplan-Meier estimates
is returned.
}
\author{J.K. Lindsey}
\seealso{
\code{\link[event]{plot.intensity}}, \code{\link[event]{plot.survivor}}
}
\examples{
surv <- rgamma(40,2,scale=5)
cens <- rbinom(40,1,0.9)
treat <- gl(2,20)
plot(km(surv, cens, group=treat), main="",xlab="Months",
ylab="Probability of deterioration")
plot.dist(km(surv, cens, group=treat))
plot.intensity(km(surv, cens, group=treat),ylab="Risk of deterioration")
}
\keyword{hplot}
\name{km}
\title{Kaplan-Meier Survivor Curves}
\usage{
km(times, censor, group=1, freq=1, cdf=FALSE)
\method{plot}{km}(x, add=FALSE, xlim=NULL, ylim=c(0,1),
main=NULL, xlab="Time", ylab=NULL, lty=NULL, ...)
\method{plot.intensity}{km}(x, add=FALSE, xlab="Time", ylab="Hazard", type="l", lty=NULL, ...)
\method{plot.dist}{km}(x, ...)
}
\alias{km}
\alias{plot.surv}
\alias{plot.km}
\alias{print.km}
\alias{plot.intensity.km}
\alias{plot.dist}
\alias{plot.dist.km}
\description{
\code{km} calculates the Kaplan-Meier estimates for survival.

To plot the survivor curve, use \code{plot()}; for the empirical
intensity curve, use \code{plot.intensity()}; for diagnostic curves to
choose a distribution to which the data might belong, use \code{plot.dist()}.
}
\arguments{
\item{times}{Vector of times to events or a list of vectors of such
times for different individuals.}
\item{censor}{Vector of censoring indicators corresponding to the
vector of times or to the last time in each vector of a list.}
\item{group}{Vector indicating to which group each individual belongs.}
\item{freq}{Vector of frequencies for grouped data.}
\item{cdf}{If TRUE, calculate the cdf instead of the survivor curve.}
\item{x}{An object produced by \code{km}.}
\item{add}{Plotting control options.}
\item{main}{Plotting control options.}
\item{type}{Plotting control options.}
\item{ylab}{Plotting control options.}
\item{xlab}{Plotting control options.}
\item{xlim}{Plotting control options.}
\item{ylim}{Plotting control options.}
\item{lty}{Plotting control options.}
\item{...}{Plotting control options.}
}
\value{
A matrix with class, \code{km}, containing the Kaplan-Meier estimates
is returned.
}
\author{J.K. Lindsey}
\seealso{
\code{\link[event]{plot.intensity}}, \code{\link[event]{plot.surv}}
}
\examples{
surv <- rgamma(40,2,scale=5)
cens <- rbinom(40,1,0.9)
treat <- gl(2,20)
plot(km(surv, cens, group=treat), main="",xlab="Months",
ylab="Probability of deterioration")
plot.dist(km(surv, cens, group=treat))
plot.intensity(km(surv, cens, group=treat),ylab="Risk of deterioration")
}
\keyword{hplot}
@@ -1,43 +1,52 @@
\name{pbirth}
\title{Fit Overdispersed Count Data as a Birth Process}
\alias{pbirth}
\usage{
pbirth(frequencies, p, intensity="negative binomial",
type="spectral decomposition", print.level=0, ndigit=10,
gradtol=0.00001, steptol=0.00001, fscale=1, iterlim=100,
typsiz=abs(p), stepmax=10*sqrt(p\%*\%p))
}
\description{
\code{pbirth} fits binomial, binomial exponential, binomial logistic,
binomial total, Poisson, Poisson exponential, negative binomial,
gen(eralized) negative binomial, and generalized negative binomial
processes as a birth process.
}
\arguments{
\item{frequencies}{Vector of frequencies or a matrix with each row a
different series of frequencies.}
\item{p}{Vector of initial estimates.}
\item{intensity}{The intensity function of the process: binomial,
binomial exdponential, binomial logistic, binomial total,
Poisson, Poisson exponential, negative binomial, or gen(eralized)
negative binomial.}
\item{type}{Algorithm used for matrix exponentiation: spectral
decomposition or series approximation.}
\item{others}{Arguments controlling \code{\link{nlm}}.}
}
\references{
Faddy, M.J. and Fenlon, J.S. (1999) Stochastic modelling of the
invasion process of nematodes in fly larvae. Applied Statistics 48:
31-37.
}
\author{J.K. Lindsey}
\examples{
y <- rnbinom(100,2,0.6)
fr <- tabulate(y)
pbirth(fr, p=log(-log(0.7)), intensity="Poisson", type="series")
pbirth(fr, p=c(log(-log(0.7)),log(5)),
intensity="negative binomial", type="series")
pbirth(fr, p=c(log(-log(0.7)),log(5),-1),
intensity="gen negative binomial", type="series")
}
\keyword{models}
\name{pbirth}
\title{Fit Overdispersed Count Data as a Birth Process}
\alias{pbirth}
\alias{deviance.pbirth}
\alias{print.pbirth}
\usage{
pbirth(frequencies, p, intensity="negative binomial",
type="spectral decomposition", print.level=0, ndigit=10,
gradtol=0.00001, steptol=0.00001, fscale=1, iterlim=100,
typsize=abs(p), stepmax=10*sqrt(p\%*\%p))
}
\description{
\code{pbirth} fits binomial, binomial exponential, binomial logistic,
binomial total, Poisson, Poisson exponential, negative binomial,
gen(eralized) negative binomial, and generalized negative binomial
processes as a birth process.
}
\arguments{
\item{frequencies}{Vector of frequencies or a matrix with each row a
different series of frequencies.}
\item{p}{Vector of initial estimates.}
\item{intensity}{The intensity function of the process: binomial,
binomial exdponential, binomial logistic, binomial total,
Poisson, Poisson exponential, negative binomial, or gen(eralized)
negative binomial.}
\item{type}{Algorithm used for matrix exponentiation: spectral
decomposition or series approximation.}
\item{print.level}{\code{nlm} control options.}
\item{ndigit}{\code{nlm} control options.}
\item{gradtol}{\code{nlm} control options.}
\item{steptol}{\code{nlm} control options.}
\item{iterlim}{\code{nlm} control options.}
\item{fscale}{\code{nlm} control options.}
\item{typsize}{\code{nlm} control options.}
\item{stepmax}{\code{nlm} control options.}
}
\references{
Faddy, M.J. and Fenlon, J.S. (1999) Stochastic modelling of the
invasion process of nematodes in fly larvae. Applied Statistics 48:
31-37.
}
\author{J.K. Lindsey}
\examples{
y <- rnbinom(100,2,0.6)
fr <- tabulate(y)
pbirth(fr, p=log(-log(0.7)), intensity="Poisson", type="series")
pbirth(fr, p=c(log(-log(0.7)),log(5)),
intensity="negative binomial", type="series")
pbirth(fr, p=c(log(-log(0.7)),log(5),-1),
intensity="gen negative binomial", type="series")
}
\keyword{models}
@@ -1,35 +1,42 @@
\name{plot.intensity}
\title{Plot Intensity Functions}
\alias{plot.intensity}
\usage{
plot.intensity(z, ...)
plot.intensity.default(times, censor=1, group=1, colour=TRUE, mix=1,
ylim=c(0,1), ylab="p", xlab="Time",
main="Empirical Intensity Function(s)")
}
\description{
Plot the empirical intensity curve for given times between events.
}
\arguments{
\item{times}{Vector of times to events or a list of vectors of such
times for different individuals.}
\item{censor}{Vector of censoring indicators corresponding to the
vector of times or to the last time in each vector of a list.}
\item{group}{Vector indicating to which group each individual
belongs.}
\item{colour}{Use a different colour for each curve.}
}
\author{J.K. Lindsey}
\seealso{
\code{\link[event]{km}}, \code{\link[event]{plot.survivor}}
}
\examples{
surv <- rgamma(40,2,scale=5)
cens <- rbinom(40,1,0.9)
treat <- gl(2,20)
plot(km(surv, cens, group=treat), main="",xlab="Months",
ylab="Probability of deterioration")
plot.dist(km(surv, cens, group=treat))
plot.intensity(km(surv, cens, group=treat),ylab="Risk of deterioration")
}
\keyword{hplot}
\name{plot.intensity}
\title{Plot Intensity Functions}
\alias{plot.intensity}
\alias{plot.intensity.default}
\usage{
\method{plot}{intensity}(x, ...)
\method{plot.intensity}{default}(x, censor=1, group=1, colour=TRUE, mix=1,
ylim=c(0,1), ylab="p", xlab="Time",
main="Empirical Hazard Function(s)", ...)
}
\description{
Plot the empirical intensity curve for given times between events.
}
\arguments{
\item{censor}{Vector of censoring indicators corresponding to the
vector of times or to the last time in each vector of a list.}
\item{group}{Vector indicating to which group each individual
belongs.}
\item{colour}{Use a different colour for each curve.}
\item{x}{An object produced by \code{km} for \code{plot.intensity}; for \code{plot.intensity.default} it is \code{times} (Vector of times to events or a list of vectors of such
times for different individuals.) These changes were made for S3 methods compatability.}
\item{mix}{...}
\item{main}{Plotting control options.}
\item{ylab}{Plotting control options.}
\item{xlab}{Plotting control options.}
\item{ylim}{Plotting control options.}
\item{...}{Plotting control options.}
}
\author{J.K. Lindsey}
\seealso{
\code{\link[event]{km}}, \code{\link[event]{plot.surv}}
}
\examples{
surv <- rgamma(40,2,scale=5)
cens <- rbinom(40,1,0.9)
treat <- gl(2,20)
plot(km(surv, cens, group=treat), main="",xlab="Months",
ylab="Probability of deterioration")
plot.dist(km(surv, cens, group=treat))
plot.intensity(km(surv, cens, group=treat),ylab="Risk of deterioration")
}
\keyword{hplot}
@@ -1,28 +1,33 @@
\name{pp}
\title{Create a Point Process Vector from Times between Events}
\alias{pp}
\usage{
pp(y, censor=1)
}
\arguments{
\item{y}{Vector of times.}
\item{cens}{Vector of censoring indicators.}
}
\value{
\code{pp} creates a vector of length \code{sum(y)} of zeroes with a one
at the end of each uncensored time interval for use with
\code{\link[event]{ehr}}.
}
\author{J.K. Lindsey}
\seealso{
\code{\link[event]{bp}}, \code{\link[event]{ehr}},
\code{\link[event]{ident}}, \code{\link[event]{tccov}},
\code{\link[event]{tpast}}, \code{\link[event]{ttime}},
\code{\link[event]{tvcov}}.
}
\examples{
y <- c(5,3,2,4)
py <- pp(y)
py
}
\keyword{manip}
\name{pp}
\title{Create a Point Process Vector from Times between Events}
\alias{pp}
\usage{
pp(y, censor=1)
}
\description{
\code{pp} creates a vector of length \code{sum(y)} of zeroes with a one
at the end of each uncensored time interval for use with
\code{\link[event]{ehr}}.
}
\arguments{
\item{y}{Vector of times.}
\item{censor}{Vector of censoring indicators.}
}
\value{
\code{pp} creates a vector of length \code{sum(y)} of zeroes with a one
at the end of each uncensored time interval for use with
\code{\link[event]{ehr}}.
}
\author{J.K. Lindsey}
\seealso{
\code{\link[event]{bp}}, \code{\link[event]{ehr}},
\code{\link[event]{ident}}, \code{\link[event]{tccov}},
\code{\link[event]{tpast}}, \code{\link[event]{ttime}},
\code{\link[event]{tvcov}}.
}
\examples{
y <- c(5,3,2,4)
py <- pp(y)
py
}
\keyword{manip}