R version 2.13.0 (2011-04-13) Copyright (C) 2011 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: i486-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 = '100' > par6 = '0' > par5 = 'N' > par4 = '8' > par3 = '1' > par2 = '0' > par1 = '10' > 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/1uqoy1318977660.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/217kc1318977661.tab") > postscript(file="/var/wessaorg/rcomp/tmp/39l4y1318977661.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/469g31318977661.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/5ucoa1318977661.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/39l4y1318977661.ps tmp/39l4y1318977661.png",intern=TRUE)) character(0) > try(system("convert tmp/469g31318977661.ps tmp/469g31318977661.png",intern=TRUE)) character(0) > try(system("convert tmp/5ucoa1318977661.ps tmp/5ucoa1318977661.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 0.971 0.168 1.162