generating random events (dd-mm-yyyy)

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

generating random events (dd-mm-yyyy)

Carsten Steinhoff
Hello,

I have to generate a couple of random datasets to validate an actuarial
software.
Each set has to contain at least two columns: (1) Date of the loss events
occurrence; (2) Severity of loss

I'm generating the dates on a monthly basis by, for example:
        ts(matrix(rpois(36,10)), start=c(2003, 1), frequency=12).
>From that output I generate dates "by hand", what is REALLY time consuming
:-(.

I think it should be possible to get a direct output in "real" dates
(dd.mm.yyyy). The day of occurence doesn't matter,it can be chosen randomly,
too. Important is only, that the MONTHLY simulated frequency follows the
chosen distribution.
Any ideas?

Thank you very much,

Carsten

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: generating random events (dd-mm-yyyy)

jholtman
try this:

> data.frame(dates = format(seq(ISOdate(2003,1,1), by='month', length=36),
+     format='%d.%m.%Y'), date=rpois(36,10))
        dates date
1  01.01.2003   11
2  01.02.2003    8
3  01.03.2003    7
4  01.04.2003    7
5  01.05.2003    5
6  01.06.2003   12
7  01.07.2003    9
8  01.08.2003   12
9  01.09.2003   11
.......


On 3/26/06, Carsten Steinhoff <[hidden email]> wrote:

>
> Hello,
>
> I have to generate a couple of random datasets to validate an actuarial
> software.
> Each set has to contain at least two columns: (1) Date of the loss events
> occurrence; (2) Severity of loss
>
> I'm generating the dates on a monthly basis by, for example:
>        ts(matrix(rpois(36,10)), start=c(2003, 1), frequency=12).
> >From that output I generate dates "by hand", what is REALLY time
> consuming
> :-(.
>
> I think it should be possible to get a direct output in "real" dates
> (dd.mm.yyyy). The day of occurence doesn't matter,it can be chosen
> randomly,
> too. Important is only, that the MONTHLY simulated frequency follows the
> chosen distribution.
> Any ideas?
>
> Thank you very much,
>
> Carsten
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
>



--
Jim Holtman
Cincinnati, OH
+1 513 646 9390 (Cell)
+1 513 247 0281 (Home)

What the problem you are trying to solve?

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: generating random events (dd-mm-yyyy)

Carsten Steinhoff
Hi Jim,
 
that's not exactly what I search. In your solution a sequence of dates is
generated and a poisson-frequency separatly. But I have to create for
example a poisson distributed sequence. E.g.: January 2003 = 3 Events;
February 2003 = 4 Events
 
01.01.2003
02.01.2003
03.01.2003
01.02.2003
02.02.2003
03.02.2003
 
Because there can be more events than days in a month the "day" should be
random.
 
Carsten.


  _____  

Von: jim holtman [mailto:[hidden email]]
Gesendet: Montag, 27. März 2006 01:14
An: Carsten Steinhoff
Cc: [hidden email]
Betreff: Re: [R] generating random events (dd-mm-yyyy)


try this:
 
> data.frame(dates = format(seq(ISOdate(2003,1,1), by='month', length=36),
+     format='%d.%m.%Y'), date=rpois(36,10))
        dates date
1  01.01.2003   11
2  01.02.2003     8
3  01.03.2003    7
4  01.04.2003    7
5  01.05.2003    5
6  01.06.2003   12
7  01.07.2003    9
8  01.08.2003   12
9  01.09.2003   11
.......

 
On 3/26/06, Carsten Steinhoff <[hidden email]> wrote:

Hello,

I have to generate a couple of random datasets to validate an actuarial
software.
Each set has to contain at least two columns: (1) Date of the loss events
occurrence; (2) Severity of loss

I'm generating the dates on a monthly basis by, for example:
       ts(matrix(rpois(36,10)), start=c(2003, 1), frequency=12).
>From that output I generate dates "by hand", what is REALLY time consuming
:-(.

I think it should be possible to get a direct output in "real" dates
(dd.mm.yyyy). The day of occurence doesn't matter,it can be chosen randomly,
too. Important is only, that the MONTHLY simulated frequency follows the
chosen distribution.
Any ideas?

Thank you very much,

Carsten

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html
<http://www.R-project.org/posting-guide.html>





--
Jim Holtman
Cincinnati, OH
+1 513 646 9390 (Cell)
+1 513 247 0281 (Home)

What the problem you are trying to solve?

        [[alternative HTML version deleted]]


______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: generating random events (dd-mm-yyyy)

Spencer Graves
          I can think of two possible solutions.  Both work on the fact that
the Poisson distribution is the probability of x events in some span of
time or space where the occurrence of any one event is independent of
whether there are others in that same span of time or space.

          First, have you considered just taking a random sample of the records
you have?  If they are uniformly distribution throughout the time
interval in question, that will give you what you want.

          Second, if they are not uniformly distributed throughout the time
interval in question then what about the following:

first <- as.POSIXct(strptime("2003/01/01", "%Y/%m/%d"))
last <- as.POSIXct(strptime("2005/12/31", "%Y/%m/%d"))
dt <- last-first

nSamples <- 5
set.seed(1)
(rDates <- first+
      runif(nSamples)*as.numeric(dt))
[1] "2003-01-01 00:04:50 Pacific Standard Time"
[2] "2003-01-01 00:06:47 Pacific Standard Time"
[3] "2003-01-01 00:10:27 Pacific Standard Time"
[4] "2003-01-01 00:16:34 Pacific Standard Time"
[5] "2003-01-01 00:03:40 Pacific Standard Time"
 >
          hope this helps.
          spencer graves
p.s.  Have you reviewed vignette('zoo')?  I found it very worthwhile,
especially since edit(vignette('zoo')) [or Stangle(vignette('zoo')$file)
  if you use ESS (Emacs Speaks Statistics)] will create a file
containing the R commands described in the vignette;  this makes it very
easy to execute the commands line by line, modify them in any way you
want to help you test variants, etc.

Carsten Steinhoff wrote:

> Hi Jim,
>  
> that's not exactly what I search. In your solution a sequence of dates is
> generated and a poisson-frequency separatly. But I have to create for
> example a poisson distributed sequence. E.g.: January 2003 = 3 Events;
> February 2003 = 4 Events
>  
> 01.01.2003
> 02.01.2003
> 03.01.2003
> 01.02.2003
> 02.02.2003
> 03.02.2003
>  
> Because there can be more events than days in a month the "day" should be
> random.
>  
> Carsten.
>
>
>   _____  
>
> Von: jim holtman [mailto:[hidden email]]
> Gesendet: Montag, 27. März 2006 01:14
> An: Carsten Steinhoff
> Cc: [hidden email]
> Betreff: Re: [R] generating random events (dd-mm-yyyy)
>
>
> try this:
>  
>
>>data.frame(dates = format(seq(ISOdate(2003,1,1), by='month', length=36),
>
> +     format='%d.%m.%Y'), date=rpois(36,10))
>         dates date
> 1  01.01.2003   11
> 2  01.02.2003     8
> 3  01.03.2003    7
> 4  01.04.2003    7
> 5  01.05.2003    5
> 6  01.06.2003   12
> 7  01.07.2003    9
> 8  01.08.2003   12
> 9  01.09.2003   11
> .......
>
>  
> On 3/26/06, Carsten Steinhoff <[hidden email]> wrote:
>
> Hello,
>
> I have to generate a couple of random datasets to validate an actuarial
> software.
> Each set has to contain at least two columns: (1) Date of the loss events
> occurrence; (2) Severity of loss
>
> I'm generating the dates on a monthly basis by, for example:
>        ts(matrix(rpois(36,10)), start=c(2003, 1), frequency=12).
>>From that output I generate dates "by hand", what is REALLY time consuming
> :-(.
>
> I think it should be possible to get a direct output in "real" dates
> (dd.mm.yyyy). The day of occurence doesn't matter,it can be chosen randomly,
> too. Important is only, that the MONTHLY simulated frequency follows the
> chosen distribution.
> Any ideas?
>
> Thank you very much,
>
> Carsten
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
> <http://www.R-project.org/posting-guide.html>
>
>
>
>
>
>
>
> ------------------------------------------------------------------------
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html