Compute population marginal means (PMM) from a model fit, for a chosen population and statistic.
yates(fit, term, population = c("data", "factorial", "sas"),
levels, test = c("global", "trend", "pairwise"), predict = "linear",
options, nsim = 200, method = c("direct", "sgtt"))
a model fit. Examples using lm, glm, and coxph objects are given in the vignette.
the term from the model whic is to be evaluated. This can be written as a character string or as a formula.
the population to be used for the adjusting variables. User can supply their own data frame or select one of the built in choices. The argument also allows "empirical" and "yates" as aliases for data and factorial, respectively, and ignores case.
optional, what values for term
should be used.
the test for comparing the population predictions.
what to predict. For a glm model this might be the 'link' or 'response'. For a coxph model it can be linear, risk, or survival. User written functions are allowed.
optional arguments for the prediction method.
number of simulations used to compute a variance for the predictions. This is not needed for the linear predictor.
the computational approach for testing equality of the population predictions. Either the direct approach or the algorithm used by the SAS glim procedure for "type 3" tests.
an object of class yates
with components of
a data frame with one row for each level of the term, and columns containing the level, the mean population predicted value (mppv) and its standard deviation.
a matrix giving the test statistics
the full variance-covariance matrix of the mppv values
optional: any further summary if the values provided by the prediction method.
The many options and details of this function are best described in a vignette on population prediction.
# NOT RUN {
fit1 <- lm(skips ~ Solder*Opening + Mask, data = solder)
yates(fit1, ~Opening, population = "factorial")
fit2 <- coxph(Surv(time, status) ~ factor(ph.ecog)*sex + age, lung)
yates(fit2, ~ ph.ecog, predict="risk") # hazard ratio
# }
Run the code above in your browser using DataLab