In R, \'nlme\' is a library or package, containing many useful functions and dat
ID: 3252052 • Letter: I
Question
In R, 'nlme' is a library or package, containing many useful functions and datasets. We will focus on using one dataset inside this library, called Gasoline. In the R console, type library(nlme) Gasoline str(Gasoline) ?Gasoline How many variables are contained in this data set? Calculate the mean of vapor. Calculate the sample variance of vapor manually by translating the equation of variance below into R code, S^2 = 1/n - 1 Sigma^infinity _i = 1 (x_i - x)^2. Note that the length() function can give you the length of a vector. Confirm that you performed the calculation of variance correctly by comparing your result with var(x). Generate a histogram of yield and describe the shape of the histogram. Calculate the five number summary for yield. Generate side-by-side boxplots, comparing endpoint to Sample. Does it seem that the endpoint differs by Sample? Generate a plot that illustrates the relationship between yield and endpoint. Describe the relationship between these two variables.Explanation / Answer
1. 6 variables are there in this data set.
2.
library(nlme)
y=Gasoline
str(Gasoline)
v=y[,5]
> n=length(v)
> n
[1] 32
> mv=mean(v)
> mv
[1] 4.18125
> mvv=sum((v-mv)^2)/(n-1)
> mvv
[1] 6.863508
> mv1=var(v)
> mv1
[1] 6.863508
3.
hist(y[,1])
The plot is right (positive) skewed
summary(y[,1])
Min. 1st Qu. Median Mean 3rd Qu. Max.
2.80 11.65 17.80 19.66 27.05 45.70
4.
par(mfrow=c(1,2))
boxplot(y[,2], main="Endpoints")
boxplot(y[,3], main="sample")
It seem that endpoint differs by sample
5.
plot(y[,1], y[,2], main="Endpoint vs yield", ylab="Endpoint", xlab="yield")
Yes, there is a relationship between these variables.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.