sdfun {RRMLRfMC} | R Documentation |
sdfun
Description
This function is used get the standard error matrix from bootstrap method It returns the matrices of standard error and p-value for the coefficient matrix
Usage
sdfun(I, z1 = NULL, z2 = NULL, T, R, eps = 1e-05, B, tpoint = NULL, ref)
Arguments
I |
a U by U incidence matrix with elements; U is the number of states; I(i,j)=1 if state j can be accessed from state i in one step and 0 otherwise |
z1 |
a n by p matrix with covariates involved in the dimension reduction(DR), n is the number of subjects, p is the number of covariates involved in DR |
z2 |
a n by q matrix with study covariates (not in dimension reduction), q is the number of study covariates |
T |
a M by 3 state matrix,
|
R |
the rank |
eps |
the tolerance for convergence; the default is 10^-5 |
B |
the bootstrap number |
tpoint |
a matrix has two columns with the participants' visit information about timeline |
ref |
a vector of reference categories |
Value
a list of outputs:
coe: the coefficient matrix of the original data
sd: the standard error matrix
pvalue: the p-value matrix
Examples
# generate the Markov chain
U=7
I1=I2=I3=rep(1,7)
I4=c(0,0,0,1,1,1,1)
I5=I6=I7=rep(0,7)
I=rbind(I1,I2,I3,I4,I5,I6,I7)
# prepare the data
data=cogdat
n=length(unique(data[,1]))
M=nrow(data)+n
Mc=0
z=matrix(0,n,9)
colnames(z)=colnames(data)[5:13]
T=matrix(0,M,3)
for(i in 1:n){
subdat=data[which(data[,1]==i),,drop=FALSE]
z[i,]=subdat[1,5:13]
mc=nrow(subdat)
T[(Mc+1):(Mc+mc+1),1]=i
T[(Mc+1):(Mc+mc+1),2]=0:mc
T[(Mc+1):(Mc+mc+1),3]=c(subdat[1,3],subdat[,4])
Mc=Mc+mc+1
}
#z1=z[,c(1:3),drop=FALSE]
z2=z[,4,drop=FALSE]
# find the standard deviation matrix for the model with rank 1
sdfun(I,z1=NULL,z2,T,1,eps = 9,2,ref=c(1,1,1,4))