非常有用 !!
R 语言 >>>
x<-c(1,2, 3, 4, 5, 6, 7, 8, 9, 10)
y<-c(0,30,44,57,65,78,68,97,99,120)
lm.reg<-lm(y ~ 1+x)
point<-data.frame(x=11)
lm.pred<-predict(lm.reg,point,interval="prediction",level=0.95)
lm.pred[1]
输出 : 128.26666666666668
python 语言 >>>
import rpy2.robjects as robjects
r = robjects.r
robjects.globalenv["x"] = robjects.FloatVector([1,2, 3, 4, 5, 6, 7, 8, 9, 10])
robjects.globalenv["y"] = robjects.FloatVector([0,30,44,57,65,78,68,97,99,120])
lm_d9 = r.lm("y ~ 1+x")
r.predict( lm_d9,
robjects.r(" data.frame(x=11) "),
interval="prediction",level=0.95)[0]
输出 : 128.26666666666668
阅读(3157) | 评论(0) | 转发(0) |