knitr::opts_chunk$set(echo = TRUE, warning=FALSE) suppressWarnings(suppressMessages(suppressPackageStartupMessages(library(ggplot2))))
The stats4stem.org
website provides a table with the desired confidence level for
a $t^*$ calculation and the the confidence level entered in R's
qt() function. This is presented without explanation.
This is an exploratory data analysis
We can load the data in R as shown below.
library(statshelpR) library(pander) data(tstar_cl_r) pander(tstar_cl_r)
We can plot the data and fit it to a linear model
plt <- ggplot(tstar_cl_r, aes(x=CL, y=R)) + geom_point(color='black', size=2) + xlab("CL") + ylab("R") + ggtitle("R as a function of CL") + theme(axis.text=element_text(size=12), axis.title=element_text(size=14), plot.title = element_text(hjust = 0.5)) print(plt)
Let's do the linear model
fit <- lm(R ~ CL, data = tstar_cl_r) pander(summary(fit))
And let's update our plot with the predicted line.
pred <- data.frame(R = predict(fit, tstar_cl_r)) pred$CL <- tstar_cl_r$CL pander(pred)
plt <- plt + geom_line(color='red',data = pred, aes(x=CL, y=R)) print(plt)
So our equation is $R = 0.5*CL + 0.5$
CL <- tstar_cl_r$CL CL_to_R <- function(x){ R <- 0.5 * x + 0.5 return(R) } rVal <- sapply(CL, CL_to_R) dfCalc <- data.frame(CL=CL, R=rVal) pander(dfCalc)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.