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

  • How to set the length of Object[] 2012-01-30

    Why this piece of code does not work? How to set the length of Object[]. Object[] entry = new Object[]{}; entry[0] = 1; entry[1] = "1"; --------------Solutions------------- If you are Initializing a new array then you either have to specify its size

  • how to set array length with delphi 2010 rtti 2009-11-20

    how to set array length in runtime ? setLength(t.GetProperty('Propertys'),3); ???? unit Unit3; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TSubProperty = Class private Fitem2: Inte

  • How to set custom width parameter to img tag created by tinymce? 2011-07-31

    How to set custom width parameter to img tag created by tinymce? I mean when you inster the image in textarea, how to change it's width to some custom value ? Image managers config does not provide such feature so I want to modify this script, just n

  • Hibernate: How to set NULL query-parameter value with HQL? 2010-01-23

    how can I set a Hibernate Parameter to "null"? Example: Query query = getSession().createQuery("from CountryDTO c where c.status = :status and c.type =:type") .setParameter("status", status, Hibernate.STRING) .setParameter("type", type, Hibernate.STR

  • How to set the "CSRFprotect" parameter to prevent AJAX hijacking? 2011-05-04

    In This article the auther mentioned a way to protect from AJAX hijacking by using CSRFprotect param but I didn't understand how he set it's value ? I would put the code here but when I do it appears inapprehensible . --------------Solutions---------

  • How to set max length of a draw line?(Corona SDK) 2012-04-08

    I am currently working on some project and it contains an option of a line to be drawn. But I can't normally set max length of line. How can I do that? Here is the code of distance formula (as I think): local function distanceBetween( e, prev ) local

  • How to set the length of a vector (in xna) 2009-10-21

    Hey, I'm wondering if there's a function out there to set the length of an XNA framework Vector3, like in c++ it would just be VECTOR.setLength( x ). Either that or the basic math to do it manually would be nice :) --------------Solutions------------

  • Delphi: how to set the length of a RTTI-accessed dynamic array using DynArraySetLength? 2010-03-27

    I'd like to set the length of a dynamic array, as suggested in this post. I have two classes TMyClass and the related TChildClass defined as TChildClass = class private FField1: string; FField2: string; end; TMyClass = class private FField1: TChildCl

  • How to set file length zero in Android? 2011-07-05

    I want to set file length to zero. i used following code try { new RandomAccessFile(file,"rw").setLength(0); } catch (FileNotFoundException e1) { // TODO Auto-generated catch block Log.i("Exception caught ==> ", e1.toString()); e1.printStackTrace(

  • How to set the dojoConfig parameter in dojoeditor based on a hidden variable value 2011-08-30

    I am new to dojo(infact coding) and am struggling with setting the locale on the dojo editor. I have a scenario where in JSP1: language value is input and the value is submitted as a hidden variable JSP2: DOJo editor is displayed based on the languag

  • Roxygen: how to set a default parameter including backslash ('\') to functions 2011-01-06

    I use Roxygen to generate Rd files of my packages under development, but I have some problems with functions with default parameter set to '\n', e.g.: lineCount <- function(text, sep='\n') { ... } Which purpose is to count new line ('\n') characte

  • How to set text length in button 2011-06-01

    I want to have a fixed size button If the text is longer than button width , it should show "tex..." How do I do this? --------------Solutions------------- Ellipsize can be used but there is a bug. The workaround is to set scrollHorizontally to true

  • How to set array length after updating it via $addToSet in mongodb? 2011-09-07

    Document structure looks like this, { blacklists:[] // elements should be unique blacklistsLength:0 // length of blacklists } Adding sets of value to blacklists is easy. db.posts.update({_id:...}, {$addtoSet:{blacklists:{$each:['peter', 'bob', 'steve

  • How to set character length of TextField by deformatting the formatted number 2011-11-16

    I used the below code to set character lentgh to 17: - (BOOL)textField:(UITextField *)theTextField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { // NSString *stringWithoutSpaces = [theTextField.text stringByRepla

  • How to set Content-Length when sending POST request in NodeJS? 2011-11-24

    var https = require('https'); var p = '/api/username/FA/AA?ZOHO_ACTION=EXPORT&ZOHO_OUTPUT_FORMAT=JSON&ZOHO_ERROR_FORMAT=JSON&ZOHO_API_KEY=dummy1234&ticket=dummy9876&ZOHO_API_VERSION=1.0'; var https = require('https'); var options

  • How to set a default parameter for a vector for use in a default constructor within a class? 2009-12-06

    For example, a class named Table, with its constructor being: Table(string name="", vector <string> mods); How would I initialize the vector to be empty? Edit: Forgot to mention this was C++. --------------Solutions------------- Table(string na

  • How to Set the Source Parameter using OAuth on Twitter? 2010-01-03

    my name is Fernando and I was here asking if there was a way to set the parameter 'source' using REST. Today, after some testing, I managed to implement OAuth in the library and I succeeded in publishing a message directly by OAuth configured for my

  • ColdFusion - how to set Content-Length header 2010-10-13

    Has anyone successfully added a Content-Length header to regular ColdFusion (I'm using CF9) pages? I'm setting up a new server behind a Cisco load balancer with compression - the box refuses to compress anything without this header, but CF doesn't pa

  • How to set content-length after a view is resolved using spring mvc? 2011-09-19

    We're using Spring MVC (3.0.5) for an API we are building. However, we have discovered that the application does not always return a content-length in the response header. Why I haven't figured out as yet. We can not manually set the content-length i

  • How to set static final parameter from context in Spring? 2011-10-18

    I have Class with static final fields and I want to initialize them from my context..Can I do this? Or I have to look for another solution? --------------Solutions------------- Since final variables are effectively constants that have to be defined e

  • Adode Air Windows Installer: How to set "Start in" parameter in desktop shortcut during add installation 2011-12-04

    I created Adobe Native Installer for Windows. During installation it creates desktop shortcut, but with empty Start in parameter. For this reason, current dir in running air application is depended on start type: if i started app directly from Progra

  • how to set "--upload-file" parameter of cURL in PHP? 2015-02-09

    I know that we can upload a file with cURL in PHP easily: $c = curl_init(); curl_setopt($c, CURLOPT_VERBOSE, true); curl_setopt($c, CURLOPT_RETURNTRANSFER, true); curl_setopt($c, CURLOPT_HEADER, false); curl_setopt($c, CURLOPT_URL, 'http://.....'); c

  • How to set value of parameter to be in MB or in KB (in MS SQL 2008)? 2009-08-20

    It works well if I write the query like this: ALTER DATABASE [test] MODIFY FILE ( NAME = N'test_log', SIZE = 3456KB, MAXSIZE = 6789999KB, FILEGROWTH = 2345KB) But it is a problem, if I try to use parameters: ALTER DATABASE [@DbName] MODIFY FILE ( NAM

  • How to set up different parameter in a Composite Pattern? 2011-11-21

    for my develop i want to use the component-pattern because a component is part of another component. But there is one problem. The components need different parameters in the run-function (which must be implement). Does someone have a idea how to rea

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

processed in 0.206 (s). 11 q(s)