The built-in R dataset swiss gives Standardized fertility measure and socio-economic indicators for each of 47 French-speaking provinces of Switzerland at about 1888. The dataset is a data frame containing 6 columns (variables). The column Infant.Mortality represents the average number of live births who live less than 1 year over a 3-year period. We are interested in the Infant.Mortality column. We can convert the data in this colun to an ordinary vector x by making the assignment x <- swiss$Infant.Mortality. Then we can easily access the data. We can also get the data by entering the values 1 by 1. (You would be wise to not do the 1 by 1 entry.) The following is a screen print of the data values: [1] 22.2, 22.2, 20.2, 20.3, 20.6, 26.6, 23.6, 24.9, 21.0, 24.4, 24.5, 16.5, 19.1, 22.7 [15] 18.7, 21.2, 20.0, 20.2, 10.8, 20.0, 18.0, 22.4, 16.7, 15.3, 21.0, 23.8, 18.0, 16.3 [29] 20.9, 22.5, 15.1, 19.8, 18.3, 19.4, 20.2, 17.8, 16.3, 18.1, 20.3, 20.5, 18.9,, 23.0 [43] 20.0, 19.5, 18.0, 18.2, 19.3 Assume these values are a random sample from a normal population with unknown mean μ and unknown standard deviation σ. Let x be the vector created by the assignment x <- swiss$Infant.Mortality. a) Using R, calculate the interquartile range of x 3.55 b) Calculate the sum of the squares of the elements of x. c) Calculate the sample mean of x. d) Calculate the sample variance of x. e) Calculate the sample standard deviation s of x. f) Calculate the maximum likelihood estimate of σ2 using this data. g) Calculate the maximum likelihood estimate of 6σ using this data. h) Calculate the 22nd percentile of x using R. i) Calculate the sample variance of the R vector sqrt(x). j) Calculate an unbiased estimate of σ2 using this data. k) Using this data, create a 99% confidence interval for μ, noting that the sample size is large enough so we can use a normal distribution critical value zstar.( , ) l) Using this data, create a 99% prediction interval for μ, noting that the sample size is large enough so we can use a normal distribution critical value zstar. ( , ) m) Using this data, we create a 1% level test of H0: μ=21 versus the alternative Ha: μ < 21. We will reject H0 if z = x − 21 s 47 < zstar where s is the sample standard deviation. What is the value of zstar? (Calculate from normal distribution) n) Continuing from part m, what is the value of z? o) Continuing from parts m and n, what is the p value of the test.
Let x be the vector created by the assignment x <- swiss$Infant.Mortality. a) Using R, calculate the interquartile range of x 3.55 b) Calculate the sum of the squares of the elements of x. c) Calculate the sample mean of x. d) Calculate the sample variance of x. e) Calculate the sample standard deviation s of x.
a) Using R, calculate the interquartile range of x 3.55
Rocde:
IQR <- quantile(x,0.75)-quantile(x,0.25)
IQR
output:
IQR=3.55
b) Calculate the sum of the squares of the elements of x
Rcode:
sum_of_squares <- sum((x^2))
sum_of_squares
Output:
sum_of_squares = 19082.41
Solution:c
xbar <- mean(x)
xbar
output:
19.94255
sample mean= 19.94255
SOlutiond:
samplevar <- var(x)
samplevar
sample variance= 8.483802
Solutione:
Calculate the sample standard deviation s of x.
samplesd <- sd(x)
samplesd
Output:
2.912697
sample standard deviation=2.912697
Get Answers For Free
Most questions answered within 1 hours.