fitParaIND: Performs the maximum likelihood estimation for the negative...

Description Usage Arguments Details Value Author(s) References See Also Examples

Description

This function fits the parametric negative binomial mixed-effect independent model in the formulation described Zhao et al (2013). The conditional distribution of response count given random effect is modelled by Negative Binomial as described in description of lmeNB. The conditional dependence among the response counts of a subject is assumed independent. The random effects are modelled with either gamma or log-normal distributions. See descriptions of lmeNB.

Usage

1
2
fitParaIND(formula, data, ID, p.ini = NULL, IPRT = FALSE, RE = "G", 
           i.tol = 1e-75, o.tol = 0.001, COV = TRUE) 

Arguments

formula

See lmeNB.

data

See lmeNB.

ID

See lmeNB.

p.ini

The initial values of the parameters \log(α), \log(θ),β[0], β[1] NULL is accepted.

IPRT

See lmeNB.

RE

The distribution of random effects G[i]. If RE="G" then the random effects are assumed to be from the gamma distribution. If RE="N" then they are assumed to be form the log-normal distribution.

i.tol

See lmeNB.

o.tol

See lmeNB.

COV

Internal use only.

Details

fitParaIND calls optim to minimize the negative log-likelihood of the negative binomial model with respect to the model parameters: \log(α), \log(θ),β[0], β[1],.... The Nelder-Mead algorithm is employed. The log-likelihood is obtained by marginalizing out the random effects. The numerical integration is carried out using adaptive quadrature.

The missing count responses, if assumed to be missing at random, can be igored.Other types of missing data are currently not accepted.

All the computations are done in R.

Value

call

See lmeNB.

opt

See lmeNB.

nlk

See lmeNB.

V

See lmeNB.

est

See lmeNB.

AR

FALSE

Author(s)

Zhao, Y. and Kondo, Y.

References

Detection of unusual increases in MRI lesion counts in individual multiple sclerosis patients. (2013) Zhao, Y., Li, D.K.B., Petkau, A.J., Riddehough, A., Traboulsee, A., Journal of the American Statistical Association.

See Also

The wrapper function for all the negative binomial mixed effect regression: lmeNB.

The functions to fit the other negative binomial mixed effect models: fitParaAR1, fitSemiIND, fitSemiAR1,

The subroutines of index.batch to compute the conditional probability index: jCP.ar1, CP1.ar1, MCCP.ar1, CP.ar1.se, CP.se, jCP,

The functions to generate simulated datasets: rNBME.R.

Examples

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
## Not run: 

## ================================================================================ ##
## generate a simulated dataset from the negative binomial mixed-effect independent model:
## Y_ij | G_i = g_i ~ NB(r_ij,p_i) where r_ij = exp(X^T beta)/a , p_i =1/(a*g_i+1)
## with G_i ~ Gamma(scale=th,shape=1/th)
set.seed(1)
sn <- 5 ## the number of repeated measures of each patient
n <- 80 ## the number of patients
loga <- - 0.5
a <- exp(loga) ## the parameter for the failure probability of the negative binomial distribution
logtheta <- 1.3
th <- exp(logtheta) ## the parameter for the gamma distribution of g_i

## No difference between the means of groups 
## The model only has an intercept term beta0 = 0.5
b0 <- 0.5
u1 <- rep(exp(b0),sn) ## the mean vector for group 1 at time point 1,...,sn
u2 <- rep(exp(b0),sn) ## the mean vector for group 2 at time point 1,...,sn


DT0 <- rNBME.R(gdist="G", n=n, a=a, th=th, u1=u1, u2=u2, sn=sn)
ID <- DT0$id
Vcode <- rep(-1:(sn-2),n) # scan number -1, 0, 1, 2, 3
new <- Vcode > 0 
dt1 <- data.frame(CEL=DT0$y)
logitd <- -0.5

## ================================================================================ ##


## [1]: Fit the negative binomial independent model 
## where the random effects are from the gamma distribution. This is the true model.

re.gamma.ind <- fitParaIND(formula=CEL~1,data=dt1,ID=ID,RE="G", 
	                  p.ini=c(loga,logtheta,b0),IPRT=TRUE)
## compute the estimates of the conditional probabilities 
## with sum of the new repeated measure as a summary statistics 
Psum <- index.batch(olmeNB=re.gamma.ind, ID=ID,data=dt1,
                    labelnp=new,qfun="sum", IPRT=TRUE) 

## compute the estimates of the conditional probabilities 
## with max of the new repeated measure as a summary statistics 
Pmax <- index.batch(olmeNB=re.gamma.ind, ID=ID,data=dt1,
                   labelnp=new,qfun="max", IPRT=TRUE)

## Which patient's estimated probabilities 
## based on the sum and max statistics disagrees the most?
( IDBigDif <- which(rank(abs(Pmax$condProbSummary[,1]-Psum$condProbSummary[,1]))==80) )
## Show the patient's CEL counts  
dt1$CEL[ID==IDBigDif]
## Show the estimated conditional probabilities based on the sum summary statistics
Psum$condProbSummary[IDBigDif,]
## Show the estimated conditional probabilities based on the max summary statistics
Pmax$condProbSummary[IDBigDif,]



## [2]: Fit the negative binomial independent model 
## where the random effects are from the lognormal distribution. 
re.logn.ind <- fitParaIND(formula=CEL~1,data=dt1,ID=ID, 
                          RE="N", 			   	
		          p.ini=c(loga,logtheta,b0), 		
		          IPRT=TRUE)

Psum <- index.batch(olmeNB=re.logn.ind, ID=ID,data=dt1,C=TRUE,
                   labelnp=new,qfun="sum", IPRT=TRUE) 

## [3]: Fit the semi-parametric negative binomial independent model 


re.semi.ind <- fitSemiIND(formula=CEL~1,data=dt1,ID=ID)

Psum <- index.batch(olmeNB=re.semi.ind,ID=ID,data=dt1, i.se = FALSE,
                   labelnp=new, qfun="sum", IPRT=TRUE) 



## [4]: Fit the negative binomial mixed-effect AR(1) model 
## where random effects are from the gamma distribution


re.gamma.ar1 <- fitParaAR1(formula=CEL~1,data=dt1,ID=ID,
		           p.ini=c(loga,logtheta,logitd,b0), 
		           RE="G", Vcode=Vcode,
		           IPRT=TRUE)

Psum <- index.batch(olmeNB=re.gamma.ar1, ID=ID,data=dt1, labelnp=new,Vcode=Vcode,
                    qfun="sum", IPRT=TRUE,i.se=FALSE) ## i.se=TRUE requires more time...
	 




## ======================================================================== ##
## == Which model performed the best in terms of the estimation of beta0 == ##
## ======================================================================== ##

getpoints <- function(y,estb0,sdb0=NULL,crit=qnorm(0.975))
{	  
points(estb0,y,col="blue",pch=16)
if (!is.null(sdb0))
{
points(c(estb0-crit*sdb0,estb0+crit*sdb0),rep(y,2),col="red",type="l")
}
}

ordermethod <- c("gamma.ind","logn.ind","semi.ind","gamma.ar1")

estb0s <- c(
re.gamma.ind$est[3,1], 
re.logn.ind$est[3,1],
re.semi.ind$est[3],
re.gamma.ar1$est[4,1]
)

## The true beta0 is:
b0
c <- 1.1
plot(0,0,type="n",xlim=c(min(estb0s)-0.5,max(estb0s)*c),
	ylim=c(0,5),yaxt="n",
main="Simulated from the independent model \n with random effect ~ gamma")

legend("topright",
	col="red",
	legend=ordermethod)
abline(v=b0,lty=3)

## [1] gamma.ind
sdb0 <- re.gamma.ind$est[3,2]
getpoints(4,estb0s[1],sdb0)

## [2] logn.ind
sdb0 <- re.logn.ind$est[3,2]
getpoints(3,estb0s[2],sdb0)

## [3] semi.ind
getpoints(2,estb0s[3])

## [4] gamma.ar1
sdb0 <- re.gamma.ar1$est[4,2]
getpoints(1,estb0s[4],sdb0)


## End(Not run)

lmeNB documentation built on May 2, 2019, 3:34 p.m.

Related to fitParaIND in lmeNB...