R version 3.0.2 (2013-09-25) -- "Frisbee Sailing" Copyright (C) 2013 The R Foundation for Statistical Computing Platform: i686-pc-linux-gnu (32-bit) 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. > par7 = '20' > par6 = '0' > par5 = 'N' > par4 = '8' > par3 = '1' > par2 = '0' > par1 = '100' > par7 <- '20' > par6 <- '0' > par5 <- 'N' > par4 <- '8' > par3 <- '1' > par2 <- '0' > par1 <- '100' > #'GNU S' R Code compiled by R2WASP v. 1.2.327 () > #Author: root > #To cite this work: Wessa P., (2013), Random Number Generator for the Log-Normal Distribution (v1.0.5) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_rnglnorm.wasp/ > #Source of accompanying publication: Office for Research, Development, and Education > # > library(MASS) > par1 <- as.numeric(par1) > par2 <- as.numeric(par2) > par2 <- round(par2,2) #rounded (we want to be able to display 10 columns) > par3 <- as.numeric(par3) > par3 <- round(par3,2) #rounded (we want to be able to display 10 columns) > par4 <- as.numeric(par4) > if (par6 == '0') par6 = 'Sturges' else par6 <- as.numeric(par6) > par7 <- as.numeric(par7) > x <- array(NA,dim=c(par7,par1)) > rest.mean <- array(NA,dim=c(par7)) > rest.sd <- array(NA,dim=c(par7)) > rsd.mean <- array(NA,dim=c(par7)) > rsd.sd <- array(NA,dim=c(par7)) > for (i in 1:par7) + { + x[i,] <- rlnorm(par1,par2,par3) + x[i,] <- as.ts(x[i,]) #otherwise the fitdistr function does not work properly + dum <- fitdistr(x[i,],'log-normal') + rest.mean[i] <- dum$estimate[1] + rest.sd[i] <- dum$estimate[2] + rsd.mean[i] <- dum$sd[1] + rsd.sd[i] <- dum$sd[2] + } > nc <- par7 > if (nc > 10) nc = 10 > if (par5 == 'Y') + { + + #Note: the /var/wessaorg/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab + load(file="/var/wessaorg/rcomp/createtable") + + a<-table.start() + a<-table.row.start(a) + a<-table.element(a,'Index',1,TRUE) + for (j in 1:nc) + { + a<-table.element(a,paste('X',j),1,TRUE) + } + a<-table.row.end(a) + if (nc < par7) + { + a<-table.row.start(a) + a<-table.element(a,'Note: only the first 10 series are displayed',nc+1,TRUE) + a<-table.row.end(a) + } + for (i in 1:par1) + { + a<-table.row.start(a) + a<-table.element(a,i,header=TRUE) + for (j in 1:nc) + { + a<-table.element(a,round(x[j,i],2)) + } + a<-table.row.end(a) + } + a<-table.end(a) + table.save(a,file="/var/wessaorg/rcomp/tmp/1ql7l1382536982.tab") + } > > #Note: the /var/wessaorg/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/wessaorg/rcomp/createtable") > > a<-table.start() > a<-table.row.start(a) > a<-table.element(a,'Parameter',1,TRUE) > for (j in 1:nc) + { + a<-table.element(a,paste('X',j,sep=''),1,TRUE) + } > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,' ',1,TRUE) > for (j in 1:nc) + { + a<-table.element(a,'(SD)',1,TRUE) + } > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'# simulated values',header=TRUE) > for (j in 1:nc) + { + a<-table.element(a,par1) + } > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'true mean',header=TRUE) > for (j in 1:nc) + { + a<-table.element(a,par2) + } > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'true standard deviation',header=TRUE) > for (j in 1:nc) + { + a<-table.element(a,par3) + } > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'mean',header=TRUE) > for (j in 1:nc) + { + a<-table.element(a,round(rest.mean[j],2)) + } > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,' ',header=TRUE) > for (j in 1:nc) + { + a<-table.element(a,round(rsd.mean[j],2)) + } > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'standard deviation',header=TRUE) > for (j in 1:nc) + { + a<-table.element(a,round(rest.sd[j],2)) + } > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,' ',header=TRUE) > for (j in 1:nc) + { + a<-table.element(a,round(rsd.sd[j],2)) + } > a<-table.row.end(a) > a<-table.end(a) > table.save(a,file="/var/wessaorg/rcomp/tmp/2klfv1382536982.tab") > postscript(file="/var/wessaorg/rcomp/tmp/3layj1382536982.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > myhist<-hist(x[1,],col=par4,breaks=par6,main='Histogram of 1st simulated series',ylab='density',xlab='simulated values',freq=F) > dev.off() null device 1 > postscript(file="/var/wessaorg/rcomp/tmp/4lrld1382536982.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > myhist<-hist(rest.mean[],col=par4,breaks=par6,main='Histogram of Estimated Means',ylab='density',xlab='estimated means',freq=F) > x <- rest.mean[] > dummean <- mean(x) > dumsd <- sd(x) > curve(1/(dumsd*sqrt(2*pi))*exp(-1/2*((x-dummean)/dumsd)^2),min(x),max(x),add=T) > dev.off() null device 1 > postscript(file="/var/wessaorg/rcomp/tmp/5ther1382536982.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > myhist<-hist(rest.sd[],col=par4,breaks=par6,main='Histogram of Estimated SDs',ylab='density',xlab='estimated standard deviations',freq=F) > x <- rest.sd[] > dummean <- mean(x) > dumsd <- sd(x) > curve(1/(dumsd*sqrt(2*pi))*exp(-1/2*((x-dummean)/dumsd)^2),min(x),max(x),add=T) > dev.off() null device 1 > > try(system("convert tmp/3layj1382536982.ps tmp/3layj1382536982.png",intern=TRUE)) character(0) > try(system("convert tmp/4lrld1382536982.ps tmp/4lrld1382536982.png",intern=TRUE)) character(0) > try(system("convert tmp/5ther1382536982.ps tmp/5ther1382536982.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.917 0.318 2.218