Statistical Inference: a Gentle Introduction for Linguists and similar [PDF]

R Basics: installation, data manipulation, input/output (h). 2. Corpus frequency data & statistical inference (h). 3

8 downloads 5 Views 1MB Size

Recommend Stories


Introduction to Statistical Inference
Ask yourself: When was the last time I did something nice for others? Next

Statistical Inference for Networks
You often feel tired, not because you've done too much, but because you've done too little of what sparks

A gentle introduction to NUMERICA
Be grateful for whoever comes, because each has been sent as a guide from beyond. Rumi

Statistical Inference
Courage doesn't always roar. Sometimes courage is the quiet voice at the end of the day saying, "I will

Statistical Inference
Almost everything will work again if you unplug it for a few minutes, including you. Anne Lamott

An introduction to statistical inference—3
You miss 100% of the shots you don’t take. Wayne Gretzky

Gentle Introduction to GPUs
If you want to become full, let yourself be empty. Lao Tzu

Noise Reduction and Statistical Inference
Your task is not to seek for love, but merely to seek and find all the barriers within yourself that

statistical models and causal inference
Knock, And He'll open the door. Vanish, And He'll make you shine like the sun. Fall, And He'll raise

Statistical inference and resampling statistics
I tried to make sense of the Four Books, until love arrived, and it all became a single syllable. Yunus

Idea Transcript


Statistical Inference: a Gentle Introduction for Linguists and similar creatures (SIGIL) With practical examples in GNU R

Designed by Marco Baroni1 and Stefan Evert2 1 Center

for Mind/Brain Sciences (CIMeC) University of Trento, Italy

2 Corpus Linguistics Group Friedrich-Alexander-Universität Erlangen-Nürnberg, Germany

http://SIGIL.r-forge.r-project.org/ Copyright © 2007–2015 Baroni & Evert

SIGIL (Baroni & Evert)

1. Introduction

sigil.r-forge.r-project.org

1 / 47

Outline

Outline

General Introduction Statistical inference and GNU R About this course

Getting Started With R Installation tips Basic functionalities External files and ) quit(save="no")

# or use GUI menus

# NB: at least some interfaces support history recall, TAB completion, etc. SIGIL (Baroni & Evert)

1. Introduction

sigil.r-forge.r-project.org

26 / 47

Getting Started With R

Basic functionalities

Vectorial math > a a * 2

# operators are applied to each element of a vector

[1] 2 4 6

> log(a)

# also works for most standard functions

[1] 0.0000000 0.6931472 1.0986123

> sum(a)

# basic vector operations: sum, length, product, . . .

[1] 6

> length(a) [1] 3

> sum(a)/length(a) [1] 2 SIGIL (Baroni & Evert)

1. Introduction

sigil.r-forge.r-project.org

27 / 47

Getting Started With R

Basic functionalities

Initializing vectors > a a

# integer sequence

> a a a a length(a) > summary(a) Min. 1st Qu.

# statistical summary of numeric vector Median

Mean 3rd Qu.

Max.

0.02717 0.51770 1.05200 1.74300 2.32600 9.11100

> mean(a) > median(a) # standard deviation is not included in summary

> sd(a) > quantile(a) 0%

25%

50%

75%

100%

0.0272 0.5177 1.0518 2.3261 9.1107 SIGIL (Baroni & Evert)

1. Introduction

sigil.r-forge.r-project.org

29 / 47

Getting Started With R

Basic functionalities

Basic plotting > a plot(a)

# don’t forget the parentheses!

> x y plot(x, y)

# most often: plot x against y

> > > > >

plot(x, a) plot(x, a, log="y") plot(x, a, log="x") plot(x, a, log="xy") plot(log(x), log(a))

# various logarithmic plots

> hist(rnorm(100)) # histogram and density estimation > hist(rnorm(1000)) > plot(density(rnorm(100000))) SIGIL (Baroni & Evert)

1. Introduction

sigil.r-forge.r-project.org

30 / 47

Getting Started With R

Basic functionalities

(Slightly less) basic plotting > a hist(a) > hist(a, probability=TRUE) > lines(density(a)) > hist(a, probability=TRUE) > lines(density(a), col="red", lwd=3) > hist(a, probability=TRUE, main="Some Distribution", xlab="value", ylab="probability") # better to type command on a single line! > lines(density(a), col="red", lwd=3)

SIGIL (Baroni & Evert)

1. Introduction

sigil.r-forge.r-project.org

31 / 47

Getting Started With R

Basic functionalities

Help! > help("hist") > ?hist

# R has excellent online documentation # short, convenient form of the help command

> help.search("histogram") > ?help.search > help.start()

# searchable HTML documentation

# or use GUI menus to access & search documentation

SIGIL (Baroni & Evert)

1. Introduction

sigil.r-forge.r-project.org

32 / 47

Getting Started With R

Basic functionalities

Your first R script I I

Simply type R commands into a text file & save it Use built-in GUI functionality or external text editor I I

I

Microsoft Word is not a text editor! nor is Apple’s TextEdit application . . .

Execute R script from GUI editor or by typing > source("my_script.R") # more about files later > source(file.choose()) # select with file dialog box

I

Many GUI editors can execute scripts line by line I

I

check your editor’s documentation for keyboard shortcuts

Just typing an expression will not automatically print the result in a script: use print(sd(a)) instead of sd(a)

SIGIL (Baroni & Evert)

1. Introduction

sigil.r-forge.r-project.org

33 / 47

Getting Started With R

External files and ) # correlation with token count

> plot(brown$to, brown$towl) > cor.test(brown$to, brown$towl)

SIGIL (Baroni & Evert)

1. Introduction

sigil.r-forge.r-project.org

47 / 47

Smile Life

When life gives you a hundred reasons to cry, show life that you have a thousand reasons to smile

Get in touch

© Copyright 2015 - 2024 PDFFOX.COM - All rights reserved.