【发布时间】:2018-11-07 11:52:07
【问题描述】:
我有 4 个训练集点,我使用“nls”来拟合训练集,然后预测包含 2 个点的测试集的响应。但是,“预测”命令总是返回训练集的值。
The code is attached below:
##Following is train set
HD = c(714,715,716.6,717.6)
p_l = c(0.5,0.1,0.05826374, 0.005982334)
##Fitting with nls
raw_data = data.frame(HD,p_l)
exp_fit = nls(p_l~exp(a+b*HD),data = raw_data,trace = T,start = list(a = 0,b
= 0))
##Following is test set
HD_test = c(718.2,719.17)
p_l_test = predict(exp_fit,newdata = HD_test)
【问题讨论】:
标签: r regression prediction nls