predict.glm(stats)
predict.glm()所属R语言包:stats
Predict Method for GLM Fits
方差分析适合预测方法
译者:生物统计家园网 机器人LoveR
描述----------Description----------
Obtains predictions and optionally estimates standard errors of those predictions from a fitted generalized linear model object.
获得预测和选择性估计从这些预测的标准误差,拟合广义线性模型对象。
用法----------Usage----------
## S3 method for class 'glm'
predict(object, newdata = NULL,
type = c("link", "response", "terms"),
se.fit = FALSE, dispersion = NULL, terms = NULL,
na.action = na.pass, ...)
参数----------Arguments----------
参数:object
a fitted object of class inheriting from "glm".
从"glm"装一类对象继承。
参数:newdata
optionally, a data frame in which to look for variables with which to predict. If omitted, the fitted linear predictors are used.
可选,在其中寻找变量的数据框预测。如果省略,拟合的线性预测。
参数:type
the type of prediction required. The default is on the scale of the linear predictors; the alternative "response" is on the scale of the response variable. Thus for a default binomial model the default predictions are of log-odds (probabilities on logit scale) and type = "response" gives the predicted probabilities. The "terms" option returns a matrix giving the fitted values of each term in the model formula on the linear predictor scale. The value of this argument can be abbreviated.
预测所需的类型。默认是线性预测的规模;替代"response"是对响应变量的规模。因此,对于一个默认的二项式模型默认的预测是日志的可能性(概率罗吉特规模)和type = "response"给出了预测的可能性。 "terms"选项返回一个矩阵,在每学期的线性预测尺度上的模型公式拟合值。这一论点的价值都可以缩写。
参数:se.fit
logical switch indicating if standard errors are required.
逻辑交换机,表示如果需要标准的错误。
参数:dispersion
the dispersion of the GLM fit to be assumed in computing the standard errors. If omitted, that returned by summary applied to the object is used.
须承担的GLM合适的分散计算标准错误。如果省略,则返回summary应用于使用对象。
参数:terms
with type="terms" by default all terms are returned. A character vector specifies which terms are to be returned
用type="terms"默认情况下,返回所有条款。字符向量指定的条件是要返回
参数:na.action
function determining what should be done with missing values in newdata. The default is to predict NA.
功能确定应做与newdata缺失值。默认预测NA。
参数:...
further arguments passed to or from other methods.
通过进一步的论据或其他方法。
Details
详情----------Details----------
If newdata is omitted the predictions are based on the data used for the fit. In that case how cases with missing values in the original fit is determined by the na.action argument of that fit. If na.action = na.omit omitted cases will not appear in the residuals, whereas if na.action = na.exclude they will appear (in predictions and standard errors), with residual value NA. See also napredict.
newdata如果省略的预测是基于适合使用的数据。在这种情况下,如何在原来的拟合遗漏值的情况下确定na.action合身的说法。如果na.action = na.omit省略的情况下将不会出现在残差,而如果na.action = na.exclude,“他们将出现(在预测和标准错误),剩余价值NA。还可以看napredict。
值----------Value----------
If se = FALSE, a vector or matrix of predictions. If se = TRUE, a list with components
如果se = FALSE,一个向量或矩阵的预测。如果se = TRUE,一个组件的列表
参数:fit
Predictions
预测
参数:se.fit
Estimated standard errors
估计标准误差
参数:residual.scale
A scalar giving the square root of the dispersion used in computing the standard errors.
一个标量,使分散的计算标准错误的平方根。
注意----------Note----------
Variables are first looked for in newdata and then searched for in the usual way (which will include the environment of the formula used in the fit). A warning will be given if the variables found are not of the same length as those in newdata if it was supplied.
变量在newdata先看着,然后在通常的方法(其中包括环境适合使用的公式)搜查。一个将给予警告,如果发现的变量是相同长度不为那些在newdata如果它提供的。
参见----------See Also----------
glm, SafePrediction
glm,SafePrediction
举例----------Examples----------
require(graphics)
## example from Venables and Ripley (2002, pp. 190-2.)[#例如,从维纳布尔斯和Ripley(2002年,第190-2页。)]
ldose <- rep(0:5, 2)
numdead <- c(1, 4, 9, 13, 18, 20, 0, 2, 6, 10, 12, 16)
sex <- factor(rep(c("M", "F"), c(6, 6)))
SF <- cbind(numdead, numalive=20-numdead)
budworm.lg <- glm(SF ~ sex*ldose, family=binomial)
summary(budworm.lg)
plot(c(1,32), c(0,1), type = "n", xlab = "dose",
ylab = "prob", log = "x")
text(2^ldose, numdead/20, as.character(sex))
ld <- seq(0, 5, 0.1)
lines(2^ld, predict(budworm.lg, data.frame(ldose=ld,
sex=factor(rep("M", length(ld)), levels=levels(sex))),
type = "response"))
lines(2^ld, predict(budworm.lg, data.frame(ldose=ld,
sex=factor(rep("F", length(ld)), levels=levels(sex))),
type = "response"))
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|