[英]How to find a model for dataset
I have a text file that contains dates and numerical values like我有一个包含日期和数值的文本文件,例如
1.1.2020, 45.67
2.1.2020, 49.65
4.1.2020, 47.58
31.1.2020, 55.88
...
Note that value of some dates is missing.请注意,缺少某些日期的值。
I would like to fit a model of the form ae^(bx) to find an estimate what would be value in 1.1.2021.我想拟合 ae^(bx) 形式的 model 来估算 1.1.2021 的价值。 How can I do that?我怎样才能做到这一点? Is there some Sagemath function for that or some Python library to find such a model.是否有一些 Sagemath function 或一些 Python 库来找到这样的 model。
For your specified formula, this can be solved by fitting a log-log model.对于您指定的公式,这可以通过拟合 log-log model 来解决。
Y = a * exp(b x) Y = a * exp(b x)
log(Y) = log(a) + b x log(Y) = log(a) + b x
as.numeric()
)将您的日期转换为数字类型(例如as.numeric()
)Y = exp(intercept + slope*date) Y = exp(截距+斜率*日期)
In R, using some made up data在R中,使用一些编造的数据
dates=sort(sample(1:100,20))
values=exp(seq(0,5,length.out=20))+rnorm(20)
mod=lm(log(values)~dates)
new=1:100
plot(values~dates)
points(exp(coef(mod)[1]+coef(mod)[2]*new)~new,col="red")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.