Question

In: Statistics and Probability

R studio questions Write up your answers and paste the R code Copy and paste all...

R studio questions

Write up your answers and paste the R code

Copy and paste all plots generated.

First create a sample drawn from a normal random variable. R has many distributions for which you can get probabilities and draw random numbers. We are going to use the normal. Go to help in R and type in rnorm. You will see a write up for functions associated with the normal distribution. dnorm is the density; pnorm is the probability distribution (area under the curve); qnorm gives you the value of x associated with a specific cumulative probability (inverse probability); rnorm allows you to create random samples.

1. Create the variable x by taking a random sample of size 100 from a normal population with mean 75 and standard deviation 10, that is x<-rnorm(100,75,10).

(a) Calculate the mean, median, standard deviation, and plot the data using a boxplot. Now I want to show you how to create a dummy variable that gives us a 1 if the value satisfies a condition and zero otherwise. To do this you use the command ifelse command. You can search this in help as well. 2. Create a dummy variable p72 that gives you a 1 if the value of x is less than 72 and 0 if not. p72<- ifelse(x<72,1,0). (a) calculate the mean. Note this is the proportion of observations of x below 72.

(b) use pnorm funciton to find out the probability that the random variable X is less than 72. Compare to your sample proportion.

(c) use the math operators in R to construct the lower and upper ends of a 95% confidence interval for the population proportion.

Solutions

Expert Solution

Step 1. Created the variable x by taking a random sample of size 100 from a normal population with mean 75 and standard deviation 10 using the command  x<-rnorm(100,75,10).

Step 2. Calculated the mean, median, standard deviation, and plot the data using a boxplot using the command mean(), median(), sd() and boxplot().

Step 3. Create a dummy variable p72=0, Created a p72 variable which will increase by 1 if x<72 otherwise not. p_hat is the sample proportion.

Step 4. Use the pnorm funciton to find out the probability that the random variable X is less than 72.

(c) 95% confidence interval for the population proportion using the sample proportion.


Related Solutions

Using R Studio Use the two iid samples. (You can copy and paste the code into...
Using R Studio Use the two iid samples. (You can copy and paste the code into R). They both come from the same normal distribution. X = c(-0.06, 1.930, 0.608 -0.133,0.657, -1.284, 0.166, 0.963, 0.719, -0.896) Y = c(0.396, 0.687, 0.809, 0.939, -0.381, -0.042, -1.529, -0.543, 0.758, -2.574, -0.160, -0.713, 0.311, -0.515, -2.332, -0.844, -0.942, 0.053, 0.066, 0.942, -0.861, -0.186, -0.947, -0.110, 0.634, 2.357, 0.201, -0.428, -1.661, 0.395) (a) Report 95% confidence interval for the mean of X. Should we...
In R/ R Studio, what code would I enter to find the answers to these questions?...
In R/ R Studio, what code would I enter to find the answers to these questions? What is the code to find the descriptive/ summary statistics of all variables in a data set and how do i find the mean values? What is the code to measure the skewness measure of delta time for all of all the values in the data set? What is the code to draw a histogram and q-q plot of the natural log of a...
Part 2– R work (must be done in R) Copy and paste your R code and...
Part 2– R work (must be done in R) Copy and paste your R code and output into a word document, along with your written answers to the questions, and upload to Canvas.   Follow these instructions to import the necessary dataset: Before opening the dataset needed for this problem, you’ll need to call the “car”package.  Run the following line of code: > library(car) Now you can import the “Prestige” dataset and use it to answer the question below. Name the data...
Download the attached file/s, copy and paste the code segment/s into your visual studio or any...
Download the attached file/s, copy and paste the code segment/s into your visual studio or any other C++ IDE and run it. You will have to implement a small intentional bug in your program // This program uses a function that returns a value. #include <iostream> using namespace std; // Function prototype int sum(int num1, int num2); int main() {    int value1 = 20,   // The first value        value2 = 40,   // The second value        total;         //...
Download the attached file/s, copy and paste the code segment/s into your visual studio or any...
Download the attached file/s, copy and paste the code segment/s into your visual studio or any other C++ IDE and run it. You will have to implement a small intentional bug in your program and post it for other students to debug. To be able to receive your full discussion points, you need to submit the following. Following is your check list and rubric       Attach your .cpp file/s with an implemented bug - 20pnts       Describe what the code...
Use R to answer the following question. Copy and paste the code and answer from R...
Use R to answer the following question. Copy and paste the code and answer from R into your paper. On the average,five cars arrive at a particular car wash every hour. Let X count the number of cars that arrive from 10 AM to 11 AM. Then X ∼pois(lambda = 5). Also, μ = σ2 = 5.  What is the probability that no car arrives during this period?  Suppose the car wash above is in operation from 8AM...
Having a difficult time writing this code up. ( JAVA based ) Will Copy and paste...
Having a difficult time writing this code up. ( JAVA based ) Will Copy and paste the whole solution I was left with. Thank you in advance ! Lab 5 – Class Statistics Write a program which will uses the file Lab5Data.txt containing student names and the points they had earned at the end of the class. The program should use one or more arrays to create a report with the following information: -A table containing the student name, total...
Please don't copy and paste answers from several sources. Write in your own words! Do you...
Please don't copy and paste answers from several sources. Write in your own words! Do you feel teams help or hurt creativity? Give specific examples. How should you handle a freeloader (someone not willing to do their share of the work) on a team where you are a member? Be specific. For an organization where you have worked, list three ways the organization helped you do your job. (This can be any type of organization if you have never worked.)...
Use the R script to answer the following questions: (write down your answers in the R...
Use the R script to answer the following questions: (write down your answers in the R script with ##) (1). Import FarmSize.csv to Rstudio. Use the correct function to build a linear regression model predicting the average size of a farm by the number of farms; Give the model a name (e.g. FarmSize_Model). Call the model name to inspect the intercept and slope of the regression model. Verify the answers in your manual calculation. (2). Use the correct function to...
Use the R script to answer the following questions: (write down your answers in the R...
Use the R script to answer the following questions: (write down your answers in the R script with ##) (1). Import FarmSize.csv to Rstudio. Use the correct function to build a linear regression model predicting the average size of a farm by the number of farms; Give the model a name (e.g. FarmSize_Model). Call the model name to inspect the intercept and slope of the regression model. Verify the answers in your manual calculation. (2). Use the correct function to...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT