01.03.2013 Views

Applied Statistics Using SPSS, STATISTICA, MATLAB and R

Applied Statistics Using SPSS, STATISTICA, MATLAB and R

Applied Statistics Using SPSS, STATISTICA, MATLAB and R

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

2.2 Presenting the Data 51<br />

Comm<strong>and</strong>s 2.3. <strong>SPSS</strong>, <strong>STATISTICA</strong>, <strong>MATLAB</strong> <strong>and</strong> R comm<strong>and</strong>s used to obtain<br />

histograms.<br />

<strong>SPSS</strong> Graphs; Histogram |Interactive; Histogram<br />

<strong>STATISTICA</strong> Graphs; Histograms<br />

<strong>MATLAB</strong> hist(y,x)<br />

R hist(x)<br />

The comm<strong>and</strong>s used to obtain histograms of continuous type data, are similar to<br />

the ones already described in Comm<strong>and</strong>s 2.2.<br />

In order to obtain a histogram with <strong>SPSS</strong>, one can use the Histogram option<br />

of Graphs, or preferably, use the sequence of comm<strong>and</strong>s Graphs;<br />

Interactive; Histogram. One can then select the appropriate number of<br />

bins, or alternatively, set the bin width. It is also possible to choose the starting<br />

point of the bins.<br />

With <strong>STATISTICA</strong>, one simply defines the bins in appropriate windows as<br />

previously mentioned. Besides setting the desired number of bins, there is instead<br />

also the possibility of defining the bin width (Step size) <strong>and</strong> the starting point<br />

of the bins.<br />

With <strong>MATLAB</strong> one obtains both the frequencies <strong>and</strong> the histogram with the<br />

hist comm<strong>and</strong>. Consider the following comm<strong>and</strong>s applied to the cork stopper<br />

data stored in the <strong>MATLAB</strong> cork matrix:<br />

» prt = cork(:,4)<br />

» [f,x] = hist(prt,6);<br />

In this case the hist comm<strong>and</strong> generates an f vector containing the<br />

frequencies counted in 6 bins <strong>and</strong> an x vector containing the bin locations. Listing<br />

the values of f one gets:<br />

» f<br />

f =<br />

27 45 32 19 18 9 ,<br />

which are precisely the values shown in Figure 2.17. One can also use the hist<br />

comm<strong>and</strong> with specifications of bins stored in a vector b, as hist(prt, b).<br />

With R one can use the hist function either for obtaining a histogram or for<br />

obtaining a frequency list. The frequency list is obtained by assigning the outcome<br />

of the function to a variable identifier, which then becomes a “histogram” object.<br />

Assuming that a data frame has been created (<strong>and</strong> attached) for cork stoppers we<br />

get a “histogram” object for PRT issuing the following comm<strong>and</strong>:<br />

> h

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!