Docsity

5 Problems with Solutions - Statistical Analysis - Assignment 1 | STAT 200, Assignments of Statistics

Toggle sidebar
bg1
Stat 200
Homework 1 Solutions
1.4 Use R as you would a calculator to find numeric answers to the following:
1. 1 + 2(3 + 4)
2. 4
3
+ 3
2+1
3.
(4 +3)(2 +1)
4.
1+2
3+4
2
Solutions
1. > 1 + 2 * (3 + 4)
[1] 15
2. > 4^3 + 3^(2+1)
[1] 91
3. > sqrt((4+3)*(2+1))
[1] 4.582576
4. > ((1+2) / (3+4))^2
[1] 0.1836735
1.9
The asking price of unused MINI Coopers varies from seller to seller. An online
classifieds listing has these values in thousands:
15.9 21.4 19.9 21.9 20.0 16.5 17.9 17.5
1. What is the smallest amount? The largest?
2. Find the average amount.
3. Find the differences of the largest and smallest amounts from the mean.
Enter in the data and apply one of R’s functions to find answers to the above questions.
Solutions
> cooper <- c(15.9,21.4,19.9,21.9,20.0,16.5,17.9,17.5)
1. > range(cooper)
[1] 15.9 21.9
2. > mean(cooper)
[1] 18.875
3. > range(cooper) - mean(cooper)
[1] -2.975 3.025
1.12
Create the following sequences:
1. “a”, “a”, “a”, “a”, “a”
2. 1, 3, …, 99 (the odd numbers in [1,100])
pf3

Partial preview of the text

Download 5 Problems with Solutions - Statistical Analysis - Assignment 1 | STAT 200 and more Assignments Statistics in PDF only on Docsity!

Stat 200

Homework 1 Solutions

1.4 Use R as you would a calculator to find numeric answers to the following:

  1. 1 + 2(3 + 4)

  2. 43 + 32+

  3. (4 + 3)(2 + 1)

2

Solutions

  1. 1 + 2 * (3 + 4) [1] 15

  2. 4^3 + 3^(2+1) [1] 91

  3. sqrt((4+3)*(2+1)) [1] 4.

  4. ((1+2) / (3+4))^ [1] 0.

1.9 The asking price of unused MINI Coopers varies from seller to seller. An online classifieds listing has these values in thousands: 15.9 21.4 19.9 21.9 20.0 16.5 17.9 17.

  1. What is the smallest amount? The largest?
  2. Find the average amount.
  3. Find the differences of the largest and smallest amounts from the mean. Enter in the data and apply one of R’s functions to find answers to the above questions.

Solutions

cooper <- c(15.9,21.4,19.9,21.9,20.0,16.5,17.9,17.5)

  1. range(cooper) [1] 15.9 21.

  2. mean(cooper) [1] 18.

  3. range(cooper) - mean(cooper) [1] -2.975 3.

1.12 Create the following sequences:

  1. “a”, “a”, “a”, “a”, “a”
  2. 1, 3, …, 99 (the odd numbers in [1,100])

using : seq(), or rep() as appropriate.

Solutions

  1. rep("a", 5) [1] "a" "a" "a" "a" "a"

  2. seq(1, 100, by=2) [1] 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 [24] 47 49 51 53 55 57 59 61 63 65 67 69 71 73 75 77 79 81 83 85 87 89 91 [47] 93 95 97 99

  3. rep(c(1,2,3), c(3,3,3)) [1] 1 1 1 2 2 2 3 3 3

  4. rep(c(1,2,3), c(3,2,1)) [1] 1 1 1 2 2 3

  5. c(seq(1,5), seq(4,1)) [1] 1 2 3 4 5 4 3 2 1

1.23 For the data set treering, which contains tree-ring widths in dimensionless units, use an R function to answer the following:

  1. How many observations are there?
  2. Find the smallest observation.
  3. Find the largest observation.
  4. How many are bigger than 1.5?

Solutions

  1. length(treering) [1] 7980

  2. min(treering) [1] 0 which(treering == 0) [1] 1395

  3. max(treering) [1] 1. which(treering == 1.908) [1] 2185

  4. sum(treering > 1.5) [1] 219