R STATISTICAL COMPUTING

Size: px
Start display at page:

Download "R STATISTICAL COMPUTING"

Transcription

1 R STATISTICAL COMPUTING some R Examples Dennis Friday 2 nd and Saturday 3 rd May, 14.

2 Topics covered Vector and Matrix operation. File Operations. Evaluation of Probability Density Functions. Testing of Hypothesis, i.e. t, z, F, Chi-square. Linear Regression.

3 Vectors I A numeric vector is a list of numbers. The three common functions that are used to create vectors in various situations are:- c(), seq() and rep(). The function c() The letter c means concatenate, i.e. to join together. > c(0, 270, 250, 300, 210) # Creating a numeric vector > Saturday.sales < c(0, 300, 3) > Sunday.sales < c(1, 230, 0)# Saving a vector in a variable. > weekend.sales < c(saturday.sales, Sunday.sales)# Combining two vectors. > cities < c( Kerala, Delhi, Chennai ) # Creating a vector of characters.

4 Vectors II The functions cbind(), rbind() and seq() > rows.sales < cbind(saturday.sales, Sunday.sales) # Binds Rows > columns.sales < rbind(saturday.sales, Sunday.sales) # Binds Columns > colnames(column.sales) < cities # Adds titles into an array of vectors. The abbreviation seq means sequence, i.e. it is used for equidistant series of numbers. > seq(4, 9) # Creates a sequence of numbers from 4 to 9 at interval of 1. # creates a sequence of numbers from 3 to 10 at interval of 2. > seq(3, 10)

5 Vectors III The function rep() The abbreviation rep means replicate, i.e. it is used to generate repeated values.it is used in two variants, depending on whether the second argument is a vector or a single number, for example; to repeat a series of numbers; > x = c(4, 5) > rep(x, 3) # This will repeat x three times. Consider the following r-code; > rep(1 : 2, c(10, 15)) # This means repeat 1 10 times and 2 15 times.

6 Matrices I Example A matrix is a two-dimensional array of numbers. > x < 1 : 12 > dim(x) < c(3, 4); x Alternatively, the function matrix() can be used as follows; > matrix(1 : 12, nrow = 3, byrow = T ) The dim assignment function sets or changes the dimension attribute of x, causing R to treat the vector of 12 numbers as a 3 x 4 matrix. Useful functions that operate on matrices include rownames(), colnames(), and the transposition function t().

7 Matrices II Example > x < matrix(1 : 12, nrow = 3, byrow = T ) > rownames(x) < LETTERS[1 : 3]; x > colnames(x) < letters[1 : 3]; x # Naming rows and columns. The character vector LETTERS is a built-in variable that contains the capital letters A Z. Similar useful vectors are letters, month.name and month.abb, which refers to lowercase letters a z, month names, and abbreviated month names respectively. Finding the Transpose and the Inverse of a matrix. > y < t(x); y # Gives the transpose of a matrix. > z < solve(x); z # Gives the inverse of a matrix.

8 Matrices III Create two matrices, say, A and B. Matrix addition, subtraction and multiplication > C = c(rep(0, 3), seq(1, 6, 1), rep(seq(1, 6, 1), 2)) > A = matrix(sample(c, 12), nrow = 3, byrow = T ); A > B = matrix(sample(c, 12), nrow = 3, byrow = T ); B > D = A + B; D # Adds the matrix. > E = A B; E # Subtracts matrix B form matrix A. > F = A B; F # Multiplies matrix A form matrix B element-wise. > G = A% %t(b); G # Computes matrix multiplication.

9 File operations Reading Data. The two common functions used in reading data are; scan() and read.table(), i.e. > Sales = scan(file = filepath ) > SALES = read.table(file = filepath, header = FALSE) To merge two or more files according to the column names or row names, we use the function merge(); > AB = merge(x, y, z) # merging files. To write an output into a file, use the function write(), i.e. > output.file = write(x, file = file path to save the data, ncolumns = 1, append = FALSE)

10 Some probability distributions I Normal distribution Full list and options are found in > help(normal) command. dnorm > x < seq(,, by =.1) > y < dnorm(x) > plot(x, y) pnorm > x < seq(,, by =.1) > y < pnorm(x, mean = 3, sd = 4) > plot(x, y)

11 Some probability distributions II qnorm The next function we look at is qnorm which is the inverse of pnorm. The idea behind qnorm is that you give it a probability, and it returns the number whose cumulative distribution matches the probability. > x < seq(0, 1, by =.05) > y < qnorm(x) > plot(x, y) > y < qnorm(x, mean = 3, sd = 2) > plot(x, y) rnorm > y < rnorm(0, mean = 2) > hist(y)

12 t-distribution I

13 t-distribution II dt, Help at > help(tdist) > x < seq(,, by =.5) > y < dt(x, df = 10) pt > x = c( 3, 4, 2, 1) > pt((mean(x) 2)/sd(x), df = ) qt > v < c(0.005,.025,.05) > qt(v, df = 253) rt > rt(3, df = 10)

14 Chi-square I

15 Chi-square II dchisq, Help at > help(chisquare) > x < seq(,, by =.5) > y < dchisq(x, df = 10) pchisq > x = c(2, 4, 5, 6) > pchisq(x, df = ) qchisq > v < c(0.005,.025,.05); qchisq(v, df = 253) rchisq > rchisq(3, df = )

16 Testing of Hypotheses I In the one-sample t-test, we are comparing a sample mean to a known or hypothesized population mean. The null hypothesis is that the expected mean difference between the sample mean and the population mean is zero, or in other words, that the expected value of the sample mean is equal to the population mean. t-test example 1. > rnorm1 = rnorm(50, 500, 100); rnorm1 # Generate random numbers from a normal distribution with µ = 500, σ = 100. > summary(rnorm1) # Gives the descriptive summary. The mean of is higher than µ = 500, but is it significantly higher? To test this hypotheses, we use the function t.test(). > t.test(rnorm1, mu = 500)

17 Testing of Hypotheses II Load the in-built library datasets. t-test example 2. Quiz > library(datasets) > head(mtcars) Assuming that the data in mtcars follows the normal distribution, find the 95% confidence interval estimate of the difference between the mean gas mileage of manual and automatic transmissions.

18 Testing of Hypotheses III Solution Answer > L = mtcars$am == 0 > mpg.auto = mtcars[l, ]$mpg; mpg.auto # automatic transmission mileage. > mpg.manual = mtcars[!l, ]$mpg; mpg.manual # manual transmission mileage. > t.test(mpg.auto, mpg.manual) In mtcars, the mean mileage of automatic transmission is mpg and the manual transmission is mpg. The 95% confidence interval of the difference in mean gas mileage is between 3.97 and mpg.

19 Testing of Hypotheses IV Chi-squared test Consider the following example; > female = c(18, 102) > male = c(10, 110) > migraine = cbind(female, male); migraine > chisq.test(migraine) From the results we find that;- We determine that the chi-square test fails to reject the null hypothesis that gender and migraine susceptibility are independent. If the ratio of female to male migraine sufferers is indeed 18:6, then our result is not what we had hoped for. We may have an unusual sample or we may simply need a larger sample to obtain statistical significance.

20 Regression I Simple Linear Regression An example of grade point averages (GPAs) of students along with the number of hours each student studies per week. We then use the lm() function to find the slope and intercept terms. Hours GPA > results < lm(gpa Hours); summary(results) The correct interpretation of the regression equation is that a student who did not study would have an estimated GPA of , and that for every 1-hour increase in study time, the estimated GPA would increase by points.

21 Regression II Example Consider the dataframe on cars, mtcars in library(datasets). Test if mpg -miles per gallon is affected by disp -displacement and hp -horsepower. > myvariables = c( mpg, disp, hp ) > mycars = mtcars[myvariables] > mymodel = lm(mpg disp + hp, data = mycars) > summary(mymodel) From the summary of the model, we can clearly see that the independent variables; disp -Engine displacement & hp -Horsepower negatively affects the dependent variable, i.e. for an increase in either displacement or horsepower, it will result in a decrease in the miles per gallon. Another important graphical way to assess relationship between

Hypothesis Testing. Gordon Erlebacher. Thursday, February 14, 13

Hypothesis Testing. Gordon Erlebacher. Thursday, February 14, 13 Hypothesis Testing Gordon Erlebacher What we have done R basics: - vectors, data frames, - factors, extraction, - logical expressions, scripts, read and writing data files - histograms, plotting Functions

More information

Motor Trend Car Road Analysis

Motor Trend Car Road Analysis Motor Trend Car Road Analysis Zakia Sultana February 28, 2016 Executive Summary You work for Motor Trend, a magazine about the automobile industry. Looking at a data set of a collection of cars, they are

More information

Introduction to R, Part I

Introduction to R, Part I Introduction to R, Part I Basic math, variables, and variable types Tim Frasier Copyright Tim Frasier This work is licensed under the Creative Commons Attribution 4.0 International license. Click here

More information

Outline. Unit 3: Inferential Statistics for Continuous Data. Outline. Inferential statistics for continuous data. Inferential statistics Preliminaries

Outline. Unit 3: Inferential Statistics for Continuous Data. Outline. Inferential statistics for continuous data. Inferential statistics Preliminaries Unit 3: Inferential Statistics for Continuous Data Statistics for Linguists with R A SIGIL Course Designed by Marco Baroni 1 and Stefan Evert 1 Center for Mind/Brain Sciences (CIMeC) University of Trento,

More information

HYPOTHESIS TESTING: THE CHI-SQUARE STATISTIC

HYPOTHESIS TESTING: THE CHI-SQUARE STATISTIC 1 HYPOTHESIS TESTING: THE CHI-SQUARE STATISTIC 7 steps of Hypothesis Testing 1. State the hypotheses 2. Identify level of significant 3. Identify the critical values 4. Calculate test statistics 5. Compare

More information

Inferences on Linear Combinations of Coefficients

Inferences on Linear Combinations of Coefficients Inferences on Linear Combinations of Coefficients Note on required packages: The following code required the package multcomp to test hypotheses on linear combinations of regression coefficients. If you

More information

Holiday Assignment PS 531

Holiday Assignment PS 531 Holiday Assignment PS 531 Prof: Jake Bowers TA: Paul Testa January 27, 2014 Overview Below is a brief assignment for you to complete over the break. It should serve as refresher, covering some of the basic

More information

Two sample Hypothesis tests in R.

Two sample Hypothesis tests in R. Example. (Dependent samples) Two sample Hypothesis tests in R. A Calculus professor gives their students a 10 question algebra pretest on the first day of class, and a similar test towards the end of the

More information

Simple linear regression: estimation, diagnostics, prediction

Simple linear regression: estimation, diagnostics, prediction UPPSALA UNIVERSITY Department of Mathematics Mathematical statistics Regression and Analysis of Variance Autumn 2015 COMPUTER SESSION 1: Regression In the first computer exercise we will study the following

More information

Statistical Analysis for QBIC Genetics Adapted by Ellen G. Dow 2017

Statistical Analysis for QBIC Genetics Adapted by Ellen G. Dow 2017 Statistical Analysis for QBIC Genetics Adapted by Ellen G. Dow 2017 I. χ 2 or chi-square test Objectives: Compare how close an experimentally derived value agrees with an expected value. One method to

More information

Bivariate data analysis

Bivariate data analysis Bivariate data analysis Categorical data - creating data set Upload the following data set to R Commander sex female male male male male female female male female female eye black black blue green green

More information

WEB-DISTANCE ST 370 Quiz 1 FALL 2007 ver. B NAME ID # I will neither give nor receive help from other students during this quiz Sign

WEB-DISTANCE ST 370 Quiz 1 FALL 2007 ver. B NAME ID # I will neither give nor receive help from other students during this quiz Sign WEB-DISTANCE ST 370 Quiz 1 FALL 2007 ver. B NAME ID # I will neither give nor receive help from other students during this quiz Sign PROBLEM 1: If the number 3 is added to every member of a sample of observations

More information

Statistical Programming with R

Statistical Programming with R Statistical Programming with R Lecture 3: Matrices Bisher M. Iqelan biqelan@iugaza.edu.ps Department of Mathematics, Faculty of Science, The Islamic University of Gaza 2017-2018, Semester 1 Matrices A

More information

SMAM 314 Exam 3 Name. 1. Mark the following statements true or false. (6 points 2 each)

SMAM 314 Exam 3 Name. 1. Mark the following statements true or false. (6 points 2 each) SMAM 314 Exam 3 Name 1. Mark the following statements true or false. (6 points 2 each) F A. A t test on independent samples is appropriate when the results of an algebra test are being compared for the

More information

1 Probability Distributions

1 Probability Distributions 1 Probability Distributions A probability distribution describes how the values of a random variable are distributed. For example, the collection of all possible outcomes of a sequence of coin tossing

More information

Generating OLS Results Manually via R

Generating OLS Results Manually via R Generating OLS Results Manually via R Sujan Bandyopadhyay Statistical softwares and packages have made it extremely easy for people to run regression analyses. Packages like lm in R or the reg command

More information

Exercise I.1 I.2 I.3 I.4 II.1 II.2 III.1 III.2 III.3 IV.1 Question (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Answer

Exercise I.1 I.2 I.3 I.4 II.1 II.2 III.1 III.2 III.3 IV.1 Question (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Answer Solutions to Exam in 02402 December 2012 Exercise I.1 I.2 I.3 I.4 II.1 II.2 III.1 III.2 III.3 IV.1 Question (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Answer 3 1 5 2 5 2 3 5 1 3 Exercise IV.2 IV.3 IV.4 V.1

More information

CHAPTER 10. Regression and Correlation

CHAPTER 10. Regression and Correlation CHAPTER 10 Regression and Correlation In this Chapter we assess the strength of the linear relationship between two continuous variables. If a significant linear relationship is found, the next step would

More information

Sampling distribution of t. 2. Sampling distribution of t. 3. Example: Gas mileage investigation. II. Inferential Statistics (8) t =

Sampling distribution of t. 2. Sampling distribution of t. 3. Example: Gas mileage investigation. II. Inferential Statistics (8) t = 2. The distribution of t values that would be obtained if a value of t were calculated for each sample mean for all possible random of a given size from a population _ t ratio: (X - µ hyp ) t s x The result

More information

Statistical Computing Session 4: Random Simulation

Statistical Computing Session 4: Random Simulation Statistical Computing Session 4: Random Simulation Paul Eilers & Dimitris Rizopoulos Department of Biostatistics, Erasmus University Medical Center p.eilers@erasmusmc.nl Masters Track Statistical Sciences,

More information

WEB-DISTANCE ST 370 Quiz 1 Autumn 2007 ver. A NAME ID # I will neither give nor receive help from other students during this quiz Sign

WEB-DISTANCE ST 370 Quiz 1 Autumn 2007 ver. A NAME ID # I will neither give nor receive help from other students during this quiz Sign WEB-DISTANCE ST 370 Quiz 1 Autumn 2007 ver. A NAME ID # I will neither give nor receive help from other students during this quiz Sign PROBLEM 1: If the number 3 is added to every member of a sample of

More information

Linear Regression. In this lecture we will study a particular type of regression model: the linear regression model

Linear Regression. In this lecture we will study a particular type of regression model: the linear regression model 1 Linear Regression 2 Linear Regression In this lecture we will study a particular type of regression model: the linear regression model We will first consider the case of the model with one predictor

More information

Marketing Research Session 10 Hypothesis Testing with Simple Random samples (Chapter 12)

Marketing Research Session 10 Hypothesis Testing with Simple Random samples (Chapter 12) Marketing Research Session 10 Hypothesis Testing with Simple Random samples (Chapter 12) Remember: Z.05 = 1.645, Z.01 = 2.33 We will only cover one-sided hypothesis testing (cases 12.3, 12.4.2, 12.5.2,

More information

Regression_Model_Project Md Ahmed June 13th, 2017

Regression_Model_Project Md Ahmed June 13th, 2017 Regression_Model_Project Md Ahmed June 13th, 2017 Executive Summary Motor Trend is a magazine about the automobile industry. It is interested in exploring the relationship between a set of variables and

More information

Matematisk statistik allmän kurs, MASA01:A, HT-15 Laborationer

Matematisk statistik allmän kurs, MASA01:A, HT-15 Laborationer Lunds universitet Matematikcentrum Matematisk statistik Matematisk statistik allmän kurs, MASA01:A, HT-15 Laborationer General information on labs During the rst half of the course MASA01 we will have

More information

Logistic Regression in R. by Kerry Machemer 12/04/2015

Logistic Regression in R. by Kerry Machemer 12/04/2015 Logistic Regression in R by Kerry Machemer 12/04/2015 Linear Regression {y i, x i1,, x ip } Linear Regression y i = dependent variable & x i = independent variable(s) y i = α + β 1 x i1 + + β p x ip +

More information

While you wait: Enter the following in your calculator. Find the mean and sample variation of each group. Bluman, Chapter 12 1

While you wait: Enter the following in your calculator. Find the mean and sample variation of each group. Bluman, Chapter 12 1 While you wait: Enter the following in your calculator. Find the mean and sample variation of each group. Bluman, Chapter 12 1 Chapter 12 Analysis of Variance McGraw-Hill, Bluman, 7th ed., Chapter 12 2

More information

Can you tell the relationship between students SAT scores and their college grades?

Can you tell the relationship between students SAT scores and their college grades? Correlation One Challenge Can you tell the relationship between students SAT scores and their college grades? A: The higher SAT scores are, the better GPA may be. B: The higher SAT scores are, the lower

More information

Review of Multiple Regression

Review of Multiple Regression Ronald H. Heck 1 Let s begin with a little review of multiple regression this week. Linear models [e.g., correlation, t-tests, analysis of variance (ANOVA), multiple regression, path analysis, multivariate

More information

CIVL /8904 T R A F F I C F L O W T H E O R Y L E C T U R E - 8

CIVL /8904 T R A F F I C F L O W T H E O R Y L E C T U R E - 8 CIVL - 7904/8904 T R A F F I C F L O W T H E O R Y L E C T U R E - 8 Chi-square Test How to determine the interval from a continuous distribution I = Range 1 + 3.322(logN) I-> Range of the class interval

More information

Inference for Single Proportions and Means T.Scofield

Inference for Single Proportions and Means T.Scofield Inference for Single Proportions and Means TScofield Confidence Intervals for Single Proportions and Means A CI gives upper and lower bounds between which we hope to capture the (fixed) population parameter

More information

GROUPED DATA E.G. FOR SAMPLE OF RAW DATA (E.G. 4, 12, 7, 5, MEAN G x / n STANDARD DEVIATION MEDIAN AND QUARTILES STANDARD DEVIATION

GROUPED DATA E.G. FOR SAMPLE OF RAW DATA (E.G. 4, 12, 7, 5, MEAN G x / n STANDARD DEVIATION MEDIAN AND QUARTILES STANDARD DEVIATION FOR SAMPLE OF RAW DATA (E.G. 4, 1, 7, 5, 11, 6, 9, 7, 11, 5, 4, 7) BE ABLE TO COMPUTE MEAN G / STANDARD DEVIATION MEDIAN AND QUARTILES Σ ( Σ) / 1 GROUPED DATA E.G. AGE FREQ. 0-9 53 10-19 4...... 80-89

More information

Analytics 512: Homework # 2 Tim Ahn February 9, 2016

Analytics 512: Homework # 2 Tim Ahn February 9, 2016 Analytics 512: Homework # 2 Tim Ahn February 9, 2016 Chapter 3 Problem 1 (# 3) Suppose we have a data set with five predictors, X 1 = GP A, X 2 = IQ, X 3 = Gender (1 for Female and 0 for Male), X 4 = Interaction

More information

Lecture 6: Linear Regression

Lecture 6: Linear Regression Lecture 6: Linear Regression Reading: Sections 3.1-3 STATS 202: Data mining and analysis Jonathan Taylor, 10/5 Slide credits: Sergio Bacallado 1 / 30 Simple linear regression Model: y i = β 0 + β 1 x i

More information

Agricultural and Applied Economics 637 Applied Econometrics II

Agricultural and Applied Economics 637 Applied Econometrics II Agricultural and Applied Economics 637 Applied Econometrics II Assignment 1 Review of GLS Heteroskedasity and Autocorrelation (Due: Feb. 4, 2011) In this assignment you are asked to develop relatively

More information

Econometrics. 4) Statistical inference

Econometrics. 4) Statistical inference 30C00200 Econometrics 4) Statistical inference Timo Kuosmanen Professor, Ph.D. http://nomepre.net/index.php/timokuosmanen Today s topics Confidence intervals of parameter estimates Student s t-distribution

More information

Using R in 200D Luke Sonnet

Using R in 200D Luke Sonnet Using R in 200D Luke Sonnet Contents Working with data frames 1 Working with variables........................................... 1 Analyzing data............................................... 3 Random

More information

STAT 328 (Statistical Packages)

STAT 328 (Statistical Packages) Department of Statistics and Operations Research College of Science King Saud University Exercises STAT 328 (Statistical Packages) nashmiah r.alshammari ^-^ Excel and Minitab - 1 - Write the commands of

More information

CHAPTER 10 ONE-WAY ANALYSIS OF VARIANCE. It would be very unusual for all the research one might conduct to be restricted to

CHAPTER 10 ONE-WAY ANALYSIS OF VARIANCE. It would be very unusual for all the research one might conduct to be restricted to CHAPTER 10 ONE-WAY ANALYSIS OF VARIANCE It would be very unusual for all the research one might conduct to be restricted to comparisons of only two samples. Respondents and various groups are seldom divided

More information

Answer Key: Problem Set 6

Answer Key: Problem Set 6 : Problem Set 6 1. Consider a linear model to explain monthly beer consumption: beer = + inc + price + educ + female + u 0 1 3 4 E ( u inc, price, educ, female ) = 0 ( u inc price educ female) σ inc var,,,

More information

Probability theory and inference statistics! Dr. Paola Grosso! SNE research group!! (preferred!)!!

Probability theory and inference statistics! Dr. Paola Grosso! SNE research group!!  (preferred!)!! Probability theory and inference statistics Dr. Paola Grosso SNE research group p.grosso@uva.nl paola.grosso@os3.nl (preferred) Roadmap Lecture 1: Monday Sep. 22nd Collecting data Presenting data Descriptive

More information

Introduction to RStudio

Introduction to RStudio Introduction to RStudio Carl Tony Fakhry Jie Chen April 4, 2015 Introduction R is a powerful language and environment for statistical computing and graphics. R is freeware and there is lot of help available

More information

R Functions for Probability Distributions

R Functions for Probability Distributions R Functions for Probability Distributions Young W. Lim 2018-03-22 Thr Young W. Lim R Functions for Probability Distributions 2018-03-22 Thr 1 / 15 Outline 1 R Functions for Probability Distributions Based

More information

Department of Economics. Business Statistics. Chapter 12 Chi-square test of independence & Analysis of Variance ECON 509. Dr.

Department of Economics. Business Statistics. Chapter 12 Chi-square test of independence & Analysis of Variance ECON 509. Dr. Department of Economics Business Statistics Chapter 1 Chi-square test of independence & Analysis of Variance ECON 509 Dr. Mohammad Zainal Chapter Goals After completing this chapter, you should be able

More information

(ii) Scan your answer sheets INTO ONE FILE only, and submit it in the drop-box.

(ii) Scan your answer sheets INTO ONE FILE only, and submit it in the drop-box. FINAL EXAM ** Two different ways to submit your answer sheet (i) Use MS-Word and place it in a drop-box. (ii) Scan your answer sheets INTO ONE FILE only, and submit it in the drop-box. Deadline: December

More information

Chapter 3 - Linear Regression

Chapter 3 - Linear Regression Chapter 3 - Linear Regression Lab Solution 1 Problem 9 First we will read the Auto" data. Note that most datasets referred to in the text are in the R package the authors developed. So we just need to

More information

Contents 1 Admin 2 General extensions 3 FWL theorem 4 Omitted variable bias 5 The R family Admin 1.1 What you will need Packages Data 1.

Contents 1 Admin 2 General extensions 3 FWL theorem 4 Omitted variable bias 5 The R family Admin 1.1 What you will need Packages Data 1. 2 2 dplyr lfe readr MASS auto.csv plot() plot() ggplot2 plot() # Start the.jpeg driver jpeg("your_plot.jpeg") # Make the plot plot(x = 1:10, y = 1:10) # Turn off the driver dev.off() # Start the.pdf driver

More information

5. Let W follow a normal distribution with mean of μ and the variance of 1. Then, the pdf of W is

5. Let W follow a normal distribution with mean of μ and the variance of 1. Then, the pdf of W is Practice Final Exam Last Name:, First Name:. Please write LEGIBLY. Answer all questions on this exam in the space provided (you may use the back of any page if you need more space). Show all work but do

More information

Business Analytics and Data Mining Modeling Using R Prof. Gaurav Dixit Department of Management Studies Indian Institute of Technology, Roorkee

Business Analytics and Data Mining Modeling Using R Prof. Gaurav Dixit Department of Management Studies Indian Institute of Technology, Roorkee Business Analytics and Data Mining Modeling Using R Prof. Gaurav Dixit Department of Management Studies Indian Institute of Technology, Roorkee Lecture - 04 Basic Statistics Part-1 (Refer Slide Time: 00:33)

More information

The Chi-Square and F Distributions

The Chi-Square and F Distributions Department of Psychology and Human Development Vanderbilt University Introductory Distribution Theory 1 Introduction 2 Some Basic Properties Basic Chi-Square Distribution Calculations in R Convergence

More information

Lecture 6: Linear Regression (continued)

Lecture 6: Linear Regression (continued) Lecture 6: Linear Regression (continued) Reading: Sections 3.1-3.3 STATS 202: Data mining and analysis October 6, 2017 1 / 23 Multiple linear regression Y = β 0 + β 1 X 1 + + β p X p + ε Y ε N (0, σ) i.i.d.

More information

Stats + Homework 2 Review. CS100 TAs

Stats + Homework 2 Review. CS100 TAs Stats + Homework 2 Review CS100 TAs What s on Homework 2? Confidence/Confidence intervals (mean, proportion, difference of each [all Z based]) CLT, LOLN Some hypothesis testing (p-values) Statistical significance

More information

Analysis of Variance. Contents. 1 Analysis of Variance. 1.1 Review. Anthony Tanbakuchi Department of Mathematics Pima Community College

Analysis of Variance. Contents. 1 Analysis of Variance. 1.1 Review. Anthony Tanbakuchi Department of Mathematics Pima Community College Introductory Statistics Lectures Analysis of Variance 1-Way ANOVA: Many sample test of means Department of Mathematics Pima Community College Redistribution of this material is prohibited without written

More information

Introduction to Statistical Data Analysis Lecture 7: The Chi-Square Distribution

Introduction to Statistical Data Analysis Lecture 7: The Chi-Square Distribution Introduction to Statistical Data Analysis Lecture 7: The Chi-Square Distribution James V. Lambers Department of Mathematics The University of Southern Mississippi James V. Lambers Statistical Data Analysis

More information

Chapter 8 Student Lecture Notes 8-1. Department of Economics. Business Statistics. Chapter 12 Chi-square test of independence & Analysis of Variance

Chapter 8 Student Lecture Notes 8-1. Department of Economics. Business Statistics. Chapter 12 Chi-square test of independence & Analysis of Variance Chapter 8 Student Lecture Notes 8-1 Department of Economics Business Statistics Chapter 1 Chi-square test of independence & Analysis of Variance ECON 509 Dr. Mohammad Zainal Chapter Goals After completing

More information

Topic 15: Simple Hypotheses

Topic 15: Simple Hypotheses Topic 15: November 10, 2009 In the simplest set-up for a statistical hypothesis, we consider two values θ 0, θ 1 in the parameter space. We write the test as H 0 : θ = θ 0 versus H 1 : θ = θ 1. H 0 is

More information

Statistics 203 Introduction to Regression Models and ANOVA Practice Exam

Statistics 203 Introduction to Regression Models and ANOVA Practice Exam Statistics 203 Introduction to Regression Models and ANOVA Practice Exam Prof. J. Taylor You may use your 4 single-sided pages of notes This exam is 7 pages long. There are 4 questions, first 3 worth 10

More information

Standard Normal Calculations

Standard Normal Calculations Standard Normal Calculations Section 4.3 Cathy Poliak, Ph.D. cathy@math.uh.edu Office in Fleming 11c Department of Mathematics University of Houston Lecture 10-2311 Cathy Poliak, Ph.D. cathy@math.uh.edu

More information

Tests about a population mean

Tests about a population mean October 2 nd, 2017 Overview Week 1 Week 2 Week 4 Week 7 Week 10 Week 12 Chapter 1: Descriptive statistics Chapter 6: Statistics and Sampling Distributions Chapter 7: Point Estimation Chapter 8: Confidence

More information

Confidence Intervals for Comparing Means

Confidence Intervals for Comparing Means Comparison 2 Solutions COR1-GB.1305 Statistics and Data Analysis Confidence Intervals for Comparing Means 1. Recall the class survey. Seventeen female and thirty male students filled out the survey, reporting

More information

Linear Models II. Chapter Key ideas

Linear Models II. Chapter Key ideas Chapter 6 Linear Models II 6.1 Key ideas Consider a situation in which we take measurements of some attribute Y on two distinct group. We want to know whether the mean of group 1, µ 1, is different from

More information

" M A #M B. Standard deviation of the population (Greek lowercase letter sigma) σ 2

 M A #M B. Standard deviation of the population (Greek lowercase letter sigma) σ 2 Notation and Equations for Final Exam Symbol Definition X The variable we measure in a scientific study n The size of the sample N The size of the population M The mean of the sample µ The mean of the

More information

Math 628 In-class Exam 2 04/03/2013

Math 628 In-class Exam 2 04/03/2013 Math 628 In-class Exam 2 04/03/2013 Name: KU ID: Note: Show ALL work clearly in the space provided. In order to receive full credit on a problem, solution methods must be complete, logical and understandable.

More information

Statistical inference (estimation, hypothesis tests, confidence intervals) Oct 2018

Statistical inference (estimation, hypothesis tests, confidence intervals) Oct 2018 Statistical inference (estimation, hypothesis tests, confidence intervals) Oct 2018 Sampling A trait is measured on each member of a population. f(y) = propn of individuals in the popn with measurement

More information

Week 14 Comparing k(> 2) Populations

Week 14 Comparing k(> 2) Populations Week 14 Comparing k(> 2) Populations Week 14 Objectives Methods associated with testing for the equality of k(> 2) means or proportions are presented. Post-testing concepts and analysis are introduced.

More information

MAT3378 (Winter 2016)

MAT3378 (Winter 2016) MAT3378 (Winter 2016) Assignment 2 - SOLUTIONS Total number of points for Assignment 2: 12 The following questions will be marked: Q1, Q2, Q4 Q1. (4 points) Assume that Z 1,..., Z n are i.i.d. normal random

More information

Simple Linear Regression: One Qualitative IV

Simple Linear Regression: One Qualitative IV Simple Linear Regression: One Qualitative IV 1. Purpose As noted before regression is used both to explain and predict variation in DVs, and adding to the equation categorical variables extends regression

More information

You can use numeric categorical predictors. A categorical predictor is one that takes values from a fixed set of possibilities.

You can use numeric categorical predictors. A categorical predictor is one that takes values from a fixed set of possibilities. CONTENTS Linear Regression Prepare Data To begin fitting a regression, put your data into a form that fitting functions expect. All regression techniques begin with input data in an array X and response

More information

Class 24. Daniel B. Rowe, Ph.D. Department of Mathematics, Statistics, and Computer Science. Marquette University MATH 1700

Class 24. Daniel B. Rowe, Ph.D. Department of Mathematics, Statistics, and Computer Science. Marquette University MATH 1700 Class 4 Daniel B. Rowe, Ph.D. Department of Mathematics, Statistics, and Computer Science Copyright 013 by D.B. Rowe 1 Agenda: Recap Chapter 9. and 9.3 Lecture Chapter 10.1-10.3 Review Exam 6 Problem Solving

More information

Statistics 301: Probability and Statistics 1-sample Hypothesis Tests Module

Statistics 301: Probability and Statistics 1-sample Hypothesis Tests Module Statistics 301: Probability and Statistics 1-sample Hypothesis Tests Module 9 2018 Student s t graphs For the heck of it: x

More information

Canonical Correlations

Canonical Correlations Canonical Correlations Summary The Canonical Correlations procedure is designed to help identify associations between two sets of variables. It does so by finding linear combinations of the variables in

More information

Package MicroMacroMultilevel

Package MicroMacroMultilevel Type Package Package MicroMacroMultilevel July 1, 2017 Description Most multilevel methodologies can only model macro-micro multilevel situations in an unbiased way, wherein group-level predictors (e.g.,

More information

Chapter 16. Simple Linear Regression and Correlation

Chapter 16. Simple Linear Regression and Correlation Chapter 16 Simple Linear Regression and Correlation 16.1 Regression Analysis Our problem objective is to analyze the relationship between interval variables; regression analysis is the first tool we will

More information

Regression and the 2-Sample t

Regression and the 2-Sample t Regression and the 2-Sample t James H. Steiger Department of Psychology and Human Development Vanderbilt University James H. Steiger (Vanderbilt University) Regression and the 2-Sample t 1 / 44 Regression

More information

Chapter 9. Hypothesis testing. 9.1 Introduction

Chapter 9. Hypothesis testing. 9.1 Introduction Chapter 9 Hypothesis testing 9.1 Introduction Confidence intervals are one of the two most common types of statistical inference. Use them when our goal is to estimate a population parameter. The second

More information

3. Shrink the vector you just created by removing the first element. One could also use the [] operators with a negative index to remove an element.

3. Shrink the vector you just created by removing the first element. One could also use the [] operators with a negative index to remove an element. BMI 713: Computational Statistical for Biomedical Sciences Assignment 1 September 9, 2010 (due Sept 16 for Part 1; Sept 23 for Part 2 and 3) 1 Basic 1. Use the : operator to create the vector (1, 2, 3,

More information

Explore the data. Anja Bråthen Kristoffersen

Explore the data. Anja Bråthen Kristoffersen Explore the data Anja Bråthen Kristoffersen density 0.2 0.4 0.6 0.8 Probability distributions Can be either discrete or continuous (uniform, bernoulli, normal, etc) Defined by a density function, p(x)

More information

This is a multiple choice and short answer practice exam. It does not count towards your grade. You may use the tables in your book.

This is a multiple choice and short answer practice exam. It does not count towards your grade. You may use the tables in your book. NAME (Please Print): HONOR PLEDGE (Please Sign): statistics 101 Practice Final Key This is a multiple choice and short answer practice exam. It does not count towards your grade. You may use the tables

More information

probability George Nicholson and Chris Holmes 29th October 2008

probability George Nicholson and Chris Holmes 29th October 2008 probability George Nicholson and Chris Holmes 29th October 2008 This practical focuses on understanding probabilistic and statistical concepts using simulation and plots in R R. It begins with an introduction

More information

Polynomial Regression

Polynomial Regression Polynomial Regression Summary... 1 Analysis Summary... 3 Plot of Fitted Model... 4 Analysis Options... 6 Conditional Sums of Squares... 7 Lack-of-Fit Test... 7 Observed versus Predicted... 8 Residual Plots...

More information

STAT Chapter 10: Analysis of Variance

STAT Chapter 10: Analysis of Variance STAT 515 -- Chapter 10: Analysis of Variance Designed Experiment A study in which the researcher controls the levels of one or more variables to determine their effect on the variable of interest (called

More information

Inference for Regression Inference about the Regression Model and Using the Regression Line

Inference for Regression Inference about the Regression Model and Using the Regression Line Inference for Regression Inference about the Regression Model and Using the Regression Line PBS Chapter 10.1 and 10.2 2009 W.H. Freeman and Company Objectives (PBS Chapter 10.1 and 10.2) Inference about

More information

Two-Way ANOVA. Chapter 15

Two-Way ANOVA. Chapter 15 Two-Way ANOVA Chapter 15 Interaction Defined An interaction is present when the effects of one IV depend upon a second IV Interaction effect : The effect of each IV across the levels of the other IV When

More information

Package misctools. November 25, 2016

Package misctools. November 25, 2016 Version 0.6-22 Date 2016-11-25 Title Miscellaneous Tools and Utilities Author, Ott Toomet Package misctools November 25, 2016 Maintainer Depends R (>= 2.14.0) Suggests Ecdat

More information

CHI SQUARE ANALYSIS 8/18/2011 HYPOTHESIS TESTS SO FAR PARAMETRIC VS. NON-PARAMETRIC

CHI SQUARE ANALYSIS 8/18/2011 HYPOTHESIS TESTS SO FAR PARAMETRIC VS. NON-PARAMETRIC CHI SQUARE ANALYSIS I N T R O D U C T I O N T O N O N - P A R A M E T R I C A N A L Y S E S HYPOTHESIS TESTS SO FAR We ve discussed One-sample t-test Dependent Sample t-tests Independent Samples t-tests

More information

Lecture 26: Chapter 10, Section 2 Inference for Quantitative Variable Confidence Interval with t

Lecture 26: Chapter 10, Section 2 Inference for Quantitative Variable Confidence Interval with t Lecture 26: Chapter 10, Section 2 Inference for Quantitative Variable Confidence Interval with t t Confidence Interval for Population Mean Comparing z and t Confidence Intervals When neither z nor t Applies

More information

SPSS LAB FILE 1

SPSS LAB FILE  1 SPSS LAB FILE www.mcdtu.wordpress.com 1 www.mcdtu.wordpress.com 2 www.mcdtu.wordpress.com 3 OBJECTIVE 1: Transporation of Data Set to SPSS Editor INPUTS: Files: group1.xlsx, group1.txt PROCEDURE FOLLOWED:

More information

Module 03 Lecture 14 Inferential Statistics ANOVA and TOI

Module 03 Lecture 14 Inferential Statistics ANOVA and TOI Introduction of Data Analytics Prof. Nandan Sudarsanam and Prof. B Ravindran Department of Management Studies and Department of Computer Science and Engineering Indian Institute of Technology, Madras Module

More information

Mathematical Notation Math Introduction to Applied Statistics

Mathematical Notation Math Introduction to Applied Statistics Mathematical Notation Math 113 - Introduction to Applied Statistics Name : Use Word or WordPerfect to recreate the following documents. Each article is worth 10 points and should be emailed to the instructor

More information

Final Exam. Name: Solution:

Final Exam. Name: Solution: Final Exam. Name: Instructions. Answer all questions on the exam. Open books, open notes, but no electronic devices. The first 13 problems are worth 5 points each. The rest are worth 1 point each. HW1.

More information

Gov Univariate Inference II: Interval Estimation and Testing

Gov Univariate Inference II: Interval Estimation and Testing Gov 2000-5. Univariate Inference II: Interval Estimation and Testing Matthew Blackwell October 13, 2015 1 / 68 Large Sample Confidence Intervals Confidence Intervals Example Hypothesis Tests Hypothesis

More information

Composite Hypotheses. Topic Partitioning the Parameter Space The Power Function

Composite Hypotheses. Topic Partitioning the Parameter Space The Power Function Toc 18 Simple hypotheses limit us to a decision between one of two possible states of nature. This limitation does not allow us, under the procedures of hypothesis testing to address the basic question:

More information

Keller: Stats for Mgmt & Econ, 7th Ed July 17, 2006

Keller: Stats for Mgmt & Econ, 7th Ed July 17, 2006 Chapter 17 Simple Linear Regression and Correlation 17.1 Regression Analysis Our problem objective is to analyze the relationship between interval variables; regression analysis is the first tool we will

More information

CBA4 is live in practice mode this week exam mode from Saturday!

CBA4 is live in practice mode this week exam mode from Saturday! Announcements CBA4 is live in practice mode this week exam mode from Saturday! Material covered: Confidence intervals (both cases) 1 sample hypothesis tests (both cases) Hypothesis tests for 2 means as

More information

Lecture 14: Introduction to Poisson Regression

Lecture 14: Introduction to Poisson Regression Lecture 14: Introduction to Poisson Regression Ani Manichaikul amanicha@jhsph.edu 8 May 2007 1 / 52 Overview Modelling counts Contingency tables Poisson regression models 2 / 52 Modelling counts I Why

More information

Modelling counts. Lecture 14: Introduction to Poisson Regression. Overview

Modelling counts. Lecture 14: Introduction to Poisson Regression. Overview Modelling counts I Lecture 14: Introduction to Poisson Regression Ani Manichaikul amanicha@jhsph.edu Why count data? Number of traffic accidents per day Mortality counts in a given neighborhood, per week

More information

Introductory Statistics with R: Simple Inferences for continuous data

Introductory Statistics with R: Simple Inferences for continuous data Introductory Statistics with R: Simple Inferences for continuous data Statistical Packages STAT 1301 / 2300, Fall 2014 Sungkyu Jung Department of Statistics University of Pittsburgh E-mail: sungkyu@pitt.edu

More information

Self-Assessment Weeks 8: Multiple Regression with Qualitative Predictors; Multiple Comparisons

Self-Assessment Weeks 8: Multiple Regression with Qualitative Predictors; Multiple Comparisons Self-Assessment Weeks 8: Multiple Regression with Qualitative Predictors; Multiple Comparisons 1. Suppose we wish to assess the impact of five treatments while blocking for study participant race (Black,

More information

STP 226 EXAMPLE EXAM #3 INSTRUCTOR:

STP 226 EXAMPLE EXAM #3 INSTRUCTOR: STP 226 EXAMPLE EXAM #3 INSTRUCTOR: Honor Statement: I have neither given nor received information regarding this exam, and I will not do so until all exams have been graded and returned. Signed Date PRINTED

More information

1 Introduction to Minitab

1 Introduction to Minitab 1 Introduction to Minitab Minitab is a statistical analysis software package. The software is freely available to all students and is downloadable through the Technology Tab at my.calpoly.edu. When you

More information