R语言Bass模型进行销售预测

简介: R语言Bass模型进行销售预测

BASS扩散模型

BASS扩散模型三个参数:#最终购买产品的总人数,m; 创新系数p; 和#系数的模仿,


q# exampleT79<-1:10Tdelt<-(1:100)/10Sales<-c(840,1470,2110,4000,7590,10950,10530,9470,7790,5890)Cusales<-cumsum(Sales)Bass.nls<-nls(Sales~M*(((P+Q)^2/P)*exp(-(P+Q)*T79))/(1+(Q/P)*exp(-(P+Q)*T79))^2,start=list(M=60630,P=0.03,Q=0.38))summary(Bass.nls)


##


## Formula: Sales ~ M * (((P + Q)^2/P) * exp(-(P + Q) * T79))/(1 + (Q/P) *


## exp(-(P + Q) * T79))^2


##


## Parameters:


## Estimate Std. Error t value Pr(>|t|)


## M 6.80e+04 3.13e+03 21.74 1.1e-07 ***


## P 6.59e-03 1.43e-03 4.61 0.0025 **


## Q 6.38e-01 4.14e-02 15.41 1.2e-06 ***


## ---


## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1


##


## Residual standard error: 727 on 7 degrees of freedom


##


## Number of iterations to convergence: 8


## Achieved convergence tolerance: 7.32e-06


# get coefficient


Bcoef <- coef(Bass.nls)


m <- Bcoef[1]


p <- Bcoef[2]


q <- Bcoef[3]

#将M的起始值设置为记录的总销售额。


ngete <- exp(-(p + q) * Tdelt)


# plot pdf


Bpdf <- m * ((p + q)^2/p) * ngete/(1 + (q/p) * ngete)^2


plot(Tdelt, Bpdf, xlab = "Year from 1979", ylab = "Sales per year", type = "l")


points(T79, Sales)

# plot cdfBcdf <- m * (1 - ngete)/(1 + (q/p) * ngete)plot(Tdelt, Bcdf, xlab = "Year from 1979", ylab = "Cumulative sales", type = "l")points(T79, Cusales)


#当q = 0时,只有创新者没有模仿者。


Ipdf <- m * ((p + 0)^2/p) * exp(-(p + 0) * Tdelt)/(1 + (0/p) * exp(-(p + 0) *


Tdelt))^2# plot(Tdelt, Ipdf, xlab = 'Year from 1979',ylab = 'Isales per year',# type='l')Impdf <- Bpdf - Ipdfplot(Tdelt, Bpdf, xlab = "Year from 1979", ylab = "Sales per year", type = "l",


col = "red")lines(Tdelt, Impdf, col = "green")lines(Tdelt, Ipdf, col = "blue")


#当q = 0时


Icdf <- m * (1 - exp(-(p + 0) * Tdelt))/(1 + (0/p) * exp(-(p + 0) * Tdelt))


# plot(Tdelt, Icdf, xlab = 'Year from 1979',ylab = 'ICumulative sales',


# type='l')


Imcdf <- m * (1 - ngete)/(1 + (q/p) * ngete) - Icdf


plot(Tdelt, Imcdf, xlab = "Year from 1979", ylab = "Cumulative sales", type = "l",


col = "red")


lines(Tdelt, Bcdf, col = "green")


lines(Tdelt, Icdf, col = "blue")

相关文章
|
4天前
|
机器学习/深度学习 数据可视化
R语言MCMC的lme4二元对数Logistic逻辑回归混合效应模型分析吸烟、喝酒和赌博影响数据
R语言MCMC的lme4二元对数Logistic逻辑回归混合效应模型分析吸烟、喝酒和赌博影响数据
10 0
|
4天前
|
数据可视化 知识图谱
数据分享|R语言、SAS潜类别(分类)轨迹模型LCTM分析体重指数 (BMI)数据可视化
数据分享|R语言、SAS潜类别(分类)轨迹模型LCTM分析体重指数 (BMI)数据可视化
|
4天前
R语言分布滞后线性和非线性模型DLM和DLNM建模应用| 系列文章
R语言分布滞后线性和非线性模型DLM和DLNM建模应用| 系列文章
11 0
|
4天前
|
机器学习/深度学习 vr&ar Python
R语言用logistic逻辑回归和AFRIMA、ARIMA时间序列模型预测世界人口
R语言用logistic逻辑回归和AFRIMA、ARIMA时间序列模型预测世界人口
10 0
|
1天前
|
数据可视化 Python
R语言无套利区间模型期货期现研究:正向套利和反向套利次数、收益率分析华泰柏瑞300ETF可视化
R语言无套利区间模型期货期现研究:正向套利和反向套利次数、收益率分析华泰柏瑞300ETF可视化
|
1天前
|
机器学习/深度学习 数据可视化
R语言用灰色模型 GM (1,1)、神经网络预测房价数据和可视化
R语言用灰色模型 GM (1,1)、神经网络预测房价数据和可视化
10 1
|
1天前
|
数据可视化 数据挖掘
R语言APRIORI模型关联规则挖掘分析脑出血急性期用药规律最常配伍可视化
R语言APRIORI模型关联规则挖掘分析脑出血急性期用药规律最常配伍可视化
|
2天前
|
算法
R语言MCMC-GARCH、风险价值VaR模型股价波动分析上证指数时间序列
R语言MCMC-GARCH、风险价值VaR模型股价波动分析上证指数时间序列
R语言MCMC-GARCH、风险价值VaR模型股价波动分析上证指数时间序列
|
3天前
|
机器学习/深度学习 存储 算法
r语言中对LASSO回归,Ridge岭回归和弹性网络Elastic Net模型实现(下)
r语言中对LASSO回归,Ridge岭回归和弹性网络Elastic Net模型实现
17 2
|
3天前
|
机器学习/深度学习 运维 算法
R语言用ARIMA模型滑动时间窗口识别网络流量时间序列异常值
R语言用ARIMA模型滑动时间窗口识别网络流量时间序列异常值

热门文章

最新文章