View source: R/basepredict.glm.R
basepredict.glm | R Documentation |
The function calculates the predicted value with the confidence interval. It can be used for any glm model.
## S3 method for class 'glm'
basepredict(model, values, sim.count=1000, conf.int=0.95, sigma=NULL, set.seed=NULL,
type = c("any", "simulation", "bootstrap"), summary = TRUE)
model |
the model Object generated with glm() or glm.nb() |
values |
the values of the case as vector in the order how they appear in the summary(model) Estimate |
sim.count |
OPTIONAL numbers of simulations to be done by the function. default: 1000 |
conf.int |
OPTIONAL the confidence interval used by the function. default: 0.95 |
sigma |
OPTIONAL the variance-covariance matrix, can be changed when having for example robust or clustered vcov. default: vcov(model) |
set.seed |
OPTIONAL set a seed for the random number generator |
type |
OPTIONAL choose between simulation and bootstrap, "any" chooses between those two according to the number of cases (bootstrap if n < 1000) |
summary |
OPTIONAL if mean/quantiles should be return or all simulated values (default: TRUE) |
The function makes a simulation for the two cases and compares them to each other.
The output is a 3x3 matrix having in the first column the predicted value, in the second column the lower value of the confidence interval and in the third column the upper value of the confidence interval.
Benjamin Schlegel, kontakt@benjaminschlegel.ch
model1 = glm(Sex ~ Height + Smoke + Pulse, data=MASS::survey, family=binomial(link=logit))
summary(model1)
# predicted probability of a non smoking person with height 150 and average pulse
basepredict(model1, c(1,150,1,0,0,mean(MASS::survey$Pulse,na.rm=TRUE)))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.