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

I'm trying to fit a curve to model responses from a direct mail campaign over time. Using R, I was a able to get a shape and scale factor using the fitdistr() function. Then I use the shape and scale as parameters in the weibull() function. However, our campaigns usually last 63 days (8 weeks) and the "length" of the fitted weibull curve gets cut off premature. Is there any way to set the "length"?

...OR is there a better way to model Direct Mail marketing campaign responses???

Thanks!

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

-------------Problems Reply------------

When you tabulate a vector with table(), only values that occur in the vector appear in the result; if you want to include other values, you need to create a factor with those values included as levels. Thus, if you want to include all the zeros at the end, make your result into a factor with the appropriate levels before tabulating:

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))

If you instead wanted to draw the theoretical curve associated with the Weibull (i.e. a density curve rather than a table corresponding to a random draw from the distribution) then use curve() with the dweibull() function:

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

(use add=TRUE to add the curve to an existing plot).

Category:r Views:1 Time:2017-09-12

Related post

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.099 (s). 10 q(s)