R version 2.6.2 (2008-02-08) Copyright (C) 2008 The R Foundation for Statistical Computing ISBN 3-900051-07-0 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > par6 = 'TRUE' > par5 = '0.2' > par4 = '6000' > par3 = '1460' > par2 = '100' > par1 = '325' > ylab = 'Frequency' > xlab = 'Profit' > main = 'Profit/Policy/Year' > #'GNU S' R Code compiled by R2WASP v. 1.0.44 () > #Author: Prof. Dr. P. Wessa > #To cite this work: AUTHOR(S), (YEAR), YOUR SOFTWARE TITLE (vNUMBER) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_YOURPAGE.wasp/ > #Source of accompanying publication: Office for Research, Development, and Education > #Technical description: Write here your technical program description (don't use hard returns!) > par1 <- as.numeric(par1) > par2 <- as.numeric(par2) > par3 <- as.numeric(par3) > par4 <- as.numeric(par4) > par5 <- as.numeric(par5) > if (par6 == 'TRUE') par6 <- TRUE > if (par6 == 'FALSE') par6 <- FALSE > reps = par1 > policies = par2 > prem = par3 > cost = par4 > prob = par5 > Poisson = par6 > gross.profit <- 1:policies > gross.profit.rate <- 1:reps > if (Poisson==T) { + for (j in 1:reps) { + totalcost=cost*rpois(policies,prob) + gross.profit=prem-totalcost + gross.profit.rate[j]=sum(gross.profit)/policies + } + } > if (Poisson==F){ + for (j in 1:reps) { + totalcost=cost*rbinom(policies,1,prob) + gross.profit = prem-totalcost + gross.profit.rate[j] = sum(gross.profit)/policies + } + } > risk <- 100 * (length (gross.profit.rate[gross.profit.rate < 0]))/reps > print(risk) [1] 15.07692 > avgprofit <- format(mean(gross.profit.rate), digits = 5) > sdprofit <- format(sd(gross.profit.rate), digits = 5) > postscript(file="/var/www/html/rcomp/tmp/1i34h1208477054.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > stripchart(gross.profit.rate, method = 'stack', main = main, xlab = xlab, ylab = ylab, col = 'blue',at=0.1) > stripchart(gross.profit.rate[gross.profit.rate<0], method = 'stack', col = 'red', add = TRUE, at=0.1) > dev.off() null device 1 > x<-rnorm(100) > > #Note: the /var/www/html/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/html/rcomp/createtable") > > a<-table.start() > a<-table.row.start(a) > a<-table.element(a,'Summary Statistics',2,TRUE) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'Number of policies',header=TRUE) > a<-table.element(a,policies) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'Number of simulations',header=TRUE) > a<-table.element(a,reps) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'Mean of gross profit per policy in USD',header=TRUE) > a<-table.element(a,avgprofit) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'Risk of loss in percent',header=TRUE) > a<-table.element(a, round(risk,0) ) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'SD of gross profit per policy',header=TRUE) > a<-table.element(a,sdprofit) > a<-table.row.end(a) > a<-table.end(a) > table.save(a,file="/var/www/html/rcomp/tmp/2uw3n1208477054.tab") > > system("convert tmp/1i34h1208477054.ps tmp/1i34h1208477054.png") > > > proc.time() user system elapsed 0.635 0.180 0.703