Displaying posts filed under

Excel

Dec
23
2009

VBA function for multiple comparison

In SAS, lsmeans treatment /pdiff of PROC mixed or GLM output mean values and a matrix of probability values of all pair wise comparison. However, we have to create the traditional comparison table by ourselves. In order to automate the process, I developed a VBA function to do the job. The source code is the [...]

Nov
4
2009

Construction of objective function in optimization problem

Many optimization procedures require a single objective function. How to construct an efficient objective function in optimization problem is a critical. Sometimes we have multiple goals, how to create a single function to integrate all the goals together? Sometimes, even though we have a single goal, but we have specific aspect of requests for the [...]

Sep
13
2009

Table with Excel – TWE 2.0

Introduction
Microsoft Excel is very popular spreadsheet software. It is widely used in education, in scientific research, in managing financial activities. Nowadays, the common versions of Microsoft Excel are version 2003 and 2007. The functions of these versions are very powerful and include enormous functions and possibilities.
Scientists and engineers use Microsoft Excel to record and keep [...]

Aug
27
2009

An example for generating experimental layout

Dr. Roe asked me to generate a pot map for her growth chamber experiments. Since she will do the experiments again and again. One fixed map is not good. I wrote some VBA code in Excel and create an Excel Add-in. This program can generate pot layout randomly. All you have to do is put [...]

Aug
27
2009

Chi Sqaure test in Excel

It is pretty easy to do Chi Square Test in Excel. First you need arrange your dat in table with one or two categories, then calculate the theretical value for each interactions (cells). Then just put the actual data and theoretical data into CHITEST worksheet function.
Sometimes that you need deal with your raw data first, [...]

Aug
27
2009

Extracting data from the searching results of citation database

Today (Sept. 25, 2002), my major advisor asked me to extract citation data from one text file he created and sent me through email. After I looked at the data, I realized that the data came from the citation databases, such as AGRICOLA, Biological Abstract, CAB, and so on. The requirements that you asked me [...]

Aug
27
2009

Search maximum and minimum of a function in a given range and its corresponding value of independent variable

More often, we need find the maximum or minimum value of a function within a given range. In Excel, we can develop a user-defined worksheet function to fulfill this goal. Here provides a user-defined function called minmax. This function is very powerful because it can be applied to any polynomial equation.
The definition of the [...]

Aug
27
2009

Estimation of confidence interval and predicted values of the dependent variable in a linear equation

Here provides a user-defined function to estimate predicted values of the dependent variable and corresponding confidence interval for a given dataset with linear relationship. The function definition is the following:
yhat(Y, X, XNew, CI, alpha)
Where, Y includes values of the dependent variable; X includes values of independent variables (can includes multiple columns (variables)); XNew includes new [...]

Aug
27
2009

Frequency histogram 制作频率分布图

相关函数介绍
1.FREQUENCY函数
返回指定数据和分组的频率数组。函数FREQUENCY的语法形式为:
FREQUENCY(data_array,bins_array)
其中Data_array为一数组或对一组数值的引用,用来计算频率。如果 data_array 中不包含任何数值,函数FREQUENCY返回零数组。Bins_array为一数组或对数组区域的引用,设定对data_array进行频率计算的分段点。如果bins_array中不包含任何数值,函数FREQUENCY返回data_array元素的数目。
看起来FREQUENCY的用法蛮复杂的,但其用处很大。比如可以计算不同工资段的人员分布,公司员工的年龄分布,学生成绩的分布,不同品种的产量分布情况等。这里以具体示例说明其基本的用法。
2.NORMDIST函数
返回给定平均值和标准偏差的正态分布的累积函数。函数的语法为:
NORMDIST(x,mean,standard_dev,cumulative)
x是需要计算累计概率的数据,mean为平均值,standard_dev为标准差,cumulative可以使TRUE或FALSE,当计算累计概率时取TRUE。
应用实例
例1、计算员工年龄分布情况
1)在工作表里第一列(A2:A9)输入员工的年龄,数据为28、25、31、21、44、33、22和35;
2)在C2:C5单元格中输入25、30、35、和40;
3)选择D2:D6单元格,输入=FREQUENCY(a2:a9,c2:c5),按CTRL+SHIFT+ENTER输入数组。
这样就可以计算出年龄在25岁以下、26~30岁、31~35岁、36~40岁和40岁以上各区间中的数目。本例中选择了5个垂直相邻的单元格后,即以数组方式输入公式。返回的数组中的元素个数比bins_array(数组中的元素个数多1。第五个数字1表示大于最高间隔(40)的数值(44)的个数。函数FREQUENCY忽略空白单元格和文本值。该例在age工作表中。
例2、在处理科学试验结果时,我们往往希望看看试验数据是否符合正态分布,最简单的办法是做频率分布图。本例中生成100个随机数字,然后对这些数据做频率分布图。
1)EXCEL提供了一个数据分析包(Analysis toolpak),打开该分析包的方法是使用ADD-INS菜单命令。
2)使用菜单命令Tools|Data Analysis…,在弹出菜单中选中”Random Number Generation”,完成对话框中的相应输入框,在A2:A101单元格中生成100个随机数字。
3)命名A2:A101为data;
4)计算数据的平均值和标准差,在D1和D2中分别输入=AVERAGE(data)和=STDEV(data);
5)在C5:C17中输入8.50到11.50,以0.50为间隔,这就是Bins_array;
6)选择D5:D17,输入=frequency(data,c5:c17)并按CTRL+SHIFT+ENTER输入该公式;
7)计算总频率数,在D18中输入=sum(d5:d17);
8)计算期望频率,在E5中输入=$d$18*normdist(c5,mean,stdev,true),在E6中输入=$d$18*(normdist(c6,mean,stdev,true)-normdist(c5-mean,stdev,true)),使用向下填充直到E16,在E17中输入=$d$18*(1-normdist(c16,mean,stdev,true));
在E5中计算数据小于等于8.5的累计概率,在E6-E16中两个连续数据(一组)的期望频率,在E17中计算数据大与等于11.5的累计概率;
9)计算期望频率的总和,在D18中输入=sum(e5:e17).
10)制作频率分布图:选中D5:E17,做一个连线图(Line),单击’Series’标签,在’Category(X) axis labels’中选中C5:C17,等图形完成后,选中实际数据线,单击鼠标右键,在弹出的右键菜单中选中’Chart type’,将其设置成柱状图(Cloumn),并设置间隙为0;并格式化Normal数据为平滑曲线。

[...]

Aug
23
2009

Use Excel Solver to solve non-linear problem – solution of general neural network

Excel is a powerful application. With additional Add-ons, it can be used to solve very complicated problem. Recently, one of my friends ask me how to solve neural network problem in Excel. Sure it can do the job. I will start with solving a very simple non-linear problem by using Excel Solver and extend the [...]