R Programming

R tutorials on confounding/interaction and linear regression model - Updates

Last year, I created several tutorials on how to use R for identifying confounding/interaction and visualizing linear regression models. I updated these tutorials recently to address some errors and mistakes. They have received new hyperlinks:

R tutorial on confounding and interactions using the epitool and epiR packages is located on my RPubs page here. The R Markdown code is located on my GitHub page here.

R tutorial on linear regression model is located on my RPubs page here. The R Markdown code is located on my GitHub page here.

Sample size estimation and Power analysis in R

I wrote a tutorial on how to perform sample size estimations and power analysis using R “pwr” package. These are simple examples that will hopefully lead to more complicated estimations. The tutorial is available on RPubs (link). The R Markdown code is available on my Github site (link).

Logistic regression in R - Part 2 (Goodness of fit tests)

In a previous tutorial, I discussed how to perform logistic regression using R. I wrote a follow-up tutorial on how to conduct goodness of fit tests for logistic regression models in R and posted it on RPubs. The R Markdown code is available on my Github site.

I’ve learned how to assess model fit using Pearson correlations, deviance, and modified Hosmer-Lemeshow Goodness Of Fit (GOF) tests. I think these are important tools when assessing the fit of a logistic regression model. However, I wanted to focus on the HL GOF tests for this tutorial because there are a lot of nuances that I learned and wanted to share.

Additionally, I added the usefulness of visualizing whether the model over- or under-predicts the actual observed data using the calibration plot in R.

Logistic regression in R

I wrote a tutorial on how to construct logistic regression models in R. This tutorial was published on RPubs (link). I go through the use of the glm() command to perform a crude logistic regression model and a multivariable logistic regression model. The data (diabetes.csv) that I used for the motivating example is located here.

The RMarkdown code I used to create the tutorial is located on my GitHub site (link).

Visualizing linear regression models using R - Part 2

I continue my previous blog post on visualizing linear regression models using R (link). Part 2 focuses on using visualization to assess whether the model’s residuals were associated with the predicted values and whether they are normally distributed.

The R Markdown code that I wrote to create this tutorial is located on my GitHub site (link).

You can find the tutorials on my RPubs site:

  • Part 1 - Visualizing linear regression model using R (link)

  • Part 2 - Visualizing linear regression model using R (link)

(NOTE: on 30 January 2022, I updated these tutorials and they can be found in my RPubs page here. The R Markdown code is saved on my GitHub page here.)

Visualizing linear regression models using R - Part 1

I wrote a tutorial on how to visualize linear regression models using R. In the tutorial I used the lm() command and the predict3d package to generate the models and visualize them using R. You can view the RPubs tutorial here. (NOTE: on 30 January 2022, I updated this tutorial and it can be found in my RPubs page here.) I created this tutorial using R Markdown, and the codes are available on my GitHub site (link).

R tutorial on using the epitools package to assess confounding and interaction

I created an R tutorial on using the epitools and epiR packages to assess confounding and interaction. It is located on my RPubs page here. I used R Markdown to create this tutorial and I uploaded my code on my GitHub page here. Here is a figure summarizing the lessons from the tutorial.

Forest plots in R

I wrote a tutorial on how to create forest plots in R. It’s posted on the RPubs site; here’s the link.

I wrote the tutorial on R Markdown and posted the code on my GitHub page (link).

This was an entertaining exercise to learn how to do this in R. There are, of course, lots of ways to create forest plots in R, but I wanted to learn how to do this using ggplot2 and some native R packages.

Here is the final forest plot.