Question

. R problem 1: Cernsus At School is a project that engages students in grades 4 - 12. The data from the project contains many variables. In this problem we will examine the following variables: -Languages.spoken: the number of languages a student can hold an everyday conversation Armspan.cm: the physical measurement of the length from one end of a students arms (measured at the fingertips) to the other when raised parallel to the ground at shoulder height at a 90° angle - Gender: Students gender Use the following command to inport and attach the data set. hu3.dat<-read.csv(http://users.stat.umn.edu/wuxxx725/data/CensusAtSchoolUS. csv) attach(hw3.dat) a) Let X be the random variable that represents the number of languages a randomly selected student can hold an everyday conversation. Use R command table) to create a probability distribution STAT 3011 of X. (Hint: There are 200 students total in this data set). Include the R command and output in your submission. Describe the shape of the probability distribution (symmetric, left skewed, right skewed, etc.) b) Use the table fron a) to calculate the expected value of X, μ. Interpret the result. c) Use R command sean to verify your answer in b). Copy and paste your R command andR code all steps (copy paste it) - for all answers

0 0
Add a comment Improve this question Transcribed image text
Answer #1

As mentioned in the question, the following R commands are required to import and attach the dataset.

hw3.dat <- read.csv("http://users.stat.umn.edu/~wuxxx725/data/CensusAtSchoolUS.csv")
attach(hw3.dat)

a) The total number of students in the dataset can be found by the following R commands. The output is given immediately below the command.

> dim(hw3.dat)   #This command gives the number of rows = 200
[1] 200 62

The total number of students is 200. This is also verified by the R command given below.

> length(Languages_spoken)
[1] 200

X is a discrete random variable which represents the number of languages a randomly selected student can hold an everyday conversation. The probability that a random variable takes a particular value is given by

??= 1 X 200

With the help of the R command table(), we create a probability distribution of the random variable X as given below.

> X <- table(Languages_spoken) #This command gives the frequency distribution of X
> X
Languages_spoken
1 2 3 4 5
126 58 14 1 1


> f_x <- table(Languages_spoken) / length(Languages_spoken) #This command gives the probability distribution of X
> f_x
Languages_spoken
1 2 3 4 5
0.630 0.290 0.070 0.005 0.005

Hence the probability distribution of the random variable X is:

\textup{Value of X} \; (x) 1 2 3 4 5
f(x) = P(X = x) 0.63 0.29 0.07 0.005 0.005

\textup{Please check that} \sum_{x=1}^{5} f(x) = 0.63 + 0.29 + 0.07 + 0.005 + 0.005 = 1.

This can be verified by the following R command.

> sum(f_x)
[1] 1

The following R commands are used to plot the probability distribution of X. The output is shown below.

# Plot the PMF
# type="h" MEANS THAT THE PLOT IS VERTICAL LINES
# points ADDS CIRCLES, abline ADDS AXES
> x <- sort(unique(Languages_spoken))
> x
[1] 1 2 3 4 5
> plot(x, f_x, type="h", col=2, main="Probability Distribution of X", xlab="x", ylab="P(X = x)")
> points(x, f_x, col=2)
> abline(h=0, col=3)

Probability Distribution of X f1 1 2 4

From the above plot, it is evident that the shape of the probability distribution of X is Right-Skewed.

b) The R commands and the output are shown below.

> mu <- sum(x * f_x)
> mu
[1] 1.465

Hence the expected value of X i.e. \mathbf{\mu = 1.465} .

Interpretation: Over a period of time, the average number of languages that a student can hold an everyday conversation is 1.465.

c) The R command and the output are shown below.

> mean(Languages_spoken)
[1] 1.465

Hence the answer in (b) is verified.

Add a comment
Know the answer?
Add Answer to:
R code all steps (copy paste it) - for all answers . R problem 1: Cernsus...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Paste the R code for each exercise along with the answers. If: Age <- c(22, 25,...

    Paste the R code for each exercise along with the answers. If: Age <- c(22, 25, 18, 20) Name <- c("James", "Mathew", "Olivia", "Stella") Gender <- c("M", "M", "F", "F")       then what is the R-code for getting the following output: ##   Age   Name Gender ## 1 22 James      M ## 2 25 Mathew      M a. DataFrame = data.frame(c(Age), c(Name), c(Gender)) subset(DataFrame, Gender == "M") b. DataFrame = data.frame(c(Age),c(Name),c(Gender)) subset(Gender=="M"), eval=FALSE c. DataFrame = data.frame(Age,Name,Gender) subset(DataFrame,Gender=="M") d. DataFrame = data.frame(c(Age,Name,Gender))...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
Active Questions
ADVERTISEMENT