Description Usage Arguments Details Value Author(s) References See Also Examples
Solving the weighted scores equations with inputs of the weight matrices and the data.
1 2 | solvewtsc(start,WtScMat,xdat,ydat,id,tvec,margmodel,link)
solvewtsc.ord(start,WtScMat,xdat,ydat,id,tvec,link)
|
start |
A starting value of the vector of regression and not regression parameters. The CL1 estimates of regression and not regression parameters is a good starting value. |
WtScMat |
A list containing the following components. omega: The array with the Ω_i,\,i=1,…,n matrices; delta: The array with the Δ_i,\,i=1,…,n matrices; X: The array with the X_i,\,i=1,…,n matrices. |
xdat |
(\mathbf{x}_1 , \mathbf{x}_2 , … , \mathbf{x}_n )^\top, where the matrix \mathbf{x}_i,\,i=1,…,n for a given unit will depend on the times of observation for that unit (j_i) and will have number of rows j_i, each row corresponding to one of the j_i elements of y_i and p columns where p is the number of covariates including the unit first column to account for the intercept (except for ordinal regression where there is no intercept). This xdat matrix is of dimension (N\times p), where N =∑_{i=1}^n j_i is the total number of observations from all units. |
ydat |
(y_1 , y_2 , … , y_n )^\top, where the response data vectors y_i,\,i=1,…,n are of possibly different lengths for different units. In particular, we now have that y_i is (j_i \times 1), where j_i is the number of observations on unit i. The total number of observations from all units is N =∑_{i=1}^n j_i. The ydat are the collection of data vectors y_i, i = 1,…,n one from each unit which summarize all the data together in a single, long vector of length N. |
id |
An index for individuals or clusters. |
tvec |
A vector with the time indicator of individuals or clusters. |
margmodel |
Indicates the marginal model. Choices are “poisson” for Poisson, “bernoulli” for Bernoulli, and “nb1” , “nb2” for the NB1 and NB2 parametrization of negative binomial in Cameron and Trivedi (1998). |
link |
The link function. Choices are “log” for the log link function, “logit” for the logit link function, and “probit” for the probit link function. |
Obtain robust estimates {\hat a} of the univariate parameters solving the weighted scores equation, g_1= g_1(a)=∑_{i=1}^n X_i^T\, W_{i,\rm working}^{-1}\, s_i( a)=0, where W_{i,\rm working}^{-1}=Δ_iΩ_{i,\rm working}^{-1}= Δ_i({\tilde a})Ω_i({\tilde a},{\tilde R})^{-1} is based on the covariance matrix of s_i(a) computed from the fitted discretized MVN model with estimated parameters {\tilde a}, {\tilde R}. A reliable non-linear system solver is used.
Note that solvewtsc.ord
is a variant of the code for ordinal (probit and logistic) regression.
A list containing the following components:
root |
The weighted scores estimates. |
f.root |
The value of the wtsc function evaluated at the root. |
iter |
The number of iterations used. |
estim.precis |
The estimated precision for root. |
Aristidis K. Nikoloulopoulos A.Nikoloulopoulos@uea.ac.uk
Harry Joe harry.joe@ubc.ca
Nikoloulopoulos, A.K., Joe, H. and Chaganty, N.R. (2011) Weighted scores method for regression models with dependent data. Biostatistics, 12, 653–665. doi: 10.1093/biostatistics/kxr005.
Nikoloulopoulos, A.K. (2016) Correlation structure and variable selection in generalized estimating equations via composite likelihood information criteria. Statistics in Medicine, 35, 2377–2390. doi: 10.1002/sim.6871.
Nikoloulopoulos, A.K. (2017) Weighted scores method for longitudinal ordinal data. Arxiv e-prints, <arXiv:1510.07376>. https://arxiv.org/abs/1510.07376.
wtsc
,
weightMat
,
godambe
,
wtsc.wrapper
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 | ################################################################################
# NB2 regression
################################################################################
################################################################################
# read and set up the data set
################################################################################
data(childvisit)
# covariates
season1<-childvisit$q
season1[season1>1]<-0
xdat<-cbind(1,childvisit$sex,childvisit$age,childvisit$m,season1)
# response
ydat<-childvisit$hosp
#id
id<-childvisit$id
#time
tvec<-childvisit$q
################################################################################
# select the marginal model
################################################################################
margmodel="nb2"
################################################################################
# select the correlation structure
################################################################################
corstr="exch"
################################################################################
# perform CL1 estimation
################################################################################
i.est<-iee(xdat,ydat,margmodel)
cat("\niest: IEE estimates\n")
print(c(i.est$reg,i.est$gam))
est.rho<-cl1(b=i.est$reg,gam=i.est$gam,xdat,ydat,id,tvec,margmodel,corstr,link)
cat("\nest.rho: CL1 estimates\n")
print(est.rho$e)
################################################################################
# obtain the fixed weight matrices
################################################################################
WtScMat<-weightMat(b=i.est$reg,gam=i.est$gam,rh=est.rho$e,
xdat,ydat,id,tvec,margmodel,corstr)
################################################################################
# obtain the weighted scores estimates
################################################################################
# solve the nonlinear system of equations
ws<-solvewtsc(start=c(i.est$reg,i.est$gam),WtScMat,xdat,ydat,id,
tvec,margmodel,link)
cat("ws=parameter estimates\n")
print(ws$r)
################################################################################
# Ordinal regression
################################################################################
################################################################################
# read and set up data set
################################################################################
data(arthritis)
nn=nrow(arthritis)
bas2<-bas3<-bas4<-bas5<-rep(0,nn)
bas2[arthritis$b==2]<-1
bas3[arthritis$b==3]<-1
bas4[arthritis$b==4]<-1
bas5[arthritis$b==5]<-1
t2<-t3<-rep(0,nn)
t2[arthritis$ti==3]<-1
t3[arthritis$ti==5]<-1
xdat=cbind(t2,t3,arthritis$trt,bas2,bas3,bas4,bas5,arthritis$age)
ydat=arthritis$y
id<-arthritis$id
#time
tvec<-arthritis$time
################################################################################
# select the link
################################################################################
link="probit"
################################################################################
# select the correlation structure
################################################################################
corstr="exch"
################################################################################
# perform CL1 estimation
################################################################################
i.est<-iee.ord(xdat,ydat,link)
cat("\niest: IEE estimates\n")
print(c(i.est$reg,i.est$gam))
est.rho<-cl1.ord(b=i.est$reg,gam=i.est$gam,xdat,ydat,id,tvec,corstr,link)
cat("\nest.rho: CL1 estimates\n")
print(est.rho$e)
################################################################################
# obtain the fixed weight matrices
################################################################################
WtScMat<-weightMat.ord(b=i.est$reg,gam=i.est$gam,rh=est.rho$e,xdat,ydat,id,
tvec,corstr,link)
################################################################################
# obtain the weighted scores estimates
################################################################################
# solve the nonlinear system of equations
ws<-solvewtsc.ord(start=c(i.est$reg,i.est$gam),WtScMat,xdat,ydat,id,
tvec,link)
cat("ws=parameter estimates\n")
print(ws$r)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.