R version 2.9.0 (2009-04-17) Copyright (C) 2009 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. > par9 = 'voorbeeld' > par8 = '20' > par7 = '' > par6 = '' > par5 = '' > par4 = '' > par3 = '1' > par2 = '150' > par1 = 'Poisson (lambda)' > par9 <- 'voorbeeld' > par8 <- '20' > par7 <- '' > par6 <- '' > par5 <- '' > par4 <- '' > par3 <- '1' > par2 <- '150' > par1 <- 'Poisson (lambda)' > #'GNU S' R Code compiled by R2WASP v. 1.0.44 () > #Author: Dr. P. Wessa > #To cite this work: Wessa, P., 2010, Demand Simulation (v1.0.0) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_demand_forecasting_simulate.wasp/ > #Source of accompanying publication: > #Technical description: > library(MASS) > library(gamlss.dist) > par2 <- as.numeric(par2) #length > par8 <- as.numeric(par8) #instances > xarr <- array(NA,dim=c(par2,par8)) > if (par1 == 'Poisson (lambda)') { + if (par3=='') par3 <- '0.3' + par3 <- as.numeric(par3) + for(i in 1:par8) { + xarr[,i] <- rpois(par2, lambda=par3) + } + x <- xarr[,1] + } > if (par1 == 'Normal (mu; sigma)') { + if (par3=='') par3 <- '0' + if (par4=='') par4 <- '1' + par3 <- as.numeric(par3) + par4 <- as.numeric(par4) + for(i in 1:par8) { + xarr[,i] <- rnorm(par2, mean=par3, sd=par4) + } + x <- xarr[,1] + } > if (par1 == 'Lognormal (mu; sigma)') { + if (par3=='') par3 <- '0' + if (par4=='') par4 <- '1' + par3 <- as.numeric(par3) + par4 <- as.numeric(par4) + for(i in 1:par8) { + xarr[,i] <- rlnorm(par2, mean=par3, sd=par4) + } + x <- xarr[,1] + } > if (par1 == 'Negative Binomial (mu; theta)') { + if (par3=='') par3 <- '1' + if (par4=='') par4 <- '4' + par3 <- as.numeric(par3) + par4 <- as.numeric(par4) + for(i in 1:par8) { + xarr[,i] <- rnegbin(par2, mu=par3, theta=par4) + } + x <- xarr[,1] + } > if (par1 == 'Zero-Inflated Poisson (mu; sigma)') { + if (par3=='') par3 <- '5' + if (par4=='') par4 <- '0.1' + par3 <- as.numeric(par3) + par4 <- as.numeric(par4) + for(i in 1:par8) { + xarr[,i] <- rZIP(par2, mu=par3, sigma=par4) + } + x <- xarr[,1] + } > if (par1 == 'Sichel - Generalized Inverse Gaussian (mu; sigma; nu)') { + if (par3=='') par3 <- '0.5' + if (par4=='') par4 <- '0.02' + if (par5=='') par5 <- '-0.5' + par3 <- as.numeric(par3) + par4 <- as.numeric(par4) + par5 <- as.numeric(par5) + for(i in 1:par8) { + xarr[,i] <- rSI(par2, mu=par3, sigma=par4, nu=par5) + } + x <- xarr[,1] + } > if (par1 == 'Sichel2 - Generalized Inverse Gaussian (mu; sigma; nu; max.value)') { + if (par3=='') par3 <- '0.5' + if (par4=='') par4 <- '0.02' + if (par5=='') par5 <- '-0.5' + if (par6=='') par6 <- '10000' + par3 <- as.numeric(par3) + par4 <- as.numeric(par4) + par5 <- as.numeric(par5) + par6 <- as.numeric(par6) + for(i in 1:par8) { + xarr[,i] <- rSICHEL(par2, mu=par3, sigma=par4, nu=par5, max.value=par6) + } + x <- xarr[,1] + } > x [1] 2 1 0 1 0 1 0 0 2 3 2 1 1 0 0 0 1 1 3 0 0 3 2 1 1 1 2 0 0 2 2 0 3 2 0 1 0 [38] 0 0 1 0 1 2 3 1 3 0 1 0 1 1 0 1 1 1 0 1 1 1 0 0 2 0 0 1 0 2 1 0 2 0 2 1 1 [75] 2 3 1 2 0 2 1 0 0 0 0 0 0 2 1 1 1 4 0 1 2 1 3 0 3 1 1 0 1 1 0 3 2 2 2 1 1 [112] 1 0 1 1 1 3 1 1 0 2 1 1 1 0 0 2 0 0 0 1 3 2 1 1 3 0 1 0 1 0 0 2 2 0 0 1 1 [149] 2 2 > write.csv(xarr,file=paste('tmp/',par9,'.csv',sep='')) > postscript(file="/var/www/html/rcomp/tmp/1dpw51271289362.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > plot(x,type='b') > dev.off() null device 1 > postscript(file="/var/www/html/rcomp/tmp/2dpw51271289362.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > myhist<-hist(x,col=2) > dev.off() null device 1 > > #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,'What is next?',1,TRUE) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,hyperlink(paste('http://www.wessa.net/Patrick.Wessa/rwasp_demand_forecasting_simulate.wasp',sep=''),'Simulate Time Series','',target='')) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,hyperlink(paste('http://www.wessa.net/Patrick.Wessa/rwasp_demand_forecasting_croston.wasp',sep=''),'Generate Forecasts','',target='')) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,hyperlink(paste('http://www.wessa.net/Patrick.Wessa/rwasp_demand_forecasting_analysis.wasp',sep=''),'Forecast Analysis','',target='')) > a<-table.row.end(a) > a<-table.end(a) > table.save(a,file="/var/www/html/rcomp/tmp/3gpvt1271289362.tab") > try(system("convert tmp/1dpw51271289362.ps tmp/1dpw51271289362.png",intern=TRUE)) character(0) > try(system("convert tmp/2dpw51271289362.ps tmp/2dpw51271289362.png",intern=TRUE)) character(0) > > #-SERVER-wessa.org > > > > proc.time() user system elapsed 0.550 0.327 0.898