This presentation is using the mtcars data in R, in this small project, we try to fit the linear model, we want to see two easy question:
-What is the relationship between the hp and MPG?
-Does the AM affect the hp and this relationship
7/14/2020
This presentation is using the mtcars data in R, in this small project, we try to fit the linear model, we want to see two easy question:
-What is the relationship between the hp and MPG?
-Does the AM affect the hp and this relationship
Here we use the ggplot2 package and plotly package, you can directly click the specific point to know the value and information of the some point~
suppressMessages(library(ggplot2)) suppressMessages(library(plotly))
## Warning: package 'plotly' was built under R version 3.6.2
We plot the graph, we can see these two relationship is really similar.
We can see know that the p-value is relative small, we can see it as there is not relation between the hp and am~.
library(statsr)
inference(y = hp, x = as.character(am),
data = mtcars, statistic = "mean",type = "ht",
method = "theoretical",
null = 0,
alternative = "twosided")
## Response variable: numerical ## Explanatory variable: categorical (2 levels) ## n_0 = 19, y_bar_0 = 160.2632, s_0 = 53.9082 ## n_1 = 13, y_bar_1 = 126.8462, s_1 = 84.0623 ## H0: mu_0 = mu_1 ## HA: mu_0 != mu_1 ## t = 1.2662, df = 12 ## p_value = 0.2295