Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

Test Items (50 points total) (1) R has probability functions available for use (Kabacoff, Section XXXXXXXXXXUsing one distribution to approximate another is not uncommon. (1)(a) (4 points) The Poisson...

1 answer below »
Test Items (50 points total)
(1) R has probability functions available for use (Kabacoff, Section XXXXXXXXXXUsing one distribution to approximate another is not uncommon.
(1)(a) (4 points) The Poisson distribution may be used to approximate the binomial distribution if n > 20 and np < 7. Estimate the following binomial probabilities using dpois() and ppois() with probability p = 0.05, and n = 100. Then, estimate the same probabilities using dbinom() and pbinom(). Show the numerical results of your calculations.
i. The probability of exactly 0 successes.
ii. The probability of fewer than 6 successes.
(1)(b) (2 points) Generate side-by-side barplots using par(mfrow = c(1,2)) or grid.a
ange(). The left barplot will show Poisson probabilties for outcomes ranging from 0 to 10. The right barplot will show binomial probabilities for outcomes ranging from 0 to 10. Use p = 0.05 and n = 100. Title each plot, present in color and assign names to the bar; i.e. x-axis value labels.
(1)(c) For this problem refer to Sections 5.2 of Business Statistics. A discrete random variable has outcomes: 0, 1, 2, 3, 4, 5, 6. The co
esponding probabilities in sequence with the outcomes are: 0.215, 0.230, 0.240, 0.182, 0.130, 0.003, XXXXXXXXXXIn other words, the probabilty of obtaining “0” is 0.215.
i. (2 points) Calculate the expected value and variance for this distribution using the general formula for mean and variance of a discrete distribution. To do this, you will need to use integer values from 0 to 6 as outcomes along with the co
esponding probabilities. Round your answer to 2 decimal places.
ii. (2 points) Use the cumsum() function and plot the cumulative probabilties versus the co
esponding outcomes. Detemine the value of the median for this distribution and show on this plot.
(2) Conditional probabilities appear in many contexts and in particular are used by Bayes’ Theorem. Co
elations are another means for evaluating dependency between variables. The dataset “faithful”" is part of the “datasets” package and may be loaded with the statement data(faithful). It contains 272 observations of 2 variables; waiting time between eruptions (in minutes) and the duration of the eruption (in minutes) for the Old Faithful geyser in Yellowstone National Park.
(2)(a) (2 points) Load the “faithful” and present summary statistics and a histogram of waiting times. Additionally, compute the empirical conditional probability of an eruption less than 3.0 minutes, if the waiting time exceeds 70 minutes.
i. (2 points) Identify any observations in “faithful” for which the waiting time exceeds 70 minutes and the eruptions are less than 3.0 minutes. List and show any such observations in a distinct color on a scatterplot of all eruption (vertical axis) and waiting times (horizontal axis). Include a horizontal line at eruption = 3.0, and a vertical line at waiting time = 70. Add a title and appropriate text.
ii. (1 point) What does the plot suggest about the relationship between eruption time and waiting time?
Answer: (Enter your answer here.)
(2)(b) (3 points) Past research indicates that the waiting times between consecutive eruptions are not independent. This problem will check to see if there is evidence of this. Form consecutive pairs of waiting times. In other words, pair the first and second waiting times, pair the third and fourth waiting times, and so forth. There are 136 resulting consecutive pairs of waiting times. Form a data frame with the first column containing the first waiting time in a pair and the second column with the second waiting time in a pair. Plot the pairs with the second member of a pair on the vertical axis and the first member on the horizontal axis.
One way to do this is to pass the vector of waiting times - faithful$waiting - to matrix(), specifying 2 columns for our matrix, with values organized by row; i.e. byrow = TRUE.
(2)(c) (2) Test the hypothesis of independence with a two-sided test at the 5% level using the Kendall co
elation coefficient.
(3) Performing hypothesis tests using random samples is fundamental to statistical inference. The first part of this problem involves comparing two different diets. Using “ChickWeight” data available in the base R, “datasets” package, execute the following code to prepare a data frame for analysis.
# load "ChickWeight" dataset
data(ChickWeight)
# Create T | F vector indicating observations with Time == 21 and Diet == "1" OR "3"
index <- ChickWeight$Time == 21 & (ChickWeight$Diet == "1" | ChickWeight$Diet == "3")
# Create data frame, "result," with the weight and Diet of those observations with "TRUE" "index"" values
esult <- subset(ChickWeight[index, ], select = c(weight, Diet))
# Encode "Diet" as a facto
esult$Diet <- factor(result$Diet)
str(result)
## Classes 'nfnGroupedData', 'nfGroupedData', 'groupedData' and 'data.frame': 26 obs. of 2 variables:
## $ weight: num XXXXXXXXXX XXXXXXXXXX175 ...
## $ Diet : Factor w/ 2 levels "1","3": XXXXXXXXXX ...
The data frame, “result”, has chick weights for two diets, identified as diet “1” and “3”. Use the data frame, “result,” to complete the following item.
(3)(a) (2 points) Display two side-by-side vertical boxplots using par(mfrow = c(1,2)). One boxplot would display diet “1” and the other diet “3”.
(3)(b) (2 points) Use the “weight” data for the two diets to test the null hypothesis of equal population mean weights for the two diets. Test at the 95% confidence level with a two-sided t-test. This can be done using t.test() in R. Assume equal variances. Display the results of t.test().
Working with paired data is another common statistical activity. The “ChickWeight” data will be used to illustrate how the weight gain from day 20 to 21 may be analyzed. Use the following code to prepare pre- and post-data from Diet == “3” for analysis.
# load "ChickWeight" dataset
data(ChickWeight)
# Create T | F vector indicating observations with Diet == "3"
index <- ChickWeight$Diet == "3"
# Create vector of "weight" for observations where Diet == "3" and Time == 20
pre <- subset(ChickWeight[index, ], Time == 20, select = weight)$weight
# Create vector of "weight" for observations where Diet == "3" and Time == 21
post <- subset(ChickWeight[index, ], Time == 21, select = weight)$weight
# The pre and post values are paired, each pair co
esponding to an individual chick.
cbind(pre, post)
## pre post
## [1,] XXXXXXXXXX
## [2,] XXXXXXXXXX
## [3,] XXXXXXXXXX
## [4,] XXXXXXXXXX
## [5,] XXXXXXXXXX
## [6,] XXXXXXXXXX
## [7,] XXXXXXXXXX
## [8,] XXXXXXXXXX
## [9,] XXXXXXXXXX
## [10,] XXXXXXXXXX
(3)(c) (2 points) Present a scatterplot of the variable “post” as a function of the variable “pre”. Include a diagonal line with zero intercept and slope equal to one. Title and label the variables in this scatterplot.
(3)(d) (4 points) Calculate and present a one-sided, 95% confidence interval for the average weight gain from day 20 to day 21. Write the code for the paired t-test and for determination of the confidence interval endpoints. **Do not use *t.test()**, although you may check your answers using this function. Present the resulting test statistic value, critical value, p-value and confidence interval.
(4) Statistical inference depends on using a sampling distribution for a statistic in order to make confidence statements about unknown population parameters. The Central Limit Theorem is used to justify use of the normal distribution as a sampling distribution for statistical inference. Using Nile River flow data from 1871 to 1970, this problem demonstrates sampling distribution convergence to normality. Use the code below to prepare the data. Refer to this example when completing (4)(c) below.
data(Nile)
m <- mean(Nile)
std <- sd(Nile)
x <- seq(from = 400, to = 1400, by = 1)
hist(Nile, freq = FALSE, col = "darkblue", xlab = "Flow",
main = "Histogram of Nile River Flows, 1871 to 1970")
curve(dnorm(x, mean = m, sd = std), col = "orange", lwd = 2, add = TRUE)
(4)(a) (2 points) Using Nile River flow data and the “moments” package, calculate skewness and kurtosis. Present a QQ plot and boxplot of the flow data side-by-side using qqnorm(), qqline() and boxplot(); par(mfrow = c(1, 2)) may be used to locate the plots side-by-side. Add features to these displays as you choose.
li
ary(moments)
(4)(b) (4 points) Using set.seed(124) and the Nile data, generate 1000 random samples of size n = 16, with replacement. For each sample drawn, calculate and store the sample mean. This can be done with a for-loop and use of the sample() function. Label the resulting 1000 mean values as “sample1”. Repeat these steps using set.seed(127) - a different “seed” - and samples of size n = 64. Label these 1000 mean values as “sample2”. Compute and present the means, sample standard deviations and sample variances for “sample1” and “sample2” in a table with the first row for “sample1”, the second row for “sample2” and the columns labled for each statistic.
(4)(c) (4 points) Present side-by-side histograms of “sample1” and “sample2” with the normal density curve superimposed. To prepare comparable histograms, it will be necessary to use “freq = FALSE” and to maintain the same x-axis with “xlim = c(750, 1050)”, and the same y-axis with “ylim = c(0, 0.025).” To superimpose separate density functions, you will need to use the mean and standard deviation for each “sample” - each histogram - separately.
(5) This problem deals with contingency table analysis. This is an example of categorical data analysis (see Kabacoff, pp.  XXXXXXXXXXThe “warp
eaks” dataset gives the number of warp
eaks per loom, where a loom co
esponds to a fixed length of yarn. There are 54 observations on 3 variables:
eaks (numeric, the number of
eaks), wool (factor, type of wool: A or B), and tension (factor, low L, medium M and high H). These data have been studied and used for example elsewhere. For the purposes of this problem, we will focus on the relationship between
eaks and tension using contingency table analysis.
(5)(a)(3 points) warp
eaks is part of the “datasets” package and may be loaded via data(warp
eaks). Load “warp
eaks” and present the structure using str(). Calculate the median number of
eaks for the entire dataset, disregarding “tension” and “wool”. Define this median value as “median_
eaks”. Present a histogram of the number of
eaks with the location of the median indicated.
Create a new variable “number” as follows: for each value of “
eaks”, classify the number of
eaks as either strictly below “median_
eaks”, or the alternative. Convert the “above”|“below” classifications to a factor, and combine with the dataset
Answered Same Day Aug 02, 2020

Solution

Shaziya answered on Aug 06 2020
121 Votes
Rwork.docx
(1) R has probability functions available for use (Kabacoff, Section 5.2.3). Using one distribution to approximate another is not uncommon.
(1)(a) (4 points) The Poisson distribution may be used to approximate the binomial distribution if n > 20 and np < 7. Estimate the following binomial probabilities using *dpois()* and *ppois()* with probability p = 0.05, and n = 100. Then, estimate the same probabilities using *dbinom()* and *pbinom()*. Show the numerical results of your calculations.
Solution :
i)The probability of 0 success
ppois(0, lambda=100)
[1] 3.720076e-44
ii) dpois(0,lambda=100,log=FALSE)
[1] 3.720076e-44
iii) dbinom(0, 100, 0.5, log = FALSE)
[1] 7.888609e-31
iv) pbinom(0, 100, 0.5, lower.tail = TRUE, log.p = FALSE)
[1] 7.888609e-31
The probability of success fewer than 6
ppois(0, lambda=100)
[1] 3.720076e-44
Warning message:
package ‘memisc’ was built under R version 3.3.3
ppois(6,lambda=100)
[1] 5.492918e-35
ppois(5,lambda=100)
[1] 3.261456e-36
dpois(0,lambda=100,log=FALSE)
[1] 3.720076e-44
dpois(5,lambda=100,log=FALSE)
[1] 3.100063e-36
dpois(5,lambda=100,log=TRUE)
[1] -81.76164
dbinom(0, 100, 0.5, log = FALSE)
[1] 7.888609e-31
dbinom(5, 100, 0.5, log = FALSE)
[1] 5.939138e-23
dbinom(5, 100, 0.5, log = TRUE)
[1] -51.17789
pbinom(0, 100, 0.5, lower.tail = TRUE, log.p = FALSE)
[1] 7.888609e-31
pbinom(5, 100, 0.5, lower.tail = TRUE, log.p = FALSE)
[1] 6.261623e-23
pbinom(5, 100, 0.5, lower.tail = TRUE, log.p = TRUE)
[1] -51.12502
Shown in screenshot below :
2) (2 points) Generate side-by-side barplots using *par(mfrow = c(1,2))* or *grid.a
ange()*. The left barplot will show Poisson probabilties for outcomes ranging from 0 to 10. The right barplot will show binomial probabilities for outcomes ranging from 0 to 10. Use p = 0.05 and n = 100. Title each plot, present in color and assign names to the bar; i.e. x-axis value labels.
data<-pnorm(10,22,sd=5)-pnorm(1,22,sd=5)
li
ary(UsingR)
E
or in li
ary(UsingR) : there is no package called ‘UsingR’
par(mfrow=c(1,2))
a <- densityplot(data)
b <- densityplot(data)

print(a, position = c(0, 10, 0.5, 1), more = TRUE)
print(b, position = c(0.5, 0, 1, 1))
i) (2 points) Calculate the expected value and variance for this distribution using the general formula for mean and variance of a discrete distribution. To do this, you will need to use integer values from 0 to 6 as outcomes along with the co
esponding probabilities. Round your answer to 2 decimal places.
Mean is coming
0.215
Variance is coming
0.01060267
As shown in the screenshot below
ii) (2 points) Use the *cumsum()* function and plot the cumulative probabilties versus the co
esponding outcomes. Detemine the value of the median for this distribution and show on this plot.
Plot between cumsum values is shown below
(2)(a) (2 points) Load the “faithful” and present summary statistics and a histogram of waiting times. Additionally, compute the empirical conditional probability of an eruption less than 3.0 minutes, if the waiting time exceeds 70 minutes.
Solution: require(stats); require(graphics)
f.tit <- "faithful data: Eruptions of Old Faithful"
ne60 <- round(e60 <- 60 * faithful$eruptions)
all.equal(e60, ne60) # relative diff. ~ 1/10000
table(zapsmall(abs(e60 - ne60))) # 0, 0.02 or 0.04
faithful$better.eruptions <- ne60 / 60
te <- table(ne60)
te[te >= 4] # (too) many multiples of 5 !
plot(names(te), te, type = "h", main = f.tit, xlab = "Eruption time (sec)")
plot(faithful[, -3], main = f.tit,
xlab = "Eruption time (min)",
ylab = "Waiting time to next eruption (min)")
lines(lowess(faithful$eruptions, faithful$waiting, f = 2/3, iter = 3),
col = "red")
Histogram for waiting times:
i. (2 points) Identify any observations in “faithful” for which the waiting time exceeds 70 minutes and the eruptions are less than 3.0 minutes. List and show any such observations in a distinct color on a scatterplot of all eruption (vertical axis) and waiting times (horizontal axis). Include a horizontal line at eruption = 3.0, and a vertical line at waiting time = 70. Add a title and appropriate text.
i. (1 point) What does the plot suggest about the relationship between eruption time and waiting time?
Solution: The suggestion which we got from the plot states that waiting time is directly proportional to eruption time as eruption time increases the waiting time also increases
(2)(b) (3 points) Past research indicates that the waiting times between consecutive eruptions are not independent. This problem will check to see if there is evidence of this. Form...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here