# ::Free Statistics and Forecasting Software::

v1.1.23-r7
Secure website (SSL) | Donate to wessa.net

### :: Investment Diversification - Free Statistics Software (Calculator) ::

All rights reserved. The non-commercial (academic) use of this software is free of charge. The only thing that is asked in return is to cite this software when results are used in publications.

The word risk is misused in financial circles since it is usually considered to be synonymous with variability, whereas the more common meaning of the word in lay circles is probability of loss. This demo takes a simple company scenario which is endowed with a high variability, but still has a positive expectation, and shows that if a portfolio of such companies were invested in, and if there were some independence in the experience of these companies (i.e diversification), then the probability of loss for the portfolio is negligible. Use risky() to see the result for one year with a portfolio of n=25 companies, and risky(100) for 100 simulations of this portfolio, showing the slim chance of a loss. The technical point of this program (and several others) is that sample means have an SD that is (1/sqrt(n)) times the SD of the population sampled. The practical implications of this are sometimes under-appreciated.

 Send output to: Browser Blue - Charts White Browser Black/White CSV MS Excel MS Word number of companies number of simulations Chart options Width: Height:

 Source code of R module n <- as.numeric(par1) m <- as.numeric(par2) my.dotplot <- function (x, at=.44, cex=1,...) { min=min(x) max=max(x) z=(x-mean(x))/sd(x) z=(round(10*z)/10) x=z*sd(x)+mean(x) edge=(max-min)/10 stripchart(x, method="stack",xlim=c( min-edge, max+edge), ylab="Frequency", at=at, cex=cex,...) } my.dotplot.lims <- function (x, at=.44, cex=1, x.min=x.min, x.max=x.max, scale=10, ...) { z=(x-mean(x))/sd(x) z=(round(scale*z)/scale) x=z*sd(x)+mean(x) edge=(x.max-x.min)/10 stripchart(x,method="stack",xlim=c(x.min-edge, x.max+edge),ylab="Frequency",at=at,cex=cex,...) } risky <- function (m=1,n=25) { cum=1:m a=matrix(nrow=n,ncol=m) return=c(-1,-.5,0,3) for (i in 1:m) { a[,i]=sample(return,n,T,c(.25,.25,.25,.25)) cum[i]=mean(a[,i]) } if (m ==1) { bitmap(file="mypicture.png") plot(table(a), xlab="net returns", ylab="frequency", col="purple", main="Returns Distribution") dev.off() bitmap(file="mypicture1.png") b=diffinv(a) plot(b, type="l", xlab="company ID", col="purple", ylab="cumulative net return", lwd=2, main="Cumulation of Profits") text(.20*n,max(b)-1,"Profit=",cex=2) text(.45*n,max(b)-1,100*mean(a),cex=2) text(.60*n,max(b)-1,"%",cex=2) dev.off() } if (m >1) { bitmap(file="mypicture2.png") min=min(cum)-0.1 max=max(cum)+0.1 my.dotplot.lims(cum[cum>0], main="Avg. Profit per \$1 Invested", col="blue", x.min=min, x.max=max) my.dotplot(cum[cum<0], col="red", add=TRUE) dev.off() } } risky(m,n)
 Top | Output | Charts | References | History | Feedback

 Cite this software as: Weldon L., (2012), Investment Diversification (v1.0.2) in Free Statistics Software (v1.1.23-r7), Office for Research Development and Education, URL http://www.wessa.net/rwasp_risky.wasp/ The R code is based on : Weldon Larry, R Programs for Statistics Education, Simon Fraser University, URL http://www.stat.sfu.ca/~weldon/Programs Weldon Larry, Instructions for using R programs for Statistics Education, Simon Fraser University, URL http://www.stat.sfu.ca/~weldon/instructions.doc
 Top | Output | Charts | References | History | Feedback
 Top | Output | Charts | References | History | Feedback

 [Select module] Main Menu Equation Plotter   Scientific Forecasting   Descriptive Statistics -Central Tendency -Variability -Skewness/Kurtosis -Quartiles -Percentiles -Stem and Leaf -Histogram -Kernel Density -Harrell-Davis -Univariate EDA -Bootstrap -Blocked Bootstrap -Mean Plot -SD Plot -(P)ACF -Spectrum -SD Mean-Plot -Variance Reduction -Correlation -Kendall Rank Corr. -Simple Regression -Bivariate KDE -Box-Cox Linearity -Regression Validation -Back-Back Histo. -Partial Correlation -Trivariate Scatter -Kendall tau Matrix -Notched Boxplots -Star Plot   Distributions -Normal ML Fit -Beta ML Fit -Cauchy ML Fit -Exponential ML Fit -Gamma ML Fit -Lognormal ML Fit -Logistic ML Fit -Neg. Binom. ML Fit -Poisson ML Fit -Weibull ML Fit -Tukey lambda PPCC -Box-Cox Normality   Hypothesis Tests -Mean -Skewness/Kurtosis   Multiple Regression -Estimate Equation   About this server

 Home Page Equation Plotter Time Series Analysis Multiple Regression Descriptive Statistics Statistical Distributions Hypothesis Testing Simon Fraser University Aston University Academic citations Computations Archive Search Computations R Project FAQ About Wessa.net Powered by Linux Server status page Any R Server'Herman Ole Andreas Wold''Gwilym Jenkins''Sir Ronald Aylmer Fisher''George Udny Yule''Gertrude Mary Cox''Sir Maurice George Kendall'Installed PackagesHistory list