Você está na página 1de 3

Excel hints

It is assumed that every student has a basic knowledge of excel: how to enter data, how to enter
equations, how to call functions, how to make graphs, etc. Below are some additional tips that you
may not know yet. Please refer to the help file of excel itself for more detailed information. You can
also find many hands-on webpages to help you on the way.

Installing Add-ins (see movie on Blackboard: solver and data analysis installation in excel.avi)
For the course you have to install some Add-ins, in any case the Add-ins ‘Data Analysis’ and the
‘Solver’ (they may have been installed already, check this under the Tab Data). If not, go to the ribbon
File, Options, Add-ins and choose Data Analysis. Do the same for the Add-in Solver. To use these
Add-ins go to the ribbon and click on the Tab Data, then you should find them ready for use.

Installing the MacroBundle12


Alternative to the procedure below you can also follow the instruction as explained in
the movie on Blackboard: macrobundle12 installation in excel.avi
The Macrobundle12 is written by dr. Robert de Levie (see the website Excellaneous,
http://www.bowdoin.edu/~rdelevie/excellaneous and his book Advanced Excel for scientific data
analysis, 3rd edition). We will use several of the macros developed by him and others. Here is how to
install the macros:
- Open Word and open the file Macrobundle12.doc, then go to the ribbon, Tab Home, then
Editing, choose select all, and copy the text onto the clipboard.
- Close Word and then open Excel, go to the ribbon, select the Tab Developer (if you cannot
find this Tab, go to File – Options – Customize and click on the Tab Developer)
- click Visual Basic, then go to Insert, Module, and paste the selected text from the
MacroBundle12 into the module.
- Then go to File, and click on Close and Return to Excel.
- Back in Excel, if you go to the Tab Developer and click on Macros, you can then select the
macro you need.
- Because you will be using these macros quite often, it is probably easier to run first the macro
InsertMBToolbar, this will install the macros in a toolbar for easy access. If you save the
excel file with the extension .xlsm, the macros will be saved with your data.

Statistical functions
Excel has an enormous amount of statistical functions. Some you may need to install such as Data
Analysis and the Solver (described above). With Data Analysis you can do such things as linear
regression, make histograms, apply descriptive statistics, among many other things.
Solver is needed to do nonlinear regression.

When you want to calculate probabilities you have to indicate confidence levels or the uncertainty
level and the degrees of freedom df (number of data points minus the number of parameters). These
two are complimentary, for instance an assumed uncertainty α=0.05 corresponds to a confidence level
of 1- α = 0.95 (95%). So, the Student t-function t(α,df) can be called as =TINV(α,df) in older versions
of Excel or with the equivalent new function =T.INV.2T(α,df) (two-tailed t-values). The Fisher
function F(α,1,df) = FINV(α,1,df) for older versions and the equivalent new function is F.INV(1-
α,1,df).

Data table
The function data table is useful to recalculate a function for a range of values of a parameter, you can
do that for one and for two parameters. Click the tab Data and then What-if analysis and the Data
table. See the pdf file Resampling with Excel by Derek Christie, Teaching Statistics 26(2004)9-14,
uploaded to Blackboard.

1
Random Numbers and Resampling methods
The function =Rand() produces random numbers from a uniform distribution between 0 and 1
(uniform means: all values have an equal chance of being selected). The function =Randbetween(x,y)
produces random numbers between x and y. You can convert a uniform distribution to a normal
distribution via the function =norminv(Rand(), mean, stdev). For instance, the function
=norminv(rand(), 100,10) generates a normal distribution of random numbers, i.e. centered on the
mean 100 with a standard deviation of 10.

The function =Index() can be used to find values in a range or an array, which is useful for
resampling. The data table is also used for resampling.

Naming cells
It can be helpful to refer to an array of cells via a name, it makes the spreadsheet much more readable.
Choose a name that reminds you of what the name refers to (e.g., MatrixA for a matrix). Highlight an
array, then go to Insert -> Name

Array operations
Functions operating on an array (such as matrix operations) must be entered with the command Crtl-
Shift-Enter (so not just by Enter).

Some further guidelines for modelling and regression in Excel


1. Always plot data before you start modelling. It gives you a first idea of what type of model
could be applicable. Also, use your food science knowledge to think about a possible model.
2. The purpose of modelling is to capture the information within the data in a mathematical
equation. You then need to estimate the parameters of the model and their uncertainties.
3. If you think a linear model is applicable, then linear regression is your choice for parameter
estimation. Excel has several possibilities for that, but you can also use the macro LS1 from
the Macrobundle, which gives you the most useful statistical information, notably standard
deviations of the parameters and the covariances.
4. If you have replicates available, use that information. Do not average but estimate all the data,
and if the errors seem to be heteroscedastic, then use weighted regression using the macro
WLS1 for weighted linear regression.
5. If you decide for a nonlinear model, use nonlinear regression. For nonlinear regression, you
need to provide starting values for the parameters and you need to calculate the sums-of-
squares. Plot the model with the data using these starting values to see whether the starting
values are not too far off. Then use Solver to estimate the parameters. Next, use the macro
SolverAid to estimate the standard deviations of the parameters and the covariances.
6. Once you have fitted a model to the data, check for possible trends in the residuals
7. If you suspect that the parameters are quite strongly correlated make contour plots via the F-
statistic or make plots of the sums-of-squares near the minimum. If you obtain elongated
ellipses, this signals problems and you should be very careful in using the estimates. They
may turn out to give very imprecise predictions.
8. If you decide to transform data (for instance, to transform a nonlinear equation into a linear
one), make sure you correct for the transformation and use the corrections for weighted linear
regression via the macro WLS1.
9. If you are going to do calculations with the estimated parameters, make sure that you involve
the uncertainties in the parameters using the macro Propagation. Use the covariance matrix
for this macro.
10. If you have more models that describe the data reasonably well, and you want to compare the
performance of each model, use the Akaike criterion. The model with the lowest Akaike
value performs the best in the statistical sense.

Below you find a flow chart that summarizes the guidelines.

Plot data and choose model

Linear model? Nonlinear model?

Transformation to a No
Homoscedastic ? Heteroscedastic? linear model? transformation

Correct for
transformation by Homoscedastic ? Heteroscedastic?
deriving weights

Nonlinear Nonlinear weighted


Linear regression Linear weighted regression regression using
using the macro LS1 regression using the using Solver Solver and
or the Data Analysis macro WLS1 and SolverAid SolverAid
Toolpack

Evaluate residuals, the estimates and their uncertainties, check for parameter correlations, make contour plots

In the case of more models, use Akaike to evaluate model performance, and make a choice

Use the macro Propagation to calculate uncertainties in predictions

Literature about Excel:

R. de Levie, Advanced Excel for scientific data analysis, 3rd Edition, Atlantic Academic, 2012.
E.J. Billo, Excel for Scientists and Engineers. Wiley, 2007
E.J. Billo, Excel for Chemists, 3rd Edition, Wiley, 2011
D.M. Bourg, Excel Scientific and Engineering Cookbook., O’Reilly, 2006

Você também pode gostar