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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

3.4 Estimating a Variance 95<br />

is to convert the variable being analysed into a Bernoulli type variable, i.e., a<br />

binary variable with 1 coding the “success” event, <strong>and</strong> 0 the “failure” event. As a<br />

matter of fact, a dataset x1, …, xn, with k successes, represented as a sequence of<br />

values of Bernoulli r<strong>and</strong>om variables (therefore, with k ones <strong>and</strong> n – k zeros), has<br />

the following sample mean <strong>and</strong> sample variance:<br />

x =<br />

v<br />

n<br />

∑ x = ≡<br />

i= i / n k / n pˆ<br />

1<br />

n<br />

i 1<br />

= ∑ =<br />

( xi<br />

− pˆ<br />

)<br />

n −1<br />

2<br />

npˆ<br />

=<br />

2<br />

.<br />

− 2kpˆ<br />

+ k n<br />

2<br />

= ( pˆ<br />

− pˆ<br />

) ≈ pˆ<br />

qˆ<br />

.<br />

n −1<br />

n −1<br />

In Example 3.5, variable DISPL with values 1 for “Yes” <strong>and</strong> 2 for “No” is<br />

converted into a Bernoulli type variable, DISPLB, e.g. by using the formula<br />

DISPLB = 2 – DISPL. Now, the “success” event (“Yes”) is coded 1, <strong>and</strong> the<br />

complement is coded 0. In <strong>SPSS</strong> <strong>and</strong> <strong>STATISTICA</strong> we can also use “if” constructs<br />

to build the Bernoulli variables. This is especially useful if one wants to create<br />

Bernoulli variables from continuous type variables. <strong>SPSS</strong> <strong>and</strong> <strong>STATISTICA</strong> also<br />

have a Rank comm<strong>and</strong> that can be useful for the purpose of creating Bernoulli<br />

variables.<br />

Comm<strong>and</strong>s 3.4. <strong>MATLAB</strong> <strong>and</strong> R comm<strong>and</strong>s for obtaining confidence intervals of<br />

proportions.<br />

<strong>MATLAB</strong> ciprop(n0,n1,alpha)<br />

R ciprop(n0,n1,alpha)<br />

There are no specific functions to compute confidence intervals of proportions in<br />

<strong>MATLAB</strong> <strong>and</strong> R. However, we provide for <strong>MATLAB</strong> <strong>and</strong> R the function<br />

ciprop(n0,n1,alpha)for that purpose (see Appendix F). For Example 3.5<br />

we obtain in R:<br />

> ciprop(95,37,0.05)<br />

[,1]<br />

[1,] 0.2803030<br />

[2,] 0.2036817<br />

[3,] 0.3569244 <br />

3.4 Estimating a Variance<br />

The point estimate of a variance was presented in section 2.3.2. This estimate is<br />

also discussed in some detail in Appendix C. We will address the problem of

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

Saved successfully!

Ooh no, something went wrong!