
Population prediction
yates.RdCompute population marginal means (PMM) from a model fit, for a chosen population and statistic.
Arguments
- fit
a model fit. Examples using lm, glm, and coxph objects are given in the vignette.
- term
the term from the model whic is to be evaluated. This can be written as a character string or as a formula.
- population
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.
- levels
optional, what values for
termshould be used.- test
the test for comparing the population predictions.
- predict
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.
- options
optional arguments for the prediction method.
- nsim
number of simulations used to compute a variance for the predictions. This is not needed for the linear predictor.
- method
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.
Details
The many options and details of this function are best described in a vignette on population prediction.
Value
an object of class yates with components of
- estimate
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.
- tests
a matrix giving the test statistics
- mvar
the full variance-covariance matrix of the mppv values
- summary
optional: any further summary if the values provided by the prediction method.
Examples
fit1 <- lm(skips ~ Solder*Opening + Mask, data = solder)
yates(fit1, ~Opening, population = "factorial")
#> Opening pmm std test chisq df ss Pr
#> L 3.2638 0.33460 global 573.4 2 15980 < 1e-08
#> M 3.5700 0.30480
#> S 12.3519 0.31251
fit2 <- coxph(Surv(time, status) ~ factor(ph.ecog)*sex + age, lung)
yates(fit2, ~ ph.ecog, predict="risk") # hazard ratio
#> factor(ph.ecog) pmm std test chisq df Pr
#> 0 0.94238 0.47654 factor(ph.ecog) NA NA NA
#> 1 1.42677 0.74168
#> 2 1.74848 3.64534
#> 3 NA 20.21523