690 views

Uploaded by jopaome_007

- Regression Analysis with Scilab
- Ols Regression in excel
- 62149888 Thesis Proposal
- Bivariate Analysis
- Discussion Emp
- Strategic plan implementation and organizational performance: a case of Hargeisa Water Agency in Somaliland
- sparrow
- Comparing Two Measurement Devices
- Methodology for the Development of Normative Data for Ten Spanish-language Neuropsychological Tests in Eleven Latin American Countries
- Statistic-SimpleLinearRegression
- Presentaion; Airline Price Discrimination
- JFE Boards 2008
- Is Greener Whiter? Voluntary Environmental Performance of Western Ski Areas
- Case8 Napa Solutions
- Mar27 Syntax
- MODEL BUILDING
- 79c
- Dinda Spss
- Output
- OUTPUT.doc

You are on page 1of 4

Introduction

"Least-squares" regression is a common data analysis technique that is used to determine whether a partic-

ular model explains some experimental data. The model is represented by some function y = f (x), where

x and y are the two bits of data measured in the experiment. The value x is called the independent variable,

since it is the one we can set arbitrarily. Similarly, y is called the dependent variable, since it depends on x

and the model (function) f .

Hopefully you remember that a line has the parametric form

y = f (x)

= mx + b

Thus, our function f has two parameters, m, the slope of the line, and b, the line’s y-intercept. The goal of

regression is twofold. First, it is to find the "best" values of the parameters of the model f (in the linear case

case, m and b). Second, we wish to determine whether this model gives a reasonable explanation for the

data.

The first goal is met by finding the values of the parameters that give a curve that fits the data points

best. Technically, our best line will minimize the average squared distance from the line to the points. We

won’t go in to the theory of why this works (you should take Math 209, or even better, Math 335!), but next

we’ll talk about how to easily find such a line (and visualize it) using Gnuplot.

Gnuplot can be used interacdtively, or a series of commands can be collected into a file and run in batch

mode. We’ll build up our results incrementally and detail individual commands, but they may be easily be

collected together. You can start Gnuplot by issuing the command gnuplot in a terminal window.

Plotting Data

The data being used should be stored in a file where each line contains an (x, y) pair in the simple (space

separated) format

xVal yVal

gnuplot> plot ’filename’ using 1:2 title ’My Experiment’ with points

1

where filename is the file containing the data you wish to plot.1 The using 1:2 part directs Gnuplot

to use the first and second columns of the data, while with points part directs Gnuplot to plot these as

disconnected points. There are other options, as we shall soon see.

You should of course, give the plot a meaningful title (rather than “My Experiment.”) You would do

well to label the axes so that others (or you, should you look back at this next week) know what is being

plotted. For example, if your values represent the time to send a message via carrier pigeon with respect to

the message size, you could do this with the commands

gnuplot> set ylabel “Time (hours)”

but you must issue the label commands before the plot command. Don’t forget the very useful units! This

should give you something that looks like the following (on screen)

14000

Carrier Pigeon Delivery

12000

10000

8000

Time (min)

6000

4000

2000

0

0 10000 20000 30000 40000 50000 60000 70000

Message size (mg)

Now we’ve got some data on some axes, and we know (vaguely) how to access it with the plot command.

So far so good. What about this regression bit?

Regression

The first thing we need to do is define the function we want to fit to the data. In our example, we’re talking

about a line, so we define our simple function (model) as a line for Gnuplot.

Now, Gnuplot has the regression thing down. It knows what to do simply when you tell it:

What you should see back is the results of a few iterations of the process for fitting the line. The last bit

should look something like:

1

We show commands with the Gnuplot command prompt “gnuplot>”. You should not type this, and if these were put into a

script, you of course would not copy the “gnuplot>”.

2

After 7 iterations the fit converged.

final sum of squares of residuals : 5.33793e+06

rel. change during last iteration : -1.30122e-12

rms of residuals (stdfit) = sqrt(WSSR/ndf) : 109.156

variance of residuals (reduced chisquare) = WSSR/ndf : 11915

======================= ==========================

m = 0.174844 +/- 0.0002964 (0.1695%)

b = 1506.34 +/- 5.756 (0.3821%)

m b

m 1.000

b -0.448 1.000

There’s a lot of info there about the nature of the data, and how well Gnuplot was able to fit it, but the part

you probably care most about is “What are the parameters?” This is probably fairly straight forward to read

off from the “Final set of parameters” section. In this data, the slope is 0.1748 and the y-intercept is about

1500.

The next question is, does it look like this line fits our data? We can plot the line (Gnuplot stores the

parameters m and b after the fitting process) with the command

gnuplot> plot f(x) title ’Line Fit’

This will in fact plot the line with the appropriate values of m and b over an arbitrary domain (-10,10).

However, it’s probably more interesting to see the line plotted with the original data. We can do this if we

issue both directives in the same command:

with points, f(x) title ’Model Fit’

This should give you something like the following image on screen.

14000

Carrier Pigeon Delivery

Model Fit

12000

10000

8000

Time (min)

6000

4000

2000

0

0 10000 20000 30000 40000 50000 60000 70000

Message size (mg)

3

Next we need to describe how to save these images to a file.

Gnuplot-ting to a file

Because it was designed in the days before rampant GUI usage, Gnuplot may seem a bit archaic with respect

to its file-saving methods. It is more analagous to shell-based pipes and output redirection than any modern

software. Saving the plots to a file involves three basic steps.

1. Direct the output to an appropriate “terminal.” This acts as a filter that puts the data in the correct

form for whatever format you want the output to be in. It’s sort of like using a command-line pipe

of the format “gnuplot | gp2img” where gnuplot generates some plot structure and gp2img

translates the output into an image.

2. Next, we need to say where the output should finally be stored. This is just like using the shell to

direct the standard output of a program into a file, such as “gp2img > file.dat”

3. Finally, we actually need to issue the plot commands. This would be the input to gnuplot that tells

it what to generate (that is eventually passed to a filter and written to a file). This could be akin to

directing a file to standard input, such as “gnuplot < commands”. In actuality the plot commands

may either be given in interactive mode (once the terminal and output are set above), or via a command

file.

Step 3 was detailed in the previous sections. The plot commands may be put into a file, or given at the

interactive prompt. Steps 1 and 2 are very easy. The syntax may vary with the output format desired, but

PNG is a compact, widely supported format, so we’ll use that as an example:

gnuplot> set output ’file.png’

These easily accomplish steps 1 and 2 above. Any subsequent plot directives will be stored in file.png

until a new output file is specified with another ”set output” command. You can return to plotting to

the screen by issuing another “redirecting” set terminal command:

Gnuplot is a robust and highly versatile piece of software. There are many more options than the very brief

portrait given here. To learn more, you should view some of the plethora of tutorials on the web.

- Regression Analysis with ScilabUploaded bywakko29
- Ols Regression in excelUploaded byTan Tar
- 62149888 Thesis ProposalUploaded bySaravanan Rasaya
- Bivariate AnalysisUploaded byAnonymous I4p7bNBDl
- Discussion EmpUploaded byfriend_foru2121
- Strategic plan implementation and organizational performance: a case of Hargeisa Water Agency in SomalilandUploaded byIOSRjournal
- sparrowUploaded bynoluv4thugs
- Comparing Two Measurement DevicesUploaded byzilangamba_s4535
- Methodology for the Development of Normative Data for Ten Spanish-language Neuropsychological Tests in Eleven Latin American CountriesUploaded byDaniela Andrea Marin Catalan
- Statistic-SimpleLinearRegressionUploaded bymfah00
- Presentaion; Airline Price DiscriminationUploaded byMishra Sukesh
- JFE Boards 2008Uploaded byPrasad Hegde
- Is Greener Whiter? Voluntary Environmental Performance of Western Ski AreasUploaded byFlora May Mendoza
- Case8 Napa SolutionsUploaded byamt801
- Mar27 SyntaxUploaded byAzrul Fazwan
- MODEL BUILDINGUploaded byVinay Agarwal
- 79cUploaded bySalman Zia
- Dinda SpssUploaded byTrisna Putra
- OutputUploaded byAdi Sarli
- OUTPUT.docUploaded byRamadhan Sukma P
- OutputUploaded byasriniadesilia
- Lecture 02 Revisedeconometrics regressionUploaded byAnubhav Bigamal
- Standard Errors for Regression Equations(3).pdfUploaded byCalvin Kessler
- empirical study on PPP theory with japan and us price levelsUploaded byAdrian Campos
- WP2013-086Uploaded byanniemaverick
- Unit-9Uploaded byswingbike
- Application of D-optimalUploaded byGanesh K C
- Q_CT3.pdfUploaded bypooja sharma
- Chapter12.pdfUploaded byangiemmendoza4366
- valores extremosUploaded byGise Quintero

- 13 Citibank RewardsCatalogueUploaded byChong Chie Fong
- Module 3 Revised Part-IIUploaded byali3800
- Final Draft - Media Release End of TU Action Draft-1Uploaded byuteachers_sl
- Wikistrat-The-Geopolitics-of-Energy.pdfUploaded byDel Libro
- Leaflets and BrochureUploaded byAnusha Prasad
- Ramya Market Study-kundrathurUploaded byramya_an2411
- Consumer Feedback Toolkit - 5.1 Conducting in-Depth Interviews With ConsumersUploaded byEric Justice
- Lecture-4 (Microprocessors and Microcontrollers)Uploaded byKhuleedShaikh
- Fish PondUploaded byDominic Lucero
- Introduction to Networking SlidesUploaded byArpanShukla
- RichardHelms-FBI1Uploaded byIon Vasilescu
- Seminar Abstract Bibin Raj b s s7 Cse bUploaded byBibin Raj B S
- 12 Swp Internet ThingsUploaded byIonut Radu
- Apriso WhitePaper How Next Gen MOM Can DriveUploaded byHarish Aditya
- History of ProbabilityUploaded byJo Ey Goh
- AGS_F1_ENUploaded byBalaji
- European Committee for Standardization.pdfUploaded byAdolfo Cano Guervos
- Comp_sciUploaded byaakash
- Template_ResumeUploaded byTian Nak
- 156 Keyboard Shortcuts for Pro ToolsUploaded byJuan Camilo Aranzalez M
- Phantom 3 4K User Manual EnUploaded bySergio Tulio Valarezo Campoverde
- Dynaco PAS-3X Stereo Preamplifier - Assembly, Operation & SchematicUploaded byjimmy67music
- Jasperreports Server User GuideUploaded byAna Boza Leiva
- Ba Baroli Dmxx eUploaded byjon1224
- Pruftechnik Group Profile.pdfUploaded byRichard Bps
- What You Need to Know About GMOs 2.0 and the Future of Our FoodUploaded byBruno Gonçalves
- “ CHALLENGES OF IMPLEMENTING ENTERPRISE RESOURCE PLANNING(ERP) PROJECTS IN MANUFACTURING INDUSTRIES ”Uploaded byjoseph_soj7852
- Effect of Knives Type on Some Operational Characteristics fora Locally Assembly Motorized Vibration Cutter Used for Date Palm Fronds PruningUploaded byIJEAB Journal
- MSDS Sodium CarbonateUploaded byEndang Supriyatna
- Advanced Database SyllabusUploaded byrambalajir