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: Wednesday November 27, 2019 by 11:59p.m. EST.
No. because when the data 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
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)
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.
Yes. Three criterias below:
n independent trials. In this experiment, n equals to 100. The 100 trails are independent, because whether a person was vaccinated or not would not afffect whether another person was vaccinated.
Trial consist of only two outcomes - ‘Yes’ or ‘No’. ‘Yes’ means that the person was vaccinated, and ‘No’ means that the person was not vaccinated.
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.
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.
No. Because binomial trial only consists of 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
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.
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.
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