如何在威布尔分布中设置 "length" 参数。我正在尝试对直邮营销活动随时间变化的响应曲线进行建模

How to set a "length" parameter in a weibull distribution. I'm trying to model a response curve of a direct mail marketing campaign over time

我正在尝试拟合一条曲线来模拟直邮活动随时间的响应。使用 R,我能够使用 fitdistr() 函数获得形状和比例因子。然后我在 weibull() 函数中使用形状和比例作为参数。但是,我们的活动通常持续 63 天(8 周),并且拟合的 weibull 曲线的 "length" 会过早地被切断。有没有办法设置"length"?

...或者是否有更好的方法来模拟直邮营销活动响应???

谢谢!

set.seed(5)
install.packages("MASS")
library("MASS")
responses <-c(4,5,1,12,24,16,16,15,5,18,7,12,5,13,6,2,9,2,5,1,4,4,5,3,3,4,7,3,9,2,2,4,3,2,5,4,3,2,2,2,2,2,2,2,2,2,1,1,1,1,1,2,3,2,1,1,1,1,1,1,1,1,1)                                                                                        

f <- fitdistr(responses,'weibull')

f #check the shape and scale

#plug in the shape and scale. 284 is the number of total responders that we're trying to fit the curve to. 
weibulldraws <- as.data.frame(table(round(.5 +   rweibull(284,1.0753863,4.6579543))))
weibulldraws

当您使用 table() 对向量进行制表时,只有向量中出现的值才会出现在结果中;如果要包含其他值,则需要创建一个因子,将这些值作为级别包含在内。因此,如果您想在末尾包含所有零,请在制表前将您的结果转换为具有适当级别的因子:

set.seed(5)
wshape <- 1.0753863
wscale <- 4.6579543
n <- 284
rvals <- round(rweibull(n,wshape,wscale)+0.5)
frvals <- factor(rvals,levels=0:63)
weibulldraws <- as.data.frame(table(frvals))

如果您想绘制与 Weibull 关联的 理论 曲线(即密度曲线而不是 table 对应于从分布中随机抽取的曲线)然后将 curve()dweibull() 函数一起使用:

curve(n*dweibull(x,wshape,wscale),from=0,to=63)

(使用 add=TRUE 将曲线添加到现有图)。