Question

In: Statistics and Probability

Enter your answers in the empty code chunks. Don't change anything in the chunk below, and...

Enter your answers in the empty code chunks.

Don't change anything in the chunk below, and make sure you run it before attempting any of the problems:

```{r message=FALSE, warning=TRUE}
library(tidyverse)
library(ggpubr)
set.seed(2018) # Belgium win 3rd place in the World Cup
```

# Basics

Calculate $\frac{(2+2)\times (3^2 + 5)}{(6/4)}$:

```{r basics1}
# your code here
```

Create a vector called "x" with the following values: 10, 15, 18, 20.

```{r basics2}
# your code here
```


Calculate the mean (`mean()`), median (`median()`) and standard deviation (`sd()`) of `x`.

```{r basics3}
# your code here
```

Draw two numbers from a standard normal distribution (`rnorm()`):

```{r basics4}
# your code here
```

Draw 100 numbers from a normal distribution with a mean of **7** and standard deviation of **4**, and store the output in an object called "x1":

```{r basics5}
# your code here
```

Draw 100 numbers from a normal distribution with a mean of **5** and standard deviation of **2**, and store the output in an object called "x2":

```{r basics6}
# your code here
```

Use `data.frame()` to combine `x1` and `x2` into a data frame called "df":

```{r basics7}
# your code here
```

Use the `$` indexing method to calculate:

* the mean of the first column of `df`:

```{r basics8}
# your code here
```

* the standard deviation of the second column of `df`:

```{r basics9}
# your code here
```

Use `head()` to print the first **3** rows of `df`:

```{r basics10}
# your code here
```

# `dplyr`

Let's work with the data set `diamonds`:

```{r data}
data(diamonds)
head(diamonds)
```

Calculate the average price of a diamond:

```{r dplyr1}
# your code here
```

Use `group_by()` to group diamonds by **color**, then use `summarise()` to calculate the average price *and* the standard deviation in price **by color**:

```{r dplyr2}
# your code here
```

Use `group_by()` to group diamonds by **cut**, then use `summarise()` to count the number of observations **by cut**:

```{r dplyr3}
# your code here
```

Use `filter()` to remove observations with a depth greater than 62, then use`group_by()` to group diamonds by **clarity**, then use `summarise()` to find the maximum price of a diamond **by clarity**:

```{r dplyr4}
# your code here
```

Use `mutate()` and `log()` to add a new variable to the data called "log_price":

```{r dplyr5}
# your code here
```


# `ggplot2`

Continue using `diamonds`.

Use `geom_histogram()` to plot a histogram of prices:

```{r ggplot1}
# your code here
```

Use `geom_density()` to plot the density of *log prices* (the variable you added to the data frame):

```{r ggplot2}
# your code here
```

Use `geom_point()` to plot carats against log prices (i.e. carats on the x-axis, log prices on the y-axis):

```{r ggplot3}
# your code here
```

Use `stat_summary()` to make a bar plot of **average** cut:

Same as above but change the theme to `theme_classic()`:

```{r ggplot4}
# your code here
```


Finally,

* create a bar plot for **average** color and assign it to the object "plot_color";
* create a scatter plot for depth against log pricse (depth on x-axis, log prices on y-axis) and assign it to the object "plot_depth";
* use `ggarrange` from `ggpubr` to combine `plot_color` and `plot_depth` into a single plot with automatic labels.

```{r ggplot5}

```

# Inference

Use `t.test()` to test the following hypothesis on *log price*:

$$
H_0: \mu = 8 \\
H_A: \mu \neq 8
$$

Solutions

Expert Solution

Note : Allowed to solve only 4 sub-questions in one post.

But the post has more than 20 questions. I have solved the first 15 codes questions in the time provided. Unable to solve the remain as I am running out time. (Note: Limited time provided to solve the question)

Request you to repost the remaining question to get them answered.


Related Solutions

C++: Do not change anything in the supplied code below that will be the Ch16_Ex5_MainProgram.cpp except...
C++: Do not change anything in the supplied code below that will be the Ch16_Ex5_MainProgram.cpp except to add documentation. PLEASE DO NOT CHANGE THE CODE JUST ADD DOCUMENTATION. Thank you. The last few have changed the code. Appreciate you all. Please use the file names listed below since your file will have the following components: Ch16_Ex5_MainProgram.cpp - given file //22 34 56 4 19 2 89 90 0 14 32 88 125 56 11 43 55 -999 #include <iostream> #include...
Please make my Code working and pass the test but do NOT change anything in main...
Please make my Code working and pass the test but do NOT change anything in main function, thank you. #include <iostream> using namespace std; void sort(int *A, int n){    for(int passes = 0;passes < 2;passes++) { // shift can have only two values either 0 or 16, used for shifting purpose int shift = passes * 16; int N = 1<<(16 + 1);    // Temporary array for storing frequency of upper or lower 16 bits int temp[N];   ...
Complete the table below. (Note: Round off your answers to the nearest hundredths. Don't use comma)...
Complete the table below. (Note: Round off your answers to the nearest hundredths. Don't use comma) Ra r m t Present Value P 1,100 8% annually 20 years P 2,200 9% semi - annually 15 years P 3,300 10% quarterly 10 years P 4,400 11% monthly 5 years P5,500 12% annually 5 years
Code in Java Change the instructionLabel to ask the user to enter a numeric value into...
Code in Java Change the instructionLabel to ask the user to enter a numeric value into the textField and click the button to convert the entered value from kilometers to miles (1.609344 km = 1 mile). When the actionButton on the form is clicked, ActionWindow should take the value entered in the textField, convert it from kilometers to miles, and display the result in the resultField. import java.awt.Container; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; public class...
Based on the below code: Answer the following questions and explain your answers: i)Presume that the...
Based on the below code: Answer the following questions and explain your answers: i)Presume that the code is instantiated in a process and it has JUST returned from its own call to fork() and there is now a clone of that process that is itself “just about” to pick up execution. Where will the clone child pick up its execution? ii)How does the clone child know it’s a clone? How does the parent process know it is not a clone,...
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...
Understand the code and explain the code and answer the questions. Type your answers as comments....
Understand the code and explain the code and answer the questions. Type your answers as comments. #include #include using namespace std; // what is Color_Size and why it is at the end? enum Color {        Red, Yellow, Green, Color_Size }; // what is Node *next and why it is there? struct Node {        Color color;        Node *next; }; // explain the code below void addNode(Node* &first, Node* &last, const Color &c) {        if (first == NULL)...
  Refer to the table for Moola given below to answer the following questions Enter answers...
  Refer to the table for Moola given below to answer the following questions Enter answers as whole numbers a. What is the equilibrium interest rate in Moola?... percent. b. What is the level of investment at the equilibrium interest rate? $...? c. Is there either a recessionary output gap (negative GDP gap) or an inflationary output gap (positive GDP gap) at the equilibrium interest rate and, if either, what is the amount? Recessionary output or Gap Inflationary output gap...
Write a C++ code to ask the user to enter 4 values (whole numbers). Your code...
Write a C++ code to ask the user to enter 4 values (whole numbers). Your code should print the numbers in descending order.
Note: for the following you may enter your answers as calculations using * for times; /...
Note: for the following you may enter your answers as calculations using * for times; / for divide and ** for to the power. For example, 10 over 7 cubed would be 10/7**3. A program to produce greeting cards has 92 pictures to choose from and 17 different sayings. If you randomly select a picture and a saying to make a card, what is the probability of selecting a particular card if all outcomes are equally likely? What is the...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT