There are 10 questions and each question (part of a question) is worth 7.5 points each. When completed, knit the file to a .HTML and save the file as Test#1_LastName and submit the .HTML file to the Test #1 assignment link in Canvas.
Due Date: Tuesday November 26, 2019 by 11:59p.m. EST.
ANS: No, there will be no variable in front of the ‘~’ sign in the xtabs() function. When the data have already been tabulated in frequency form, we will put the frequency variable in front of the ‘~’ sign.
library(vcd)
## Loading required package: grid
#run code below
data("DanishWelfare",package="vcd")
#creating a crosstabulation of alcohol consumption (Alcohol), location (Urban) and
#marital status(Status)
structable(Alcohol ~ Urban + Status, DanishWelfare)
## Alcohol <1 1-2 >2
## Urban Status
## Copenhagen Widow 4 4 4
## Married 4 4 4
## Unmarried 4 4 4
## SubCopenhagen Widow 4 4 4
## Married 4 4 4
## Unmarried 4 4 4
## LargeCity Widow 4 4 4
## Married 4 4 4
## Unmarried 4 4 4
## City Widow 4 4 4
## Married 4 4 4
## Unmarried 4 4 4
## Country Widow 4 4 4
## Married 4 4 4
## Unmarried 4 4 4
#insert your modified code below
structable(Status ~ Urban + Alcohol, DanishWelfare)
## Status Widow Married Unmarried
## Urban Alcohol
## Copenhagen <1 4 4 4
## 1-2 4 4 4
## >2 4 4 4
## SubCopenhagen <1 4 4 4
## 1-2 4 4 4
## >2 4 4 4
## LargeCity <1 4 4 4
## 1-2 4 4 4
## >2 4 4 4
## City <1 4 4 4
## 1-2 4 4 4
## >2 4 4 4
## Country <1 4 4 4
## 1-2 4 4 4
## >2 4 4 4
ANS: It is in frequency form.
ANS: Since DanishWelfare data frame is in frequency form, we can put variable ‘Freq’ to the left of the ‘-’ sign in the xtabs() function.
Reminder: Three criteria for Binomial experiment (from our class notes): 1. n independent trials (state n and explain why trial are independent) 2. only one of two outcomes; “success” and “failure” (specify what is a “success” and what is a “failure”) 3. the probability of “success” stays the same from trial to trial (state p and why the probability stays the same from trial to trial)
ANS: Data collected from the website gs.statcounter.com shows that Chrome browser has 68.91% market share in desktop browser. We can randomly select 10 desktop browser visitors and record how many of them use Chrome browser. 1. n independent trials. We observed whether a desktop browser visitor use Chrome browser. In this experiment, n is equal to 10. The 10 trails are independent, because whether a visitor use Chrome browser does not afffect whether another visitor use Chrome browser. 2. Trial consist of only two outcomes, whether ‘Yes’ or ‘No’. we will consider ‘Yes’ as the fact that the visitor use Chrome browser, and ‘No’ as the fact that the visitor does not use Chrome browser. 3.The probability of ‘Yes’ stays the same from trial to trial. The probability of a visitor using Chrome browser is 68.91% as given by the data from the website.
Is this a binomial experiment? State Yes or No. If Yes, describe the three criteria that make this experiment Binomial. If No, state why this is not a Binomial experiment.
ANS: Yes. Assuming we collect the data that p% poeple were vaccinated for the flu this year, we will consider this is a binomial experiment for this specific question ‘Were you vaccinated for the flu this year?’, if there is a fixed number of trials of 100 subjects. To be notice, the experiment for the other questions may be not a binomial exoeriment, since we have no information about those questions. We only think it is a binomial experiment for this specific question, not for the whole researcher experiment.
Trial consist of only two outcomes, whether ‘Yes’ or ‘No’. we will consider ‘Yes’ as the fact that the person was vaccinated, and ‘No’ as the fact that the person was not vaccinated. 3.The probability of ‘Yes’ stays the same from trial to trial. The probability of a person was vaccinated is P% as given by collected data.
A student answers 10 quiz questions completely at random; the first five are true/false, the second five are multiple choice, with four options each.
Is this a binomial experiment? State Yes or No. If Yes, describe the three criteria that make this experiment Binomial. If No, state why this is not a Binomial experiment.
ANS: No, it is not a binomial experiment. Trial does not consist of only two outcomes. For the fist five questions, there are only ‘true’ or ‘false’ outcomes, but for the second five, there are four outcomes.
dbinom(6,10,0.25)
## [1] 0.016222
pbinom(5,10,0.25)
## [1] 0.9802723
Use the appropriate R function (must be one we discussed in class) to find the probability.
meanOfClaim = 15
#P(X>10)
ppois(10,meanOfClaim,lower.tail=FALSE)
## [1] 0.8815356
Use the appropriate R function (must be one we discussed in class) to find the probability.
#P(X>9)
ppois(9,meanOfClaim,lower.tail=FALSE)
## [1] 0.9301463
Use the appropriate R function (must be one we discussed in class) to find the probability.
#P(X=10)
dpois(10,meanOfClaim)
## [1] 0.04861075
library(vcd)
data("SpaceShuttle", package="vcd")
SpaceShuttle.tab = table(SpaceShuttle$nFailures)
SpaceShuttle.tab
##
## 0 1 2
## 16 5 2
k = 0 : 2
PK = prop.table(SpaceShuttle.tab)
cbind(k,Prob=round(PK,7))
## k Prob
## 0 0 0.6956522
## 1 1 0.2173913
## 2 2 0.0869565