PLEASE PUT THE R CODE. The built-in dataset rock data frame has 48 rows and 4 nu
ID: 3313210 • Letter: P
Question
PLEASE PUT THE R CODE.
The built-in dataset rock data frame has 48 rows and 4 numeric columns of data. The data is from measurements on core samples from petroleum reservoirs. Each core sample/cross section was measured or permeability, total area of pores, total perimeter of pores, and shape. The data in the area column of rock is the data is the data we shall consider. Let the random variable X represent a random observation from rock area. Assume the area column of rock is the outcome of a random sample of size 48 from a population with distribution X. Assume X has mean and standard deviation o. Answer the following using R code: a) Give the R code to assign the data of the rocksarea column to the vector x. b) Calculate the range of x. (Single number) c) Using the R quantile function calculate the 25th percentile of x. d) Calculate the sample mean of x. Cal this mean xbar e) Calculate the sample median of x. of x. g) Calculate the critical value to be used to produce an 97% confidence interval for . h) Find the lower boundary for a 97% confidence interval for i) Find the upper boundary for a 97% confidence interval for j) How long is the 97% confidence interval for ?Explanation / Answer
(a)
To assign the data of the rock$area column to the vector x, we can use
x <- rock$area
or simply,
x = rock$area
(b)
We calculate the range of x using the code: range(x)
But it will give a pair of values (minimum and maximum) rather than a single value.
For a single valued answer, we use: max(x) – min(x)
The output is 11196
(c)
For calculating 25th parcentile, we use the built-in quantile function:
quantile(x, .25)
This gives the answer: 5305.25
(d)
To calculate sample mean and denoting it by xbar, we use the code:
xbar = mean(x)
Calling up xbar gives the result: 7187.729
(e)
To calculate median of x, we use: median(x)
The result is: 7487
(f)
By default, the sd function of R calculates sample standard deviation.
So, to calculate sample standard deviation, we use sd(x)
This gives the output: 2683.849
(g)
The usual one-sample t-test in R tests the mean of a sample to a standard Normal population with unknown variance.
The critical value used to create a 97% Confidence Interval of the sample mean is: qt(.985,47)
The output is: 2.237974
(h)
So, to get a 97% confidence interval of µ we use: t.test(x,conf.level=.97)
This gives the lower boundary of the 97% confidence interval of µ will be: 6320.782
(i)
Similarly, using: t.test(x,conf.level=.97) gives the lower boundary of the 97% confidence interval of µ as: 8054.676
(j) Following the above results, to find the length of the 97% Confidence Interval we simply subtract the 97% Lower Boundary from 97% Upper Boundary; and we get 1733.894
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.