The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.

Getting Started with LogisticRCI

The LogisticRCI package is designed to make the calculation of the linear and logistic reliable change index easy and streamlined. In this vignette we give short examples on how to use the package based on a simulated sample dataset with 100 patients.

LogisticRCI installation and load

The LogisticRCI package is installed from CRAN and loaded in the typical way.

install.packages("LogisticRCI")
library("LogisticRCI")

Computing the Linear and Logistic RCI from a sample dataset

We can load the sample dataset and see the first 6 rows by executing:

data("RCI_sample_data")
head(RCI_sample_data)
#>   age education gender score baseline
#> 1  71        20 female     6        7
#> 2  74        15 female     5       10
#> 3  55        16   male     3        8
#> 4  63        12 female     7        5
#> 5  82        18 female     1        3
#> 6  73        14 female     2        9

In this dataset, we have baseline scores for a memory test with 15 items calculated for 100 patients (baseline), and their follow-up scores (score). We have age, education and gender as covariates.

We begin by fitting linear and logistic models.

linear_fit <- lm(score ~ baseline + age + gender + education,
                 data = RCI_sample_data)

logistic_fit <- glm(cbind(score, 15 - score) ~ baseline + age + gender + education,
                    family = binomial,
                    data = RCI_sample_data)

We can explore the significance of the covariate effects in the usual way, using anova:

anova(linear_fit)
#> Analysis of Variance Table
#> 
#> Response: score
#>           Df Sum Sq Mean Sq F value    Pr(>F)    
#> baseline   1 713.16  713.16 91.7423 1.317e-15 ***
#> age        1  14.64   14.64  1.8836    0.1732    
#> gender     1   5.28    5.28  0.6792    0.4119    
#> education  1   4.14    4.14  0.5325    0.4674    
#> Residuals 95 738.49    7.77                      
#> ---
#> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

anova(logistic_fit, test = "Chisq")
#> Analysis of Deviance Table
#> 
#> Model: binomial, link: logit
#> 
#> Response: cbind(score, 15 - score)
#> 
#> Terms added sequentially (first to last)
#> 
#> 
#>           Df Deviance Resid. Df Resid. Dev Pr(>Chi)    
#> NULL                         99     459.31             
#> baseline   1  201.030        98     258.28  < 2e-16 ***
#> age        1    5.193        97     253.09  0.02268 *  
#> gender     1    1.810        96     251.28  0.17849    
#> education  1    1.290        95     249.99  0.25611    
#> ---
#> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

To compute the reliable change index we only need to pass the fitted model objects fo the RCI function.

linear_RCI <- RCI(linear_fit)

logistic_RCI <- RCI(logistic_fit)

The RCI function automatically detects whether we are passing a linear or logistic regression model and performs the appropriate computations internally.

Let's proceed with the Logistic RCI. We can check for normality using, e.g. the Shapiro-Wilk test.

shapiro.test(logistic_RCI)
#> 
#>  Shapiro-Wilk normality test
#> 
#> data:  logistic_RCI
#> W = 0.98577, p-value = 0.3604

We don't reject the null hypothesis that the sample may have arisen from a normal distribution. We may now check how many patients are showing reliable decline using a threshold of \(-1.64\), representing the lower 5th percentile of the standard normal distribution.

sum(logistic_RCI < -1.64)
#> [1] 4

We may also identify who these patients are by looking at their IDs.

which(logistic_RCI < -1.64)
#>  3  6 38 89 
#>  3  6 38 89

So we have that patients 3, 6, 38 and 89 are exhibiting reliable cognitive decline at a 5% level.

Computing the Linear and Logistic RCI for a single new patient

Suppose we have the scores for a new patient, who is male, aged 68 years old, has 12 years of education, a baseline score of 11 and a follow-up score of 9. We first create a data.frame with the new patient information.

new_patient <- data.frame("age" = 68,
                          "gender" = "male",
                          "score" = 9,
                          "baseline" = 11,
                          "education" = 12)

Now we may calculate the RCI based on either the linear or logistic models we fitted in the previous section without having to re-fit the model to an updated sample by using the RCI_newpatient function.

RCI_newpatient(model = linear_fit, new = new_patient)
#> [1] -0.2691052
RCI_newpatient(model = logistic_fit, new = new_patient)
#> [1] -0.3361395

According to both the linear and logistic models, this new patient does not exhibit reliable cognitive decline at a 5% level.

References

Moral, R.A., Diaz-Orueta, U., Oltra-Cucarella, J. (PsyArXiv preprint) Logistic versus linear regression-based Reliable Change Index: implications for clinical studies with diverse sample sizes. DOI: 10.31234/osf.io/gq7az

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.