MPG: Gasoline Consumption of Cars by Origin

Description Usage Format Source Examples

Description

Gasoline consumption (in miles per gallon in city driving) of cars by origin. There are 3 variables representing samples of sizes n1 = 58, n2 = 14 and n3 = 37.

Usage

1

Format

A data frame with 58 observations on the following 3 variables.

origin1

Gasoline consumption, a numeric vector

origin2

Gasoline consumption, a numeric vector

origin3

Gasoline consumption, a numeric vector

Source

See CAR

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
data(MPG)

library(boot)

set.seed(123)

B <- apply(MPG, MARGIN=2, 
           FUN=boot, 
           statistic=function(x, i){
             var(x[i], na.rm = TRUE)
           }, 
           R = 500)

Bt0 <- sapply(B, 
              FUN=function(x) x$t0)

Bt <-  sapply(B, 
              FUN=function(x) x$t)

Bf <- max(Bt0)/min(Bt0)

FBoot <- apply(Bt, MARGIN=1, 
               FUN=function(x){
                 max(x)/min(x)
               })

Bf

quantile(FBoot, 0.95)

sum(FBoot >= Bf)/length(FBoot)

rm(Bt0, Bt, Bf, FBoot)

Example output

[1] 2.135698
     95% 
4.520113 
[1] 0.62

mistat documentation built on April 18, 2021, 5:07 p.m.