View source: R/estimating_equations.R
ee.wgee.mean | R Documentation |
Calculate estimating function from WGEE. This estimating function is used for marginal mean selection.
ee.wgee.mean(y,x,r,pi,id,time,beta,rho,phi,dist,corstr)
y |
A vector containing outcomes. use NA to indicate missing outcomes. |
x |
A matrix containing covariates. The first column should be all ones corresponding to the intercept. |
r |
A vector indicating the observation of outcomes: 1 for observed records, and 0 for unobserved records. |
pi |
A vector containing observing probabilities across all observations. |
id |
A vector indicating subject id. |
time |
The number of observations for each subject |
beta |
A plug-in estimator solved by an external estimation procedure, such as WGEE. |
rho |
A correlation coefficients obtained from an external estimation procedure, such as WGEE. |
phi |
An over-dispersion parameter obtained from an external estimation procedure, such as GEE. |
dist |
A specified distribution. It can be "gaussian", "poisson",and "binomial". |
corstr |
A candidate correlation structure. It can be "independence","exchangeable", and "ar1". |
A matrix containing values of calculated estimating equations.
corstr should be prespecified.
## tests # load data data(wgeesimdata) library(wgeesel) data_wgee<-data.frame(do.call(cbind,wgeesimdata)) corstr<-"exchangeable" dist<-"binomial" id<-data_wgee$id # obtain the estimates. # Note that "obs_ind" is an indicator of observations in the missing data model. fit<-wgee(y~x1+x2+x3,data_wgee,id,family=dist,corstr =corstr, scale = NULL,mismodel =obs_ind~x_mis1) beta<-as.vector(summary(fit)$beta) rho<-summary(fit)$corr phi<-summary(fit)$phi #calculate observing probabilies for all observations gamma<-as.vector(summary(fit$mis_fit)$coefficients[,1]) x_mis<-wgeesimdata$x_mis pi<-cond.prob(x_mis,gamma,id,time=3) wgee.matrix<-ee.wgee.mean(y=wgeesimdata$y,x=wgeesimdata$x,r=wgeesimdata$obs_ind, pi=pi,id=wgeesimdata$id,time=3,beta=beta,rho=rho,phi=phi,dist=dist,corstr=corstr) apply(wgee.matrix,1,mean)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.