AllBestEssays.com - All Best Essays, Term Papers and Book Report
Search

Stats 201 R

Essay by   •  May 23, 2016  •  Coursework  •  1,127 Words (5 Pages)  •  1,379 Views

Essay Preview: Stats 201 R

Report this essay
Page 1 of 5

Computer Assignment

pop.2<-read.csv("C:\\Users\\tintan23\\Desktop\\pop2.csv",header=TRUE)

  1. a) agemean<-mean(pop.2$age)

> agemean

[1] 34.97627

agesd<-sd(pop.2$age)

> agesd

[1] 4.187331

b) > boxplot(pop.2$age,main= "Key Points of Age Variable") (Plot on separate piece of paper)

c)> summary(pop.2$age)

   Min. 1st Qu.  Median    Mean 3rd Qu.    Max.

  20.00   32.00   35.00   34.98   38.00   54.00

  1. > bmimean<-mean(pop.2$bmi)

> bmimean

[1] 24.98446

> bmisd<-sd(pop.2$bmi)

> bmisd

[1] 4.188511

> boxplot(pop.2$bmi,main= "Key Points of Bmi Variable")(Plot on separate piece of paper)

> summary(pop.2$bmi)

   Min. 1st Qu.  Median    Mean 3rd Qu.    Max.

 9.986  22.080  24.820  24.980  27.700  46.230

  1. a) table(pop.2$group)

  HIGH    LOW NORMAL

 28126   4215  67659

b) table(pop.2$sex)

FEMALE   MALE

 50032  49968

  1. a) > sampleage1<-sample(pop.2$age,size=100)

> sampleage1

  [1] 35 32 31 32 37 37 34 33 35 38 34 34 33 37 31 34 29 34 40 36 27 38 35 37

 [25] 33 36 26 33 34 36 37 31 39 30 28 34 32 32 39 35 36 34 34 31 33 36 33 32

 [49] 37 34 34 34 35 34 38 30 31 40 28 40 35 42 31 39 33 29 39 31 34 34 39 45

 [73] 34 34 37 45 28 39 32 33 36 37 42 33 35 31 37 34 36 34 29 31 36 32 39 30

 [97] 32 30 32 40

b) > mean(sampleage1)

    [1] 34.41

   > sd(sampleage1)

   [1] 3.660035

c) > t.test(sampleage1,conf.level=0.95)

        One Sample t-test

data:  sampleage1

t = 94.015, df = 99, p-value < 2.2e-16

alternative hypothesis: true mean is not equal to 0

95 percent confidence interval:

 33.68377 35.13623

sample estimates:

mean of x

    34.41

d)  (yes it does have the mean of the population)

e )            Null Hypothesis

  • H0 = there is no difference between the mean of sample age 1  and  the  agemean
  • Research Hypothesis
  • H1 = there is a difference between the mean  of sample age 1 and agemean

               > #two-sided

> t.test(sampleage1,mu=agemean,conf.level=0.95)

   

        One Sample t-test

data:  sampleage1

t = -1.5472, df = 99, p-value = 0.125

alternative hypothesis: true mean is not equal to 34.97627

95 percent confidence interval:

 33.68377 35.13623

sample estimates:

mean of x

    34.41

  • Need to reject  research hypothesis since there is no difference. Therfore H0 = there is no difference between the mean of sample age 1  and  the  agemean

6)a) sampleage2<-sample(pop.2$age,size=100)

> sampleage2

  [1] 35 31 31 32 32 33 38 33 36 36 43 33 32 30 34 31 34 40 38 44 32 32 41 36

 [25] 31 39 35 33 32 28 44 36 36 36 34 42 35 37 37 38 35 42 30 36 35 31 38 39

 [49] 33 38 38 32 32 35 43 28 32 37 35 35 33 39 29 38 36 33 36 35 32 43 24 35

 [73] 34 24 40 42 37 35 36 31 25 34 33 32 33 33 36 34 32 35 32 35 36 30 34 37

 [97] 34 28 36 45

b)  > mean(sampleage2)

     [1] 34.8

   > sd(sampleage2)

      [1] 4.129226

c) )            Null Hypothesis

  • H0 = there is no difference between the mean of sample age 1  and  the mean of sampleage2
  • Research Hypothesis
  • H1 = there is a difference between the mean  of sample age 1 and the mean of sampleage2

 t.test(sampleage1,sampleage2,conf.level=0.95)

    Welch Two Sample t-test

data:  sampleage1 and sampleage2

t = -0.7068, df = 195.19, p-value = 0.4805

alternative hypothesis: true difference in means is not equal to 0

95 percent confidence interval:

 -1.4782206  0.6982206

sample estimates:

mean of x mean of y

    34.41     34.80

The 95% confidence interval of the difference in mean sampleage 1 and sampleage2 is between 34.41  and 34.80 .

...

...

Download as:   txt (6.5 Kb)   pdf (125.9 Kb)   docx (11.8 Kb)  
Continue for 4 more pages »
Only available on AllBestEssays.com