View source: R/supporting_functions.R
marg.prob | R Documentation |
A function calculates the inverse of joint probabilities for weight calculation involved in WGEE.
marg.prob(pi)
pi |
A matrix containing covariates for the missing data model. The first column should be all ones corresponding to the intercept. |
a vector containing the inverse of joint probabilities.
## 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 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) joint_prob<-marg.prob(pi)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.