We can create the general models we will use by setting the engine with set_engine() for linear and logistic regression, repsectively.
linear <-linear_reg() %>%set_engine("lm")logit <-logistic_reg() %>%set_engine("glm")
Linear Regression
Restrictive Model
We first fit the model predicting temperature from having a runny nose:
lm_fit1 <- linear %>%fit(BodyTemp~RunnyNose,data=flu_clean)# By using the tidy function, we can convert the resulting list into an easy to read table# From there, we can also create a dot and whisker plot to demonstrate the relative size# of the estimatesbroom::tidy(lm_fit1) %>% dotwhisker::dwplot(vline =# Creates a vertical line to visualize no associationgeom_vline(xintercept =0, colour ="black", linetype =2))
We see that the regression coefficient relating runny nose status and body temperature is about -0.3. ### Other Models No we will see how this compares to a less restrictive model by using more predictors:
Using 3 more predictors for body temperature, we get 32 different coefficients relating body temperature to each prediction and their associated interactions. We can see that this model may be too complex for interpretation.
Instead, we may want to look at how 2 or 3 predictors could impact the results:
This model is easier to use and make predictions from but is still less restrictive than the original model.
Logistic Regression
Restrictive Model
We first fit the model predicting nausea from having a runny nose:
log_fit1 <- logit %>%fit(Nausea~RunnyNose, data=flu_clean)# By using the tidy function, we can convert the resulting list into an easy to read table# From there, we can also create a dot and whisker plot to demonstrate the relative size# of the estimatesbroom::tidy(log_fit1) %>% dotwhisker::dwplot(vline =# Creates a vertical line to visualize no associationgeom_vline(xintercept =0, colour ="black", linetype =2))
We see that the regression coefficient relating runny nose status and nausea is depicted above with it’s 95% CI. The coefficient estimate is about 0.05.
We see that, again, the model is too crowded for much meaningful interpretation. We do notice the much wider ranges of values obtained by the model. Likely, the effect size is so diluted by the vast number of predictors used in the model. If more predictors are introduced, the ranges of values will also increase exponentially larger.
Instead, let’s try looking at something a little simpler but still less restrictive than the original model:
Here, we can see relative effect that each predictor has on the outcome. Simply, we see that severe weakness is strongly associated with increased nausea.