其他分享
首页 > 其他分享> > R语言predict函数用法

R语言predict函数用法

作者:互联网

R语言predict函数用法

predict(object, newdata, se.fit = FALSE, scale = NULL, df = Inf,
interval = c(“none”, “confidence”, “prediction”),
level = 0.95, type = c(“response”, “terms”),
terms = NULL, na.action = na.pass,
pred.var = res.var/weights, weights = 1, …)

参数:object

Object of class inheriting from “lm”.
继承类的对象从“lm”。

参数:newdata

An optional data frame in which to look for variables with which to predict. If omitted, the fitted values are used.
一个可选的数据框寻找与预测的变数。如果省略,用来拟合值。

参数:se.fit

A switch indicating if standard errors are required.
一个开关,如果需要标准误差。

参数:scale

Scale parameter for std.err. calculation.
尺度参数std.err的计算。

参数:df

Degrees of freedom for scale
度规模的自由。

参数:interval

Type of interval calculation.
区间计算的类型。其中,若interval=“prediction”,则返回在默认置信水平为95%下的置信区间(lwr为区间左端,upr为区间右端);若interval=“confidence”,则返回预测值的预测范围区间。

参数:level

Tolerance/confidence level.
宽容/置信水平。

参数:type

Type of prediction (response or model term).
预测型(反应或模型长期)。

参数:terms

If type=”terms”, which terms (default is all terms).
如果type=”terms”,则默认是所有条款。

参数:na.action

function determining what should be done with missing values in newdata. The default is to predict NA.
功能确定应做与newdata缺失值,默认预测NA。

参数:pred.var

the variance(s) for future observations to be assumed for prediction intervals.
要承担未来的观测方差(S)的预测区间。

参数:weights

variance weights for prediction. This can be a numeric vector or a one-sided model formula. In the latter case, it is interpreted as an expression evaluated in newdata.
预测方差权。这可以是一个数值向量或片面的模型公式。在后一种情况下,它被解释为表达newdata的评价。

例如:

> yy<-predict(fm,newdata = data.frame(X1=220,X2=2500),interval="confidence")
> yy
    fit   lwr   upr
1 135.6 134.1 137.1
> yy<-predict(fm,newdata = data.frame(X1=220,X2=2500),interval="prediction")
> yy
    fit   lwr   upr
1 135.6 130.6 140.5

标签:terms,函数,predict,interval,prediction,用法,参数,newdata
来源: https://blog.csdn.net/qq_43605275/article/details/117593998