R version 2.8.0 (2008-10-20) 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. Natural language support but running in an English locale 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 = '100' > #'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!) > 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/www/html/freestat/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab + load(file="/var/www/html/freestat/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/www/html/freestat/rcomp/tmp/11rwq1287517351.tab") + } > > #Note: the /var/www/html/freestat/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/html/freestat/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/www/html/freestat/rcomp/tmp/2m2ck1287517352.tab") > postscript(file="/var/www/html/freestat/rcomp/tmp/3m2ck1287517352.ps",horizontal=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/www/html/freestat/rcomp/tmp/4m2ck1287517352.ps",horizontal=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/www/html/freestat/rcomp/tmp/5fcb51287517352.ps",horizontal=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/3m2ck1287517352.ps tmp/3m2ck1287517352.png",intern=TRUE)) character(0) > try(system("convert tmp/4m2ck1287517352.ps tmp/4m2ck1287517352.png",intern=TRUE)) character(0) > try(system("convert tmp/5fcb51287517352.ps tmp/5fcb51287517352.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.162 0.643 1.276