06.09.2021 Views

Learning Statistics with R - A tutorial for psychology students and other beginners, 2018a

Learning Statistics with R - A tutorial for psychology students and other beginners, 2018a

Learning Statistics with R - A tutorial for psychology students and other beginners, 2018a

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.

Preface<br />

Table of Contents<br />

I Background 1<br />

ix<br />

1 Why do we learn statistics? 3<br />

1.1 On the <strong>psychology</strong> of statistics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3<br />

1.2 The cautionary tale of Simpson’s paradox . . . . . . . . . . . . . . . . . . . . . . . . . . 6<br />

1.3 <strong>Statistics</strong> in <strong>psychology</strong> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8<br />

1.4 <strong>Statistics</strong> in everyday life . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10<br />

1.5 There’s more to research methods than statistics . . . . . . . . . . . . . . . . . . . . . . 10<br />

2 A brief introduction to research design 11<br />

2.1 Introduction to psychological measurement . . . . . . . . . . . . . . . . . . . . . . . . . 11<br />

2.2 Scales of measurement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14<br />

2.3 Assessing the reliability of a measurement . . . . . . . . . . . . . . . . . . . . . . . . . . 19<br />

2.4 The “role” of variables: predictors <strong>and</strong> outcomes . . . . . . . . . . . . . . . . . . . . . . 20<br />

2.5 Experimental <strong>and</strong> non-experimental research . . . . . . . . . . . . . . . . . . . . . . . . 20<br />

2.6 Assessing the validity of a study . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22<br />

2.7 Confounds, artifacts <strong>and</strong> <strong>other</strong> threats to validity . . . . . . . . . . . . . . . . . . . . . . 25<br />

2.8 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33<br />

II An introduction to R 35<br />

3 Getting started <strong>with</strong> R 37<br />

3.1 Installing R . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38<br />

3.2 Typing comm<strong>and</strong>s at the R console . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42<br />

3.3 Doing simple calculations <strong>with</strong> R . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46<br />

3.4 Storing a number as a variable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48<br />

3.5 Using functions to do calculations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51<br />

3.6 Letting Rstudio help you <strong>with</strong> your comm<strong>and</strong>s . . . . . . . . . . . . . . . . . . . . . . . . 54<br />

3.7 Storing many numbers as a vector . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57<br />

3.8 Storing text data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60<br />

3.9 Storing “true or false” data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61<br />

3.10 Indexing vectors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66<br />

3.11 Quitting R . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69<br />

3.12 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70<br />

4 Additional R concepts 73<br />

4.1 Using comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73<br />

4.2 Installing <strong>and</strong> loading packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74<br />

4.3 Managing the workspace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80<br />

4.4 Navigating the file system . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83<br />

4.5 Loading <strong>and</strong> saving data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87<br />

4.6 Useful things to know about variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93<br />

4.7 Factors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97<br />

4.8 Data frames . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100<br />

v

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

Saved successfully!

Ooh no, something went wrong!