+ All Categories
Home > Documents > Analyzing baseline follow-up studies with the nlme-package in...

Analyzing baseline follow-up studies with the nlme-package in...

Date post: 16-Mar-2021
Category:
Upload: others
View: 7 times
Download: 0 times
Share this document with a friend
27
Analyzing baseline follow-up studies with the nlme-package in R Statistical analysis of correlated and repeated measurements for health researchers Julie Forman, Section of Biostatistics, University of Copenhagen Introduction In what follows I will describe how to analyze data from longitudinal baseline follow-up studies with the nlme-package in R. I will describe the appropriate analyses for: 1. Single group studies (the easy case, much like oneway ANOVA). 2. Parallel group studies (a little harder, much like twoway ANOVA with interaction). 3. Randomized group studies (the tricky case, but most often used in practice). and, of course, the basic data management that is needed to prepare data for analysis as well as some descriptive statistics that will help you to get an overview of your data. All of these analyses apply to data from balanced study designs meaning that follow-up times are planned to be the same for all subjects in the study (contrary to retrospective registry studies where e.g. times of visiting the doctor may differ quite substantially between patients). Note that in practice data is often collected not exactly on schedule and for some subjects data will be missing on one or more occations due to drop out, technical problems etc. Valid mixed model analyses can still be performed with missing data as long as 1) the study design remains balanced, 2) there are no systematic biases in who is seen ahead of/ behind schedule, and 3) missing data are missing at random (please refer to lectures 2 and 6 for further explanation). Case study: a randomized study on chronic kidney disease Throughout this chapter I will use data from Boesby et al (2013): Eplerenone Attenuates Pulse Wave Reflection in Chronic Kidney Disease Stage 3–4 - A Randomized Controlled Study, PLOS ONE 8(5). In this randomized study a novel treatment, Eplerenone, was compared to a standard treatment in patients with chronic kidney disease (CKD). The data from the CKD study and the R code I have used to analyze it is contained in the files cdkwide.txt and ckd-demo.R found at the course webpage. 1
Transcript
Page 1: Analyzing baseline follow-up studies with the nlme-package in Rstaff.pubhealth.ku.dk/~jufo/courses/rm2018/ckd_demo_R.pdf · 2018. 11. 14. · Analyzing baseline follow-up studies

Analyzing baseline follow-up studieswith the nlme-package in R

Statistical analysis of correlated and repeated measurements for health researchers

Julie Forman, Section of Biostatistics, University of Copenhagen

Introduction

In what follows I will describe how to analyze data from longitudinal baseline follow-up studieswith the nlme-package in R. I will describe the appropriate analyses for:

1. Single group studies (the easy case, much like oneway ANOVA).

2. Parallel group studies (a little harder, much like twoway ANOVA with interaction).

3. Randomized group studies (the tricky case, but most often used in practice).

and, of course, the basic data management that is needed to prepare data for analysis as well assome descriptive statistics that will help you to get an overview of your data.

All of these analyses apply to data from balanced study designs meaning that follow-up timesare planned to be the same for all subjects in the study (contrary to retrospective registry studieswhere e.g. times of visiting the doctor may differ quite substantially between patients). Notethat in practice data is often collected not exactly on schedule and for some subjects data willbe missing on one or more occations due to drop out, technical problems etc. Valid mixedmodel analyses can still be performed with missing data as long as 1) the study design remainsbalanced, 2) there are no systematic biases in who is seen ahead of/ behind schedule, and 3)missing data are missing at random (please refer to lectures 2 and 6 for further explanation).

Case study: a randomized study on chronic kidney disease

Throughout this chapter I will use data from Boesby et al (2013): Eplerenone Attenuates PulseWave Reflection in Chronic Kidney Disease Stage 3–4 - A Randomized Controlled Study, PLOSONE 8(5). In this randomized study a novel treatment, Eplerenone, was compared to a standardtreatment in patients with chronic kidney disease (CKD). The data from the CKD study and theR code I have used to analyze it is contained in the files cdkwide.txt and ckd-demo.Rfound at the course webpage.

1

Page 2: Analyzing baseline follow-up studies with the nlme-package in Rstaff.pubhealth.ku.dk/~jufo/courses/rm2018/ckd_demo_R.pdf · 2018. 11. 14. · Analyzing baseline follow-up studies

Figur 1: CKD study: Augmentation indices (AIX) following treatment initiation in newly diag-nosed patients with chronic kidney disease. Outcomes are shown at baseline (0 weeks) and after12 and 24 weeks of treatment with either Eplerenone or standard treatment (control group).

To highlight the differences between the twoway ANOVA type linear mixed model for parallel(i.e. non-randomized) group studies and the constrained linear mixed model for randomizedstudies, I have applied both models to the same data even though the second is the most apro-priate (the first approach is not outright wrong but it is suboptimal). For the same reason, allanalyses were carried out with the augmentation index (AIX) as outcome although this was asecondary outcome in the original study. It should be noted that, even though the estimated ef-fect on the primary outcome matched the presumed beneficial effect of Eplerenone anticipatedin the power calculation, the study was de facto underpowered and failed to reach the 5% levelof significance.

Preparing data for analysis

A trimmed version of the original records from the CKD study are contained in the datafileckdwide.txt. It contains the following variables:

id Study ID number.sex Patients gender (1=male, 2=female).age Patients age in years.treatgroup Treatment group (0=control, 1=Eplerenone).aix0 Augmentation index (%) at baseline (just before initiation of treatment).aix1 Augmentation index (%) after 12 weeks of treatment (safety visit).aix2 Augmentation index (%) after 24 weeks of treatment (end point).

It is possible to read data into SAS from the datafile using a program like the one below. Pleasenote that you have to save the datafile and change the path in the program so that it matches thelocation on your computer where the file can be found.

2

Page 3: Analyzing baseline follow-up studies with the nlme-package in Rstaff.pubhealth.ku.dk/~jufo/courses/rm2018/ckd_demo_R.pdf · 2018. 11. 14. · Analyzing baseline follow-up studies

/* Read in the data from the textfile */

ckdwide <- read.table(’ckdwide.txt’, header=TRUE, na.strings=’.’)

Note that missing data appear as .’s in the datafile. The argument na.strings=’.’ ensurethat they will be represented apropriately as NAs in R. The argument header=TRUE tells Rthat the first line in the datafile contains the names of the variables.However, knowing that importing data into R can be tricky, I have made a copy of the datawithin the program file ckd-demo.R. If you want to get started on doing linear mixed modelanalyses straight away, you can run this instead.

This is what it looks like:

/* Generate data within R */

rawdata <- matrix(c(1, 1, 57, 0, 10.5, 17.5, 25,2, 1, 48, 0, -2.5, 8, 8.5,3, 2, 54, 1, 18, 24, 23.5,

(51 records in total)

51, 7, byrow=TRUE)

colnames(raw) <- c(’id’,’sex’,’age’,’treatgroup’,’aix0’,’aix1’,’aix2’)ckdwide <- as.data.frame(raw)

Once you highlight and submit this code in R, a dataset called ckdwide is created. You canlocate ckdwide in the Environment window and click the table icon to the right of the nameof the data to take a look inside. As appears the dataset contains seven variables and 51 records(id-numbers range from one to 54 but three patients dropped out of the study before the baselinevisit). It is important to notice that all variables appear as numerical in R, they are considered asnumbers unless we specifically tell the program to treat them differently. However, we shouldbear in mind that treatment and gender are truly categorical variables which are coded as 1 forEplerenone, 0 for control treatment, and 1 for male, 2 for female, repectively.

The long and the wide format

In order to perform longitudinal data analyses and other mixed model analyses it is importantto distinguish two different formats for the same data.

1. The wide format with one record (line in the data) per subject.

2. The long format with several records (lines in the data) per subject, one for each occation.

3

Page 4: Analyzing baseline follow-up studies with the nlme-package in Rstaff.pubhealth.ku.dk/~jufo/courses/rm2018/ckd_demo_R.pdf · 2018. 11. 14. · Analyzing baseline follow-up studies

The dataset ckdwide is in the wide format, all data from the same person is contained in asingle line. This is the natural format when entering the trial data in a database (e.g. an Excellspreadsheet) because it is compact and makes it easy to compare measurements from the sameperson between the different occations. E.g the record from the patients with id=1 and id=3 inthe ckdwide data reads:

id sex age treatgroup aix0 aix1 aix21 1 57 0 10.5 17.5 25.03 2 54 1 18 24 23.5

From this we see that id=1 is a male patient aged 57 who received standard treatment and whoseaugmentation index increased from 10.5 at baseline to 25.0 at final follow-up. Similarly id=3 isfemale, aged 54, received eplerenone, and her augmentation index increased from 18 to 23.5.

However, to perform a mixed model analysis data must be presented to SAS in the so-calledlong format where each measurement appear in separate lines in the dataset and an additionalvariable identifies the occation. E.g. in the CKD-data the patient with id=1 contributes threerecords, one from week 0 (baseline), one from week 12, and one from week 24:

id week sex age treatgroup aix1 0 1 57 0 10.51 12 1 57 0 17.51 24 1 57 0 25.03 0 2 54 1 183 12 2 54 1 243 24 2 54 1 23.5

Note the redundancies in the variables id, sex, age, and treatgroup which do not changebetween occations (the same number is recorded three-fold). In contrast there is only one outco-me variable aix which now changes between occations, while three variables aix0, aix1,and aix2 were needed to contiain the repeated measurements in the wide data.

Transforming data from the wide to the long format

Fortunatly we do not have to rearrange data manually to make a long version that can be usedin the analyses. The following R code transforms the data from ckdwide and stores it in a newdataset ckdlong which is in the long format:

ckdlong <- reshape(ckdwide, direction=’long’,varying=c(’aix0’,’aix1’,’aix2’),idvar=c(’id’,’sex’,’age’),v.names=’aix’,timevar=’visit’)

ckdlong$week <- factor(ckdlong$visit, labels=c(0, 12, 24))

4

Page 5: Analyzing baseline follow-up studies with the nlme-package in Rstaff.pubhealth.ku.dk/~jufo/courses/rm2018/ckd_demo_R.pdf · 2018. 11. 14. · Analyzing baseline follow-up studies

For technical reasons we will need both a numerical and a categorical version containing theoccations for the mixed model analysis. While transforming the data from the wide to the longformat I have created the numerical variable visit which numbers occations as 1, 2, and 3.Next I have added the categorcal variable week which labels the occations as 0, 12, and 24.Please check the contents of the new dataset by opening it from the Environment window.Make sure to notice the difference between the wide and the long data format.

Descriptive statistics

Before we proceed to making statistical analyses I will show you how to make descriptivestatistics suitable for longitudinal data analyses. In particular making graphical displays of thedata will help us to:

• Spot erroneous measurements that could otherwise spoil the results of your analyses.

• Make a rough assessment of the trends in the data which will help us when interpretingthe output from the formal mixed model analyses.

• Judge wheter data is approximately normally distributed or should be transformed tobetter fulfill modeling assumptions

Some of the descriptive statistics presented below are absolutely essential for aiding the ana-lyses, they will help you correct errors in your R code as well as in your data. Others I haveincluded for pedagogical reasons to help you become familiar with linear mixed models and themultivariate normal distribution.

Spaghettiplots

Personally I would never do a longitudinal data analysis without first looking at spaghettiplots.The spaghettiplot is the most informative display since it contains all of the raw data. From thiswe can get an impression of both individual outcomes (any weird ones?) and the distributionacross the sample (trend, variation, symmetric or skewed?, weak or strong correlation?). Tomake spaghettiplots in R we can use the xyplot function in the lattice-package.

xyplot(aix~week|treatgroup, data=ckdlong, group=id, type=’b’)

Please note that xyplot applies to data in the long format. The group argument connects thedatapoints belonging to the same id. If you want to make a plot of a single group you simplyomit |treatgroup from the code. Note that more advanced plots of repeated measurementsdata can be made with the ggplot2-package. You can find additional R-notes on the coursewebpage which will teach you how to do it. However, xyplot is often sufficient to make theplots we need to inspect the data.

5

Page 6: Analyzing baseline follow-up studies with the nlme-package in Rstaff.pubhealth.ku.dk/~jufo/courses/rm2018/ckd_demo_R.pdf · 2018. 11. 14. · Analyzing baseline follow-up studies

Figur 2: Spaghettiplots made with xyplot

Scatterplot matrices

If you want to get an impression of how strong the correlation is between your repeated measu-erements and whether they are multivariately normally distributed, you can make scatterplotmatrices with the generic plot function in R. Similarly the cor function computes the cross-correlations. Note that when multiple treatments/groups are considered as in the CKD study itis apropriate to make one scatteplot matrix for each group. Hence you have to apply plot tothe subset of the data belonging to each separate treatmentgroup:

ckd0 <- subset(ckdwide, treatgroup==0)ckd1 <- subset(ckdwide, treatgroup==1)

# Simple scatterplotsplot(ckd0[,c(’aix0’,’aix1’,’aix2’)], main=’Control group’)plot(ckd1[,c(’aix0’,’aix1’,’aix2’)], main=’Eplerenone group’)

# Correlationscor(ckd0[,c(’aix0’,’aix1’,’aix2’)], use=’pairwise.complete.obs’)cor(ckd1[,c(’aix0’,’aix1’,’aix2’)], use=’pairwise.complete.obs’)

Please note that this applies to data in the wide format. More informative plots with superimpo-sed normaldistributions and including the correlations can be made with the pairs.panelsfunction in the psych-package:

# Scatterplot matrices with effects (psych-package):library(psych)pairs.panels(ckd0[,c(’aix0’,’aix1’,’aix2’)], ellipses=TRUE)pairs.panels(ckd1[,c(’aix0’,’aix1’,’aix2’)], ellipses=TRUE)

6

Page 7: Analyzing baseline follow-up studies with the nlme-package in Rstaff.pubhealth.ku.dk/~jufo/courses/rm2018/ckd_demo_R.pdf · 2018. 11. 14. · Analyzing baseline follow-up studies

Figur 3: Scatterplot matrices from the CKD study made with plot

When checking at the resulting scatterplots, you should look for the elliptical shape that cha-racterizes the multivariate normal distribution. Beware, however, that the usual problem withchecking normality recurrs: If sample sizes are small the assumption that data is normally di-stributed is important but impossible to verify (therefore small sample size should always berecognized as a limitation), while if sample sizes are large the linear mixed model is robust toall but substantial skewness and major outliers. If the data deviates a lot from the normal distri-bution, you can try to improve the fit by applying a transformation, e.g. a logarithm. When indoubt either stick to the original data or consult with a statistician.

Figur 4: Scatterplot matrices from the CKD study made with pairs.panels

Finally, I would like to point out that spaghettiplots are usually sufficient to get a feel for thedistribution of the data and that the output you get from running the mixed model analysis

7

Page 8: Analyzing baseline follow-up studies with the nlme-package in Rstaff.pubhealth.ku.dk/~jufo/courses/rm2018/ckd_demo_R.pdf · 2018. 11. 14. · Analyzing baseline follow-up studies

allows you to make residual plots that are better for judging normality (since data can be joinedacross groups and occations) as well as estimated cross-correlations.

Trends in summary statistics over time

Summary statistics over the various groups and time points in a longitudinal study can be com-puted by applying the aggregate function in R to the data in the long format. A bit of po-stprocessing is needed to collect the results in a concise manner. Here I have computed meansand standard deviations for the data from the CKD study:

# sample meansckd.mean <- aggregate(aix~treatgroup+week, data=ckdlong,

mean, na.rm=TRUE)names(ckd.mean)[3] <- ’mean’

# sample SDsckd.sd <- aggregate(aix~treatgroup+week, data=ckdlong,

sd, na.rm=TRUE)names(ckd.sd)[3] <- ’sd’

# Collect the summary statistics in a dataframeckd.summaries <- merge(ckd.mean, ckd.sd)print(ckd.summaries, digits=3)

Figur 5: Trends in sample means from the CKD study plottet with xyplot.

8

Page 9: Analyzing baseline follow-up studies with the nlme-package in Rstaff.pubhealth.ku.dk/~jufo/courses/rm2018/ckd_demo_R.pdf · 2018. 11. 14. · Analyzing baseline follow-up studies

The demo program further includes medians and ranges. From this I have obtained:

treatgroup week mean sd min median max1 0 0 24.6 24.6 -2.5 27.5 35.02 0 12 25.3 25.3 8.0 25.2 49.53 0 24 27.3 27.3 8.5 28.0 44.54 1 0 22.3 22.3 -5.5 23.2 43.05 1 12 19.9 19.9 -16.5 24.0 38.56 1 24 20.4 20.4 -10.0 19.0 39.0

To plot the sample means of the two treatment groups over time apply the xyplot function tothe dataset containing the summary statistics:

xyplot(mean~week, data=ckd.summaries, group=treatgroup, type=’b’)

1. Analysis of single group studies

In a longitudinal single group study a single homogeneous population is followed over timeand the research interest will be to describe systematic changes in the outcome. From a stati-stical point of view this means that we wish to compare population means between differenttime points while acknowledging the correlation in the repeated measurements on the the samesubject.

For illustration I will analyze the data from the control group in the CKD study to describethe natural disease progression in patients after the initiation of standard treatment. I will makefurther analyses to compare the disease progression between the Eplerenone and control groupin sections 2 and 3 below, but we start out with the single group model to make the introductionto linear mixed models as simple as possible.

Occation Population mean with control treatmentweek=0 µ1 = β0week=12 µ2 = β0 +β1week=24 µ3 = β0 +β2

Tabel 1: Population means (µ) over time expected with the control treatment of the CKD stu-dy. Changes in means over time are described by regresssion parameters (β1 and β2) with thebaseline mean as intercept (β0).

To perform the single group analysis we specify a linear mixed model with occation (week inthe CKD study) as a categorical covariate like in a oneway ANOVA model. To account for thecorrelation in the data as well as possible changes in variance/standard deviation over time wespecify an unstructured covariance pattern which needs a bit of explanation offered below.

9

Page 10: Analyzing baseline follow-up studies with the nlme-package in Rstaff.pubhealth.ku.dk/~jufo/courses/rm2018/ckd_demo_R.pdf · 2018. 11. 14. · Analyzing baseline follow-up studies

Mean and covariance parameters

A multivariate normal distribution is described by two sets of model parameters, the mean-vector and the covariance-matrix.

The mean-vektor is the list of means for each occaion,

Mean =

µ1µ2µ3

like in the above table where they have been rephrased in terms of the regression coefficients ina oneway ANOVA model.

The covariance-matrix,

Covariance =

σ21 σ12 σ13

σ21 σ22 σ23

σ31 σ32 σ23

contains the population variances from each occation on its diagonal and the covariances be-tween outcomes from different occations off the diagonal. Please recall that the covariance isthe numerator in the mathematical formula defining the correlation coefficient, e.g.

ρ12 = Corr(Y1,Y2) =Cov(Y1,Y2)

SD(Y1) ·SD(Y2)=

σ12

σ1 ·σ2.

Moreover, the covariances are symmetric, e.g. σ12 = σ21, so the covariance matrix consideredhere contains six parameters in total, three variances and three correlations.

From an applied point of view the correlation coefficient has a more direct interpretation thanthe covariance, just like the standard deviation (σ ) has a more direct interpreation than the vari-ance (σ2). However, from a mathematical point of view phrasing the multivariate normal modelin terms of variances and covariances lead to more straightforward computations and thereforethese are part of the standard output from other software packages such as SAS’ PROC MIXED.Further note that there is a one-to-one correspondence between variances-covariances and stan-dard deviations- correlations, if you know either you can compute the other.

The unstructured covariance pattern

As long as the number of occations is small compared to the number of subjects in the stu-dy we do not have to make any restrictive assumptions about the covariance parameters (suchan assumption could be that the variance was constant over time, i.e. that σ2

1 = σ22 = σ3

3 ). Byleaving the covariance matrix unrestricted, we say that we assume an unstructured covariancepattern. I would recommend specifying any linear mixed model with as unstructured covari-ance pattern as far as possible since this guarantees that we are not making any wrong modelassumptions (with the possible exception of assuming a normal distribution in the first place).

10

Page 11: Analyzing baseline follow-up studies with the nlme-package in Rstaff.pubhealth.ku.dk/~jufo/courses/rm2018/ckd_demo_R.pdf · 2018. 11. 14. · Analyzing baseline follow-up studies

R program - specifying the linear mixed model

To perform a linear mixed model analysis with an unstructured covariance pattern, we have touse the gls function to specify a model object. The gls function is fuond in the nlme-packagewhich must be loaded prior to analysis.

library(nlme) # load nlme-package

ckdlong$treatgroup <- factor(ckdlong$treatgroup)ckdlong$id <- factor(ckdlong$id)

fit1 <- gls(aix~week,data=subset(ckdlong, treatgroup==0),correlation=corSymm(form=~visit|id),weights=varIdent(form=~1|visit),na.action=na.exclude,control=glsControl(opt=’optim’))

As to the essential parts of the code:

• Don’t forget that numerical variables must be transformed into categorical ones with thefactor function in order for R to recognize them as such. By default R chooses thecategory first in alphabetic/numerical order as reference point. In case you want anothercategory to be used as reference you can change it with the relevel function. Notethat we have already defined week as a categorical covariate when constructing the longdataset, so we only need to transform id and treatgroup before we fit the model.

• The model formula (aix∼week) specifes which variable is the outcome (left of ∼) andwhich are the covariates (right of ∼).

• data specifies which dataset the model is applied to. In this case we are only interestedin the control group so we pick out the relevant records with the subset function. Notethat gls applies to data in the long format.

• correlation=corSymm ... specifies an unstructured correlation matrix for therepeated measurements. We have to supply id and visit to corSymm as shown inthe above so that R knows that the repeated measurements with the same id belongs tothe same subject and also from which time point (the numerical variable visit).

• weights=varIdent ... is needed to complete the specification of the unstructu-red covariance by allowing the variances / standard deviation to differ between the timepoints. The numerical variable visit must be supplied to varIdent to distinguishobservations from different occations. Note that the name varIdent is a bit counterin-tuitive since this is what specifies non-indentical variances for the various occations.

• na.action=na.exclude should always be supllied in case data contains recordswith missing values. Otherwise gls returns an error message.

11

Page 12: Analyzing baseline follow-up studies with the nlme-package in Rstaff.pubhealth.ku.dk/~jufo/courses/rm2018/ckd_demo_R.pdf · 2018. 11. 14. · Analyzing baseline follow-up studies

• control=glsControl(opt=’optim’) is a technical option which often makesthe numerical optimisation run more smoothly in R.

R program - extracting results from the analysis

In order to obtain the results from the linear mixed model analysis, statistical information mustbe extracted from the model object. This can be done using a number of different extractorfunctions which I describe here.

• summary(fit1) returns estimates, corresponding p-values, an overall model sum-mary, and a load of other more or less useful information.

• intervals(fit1) resturns estimates and approximate 95% confidence intervals.

• anova(fit1, type=’marginal’) outputs approximate type 3 tests.

• getVarCov(fit1) returns the estimated covariance matrix.

• The predicted population means can be computed with the predict function, but firstwe need to construct a new dataframe containing the values of the covariates we want tomake predictions for. It is important to name and value the variables in the new dataframeexactly as in the original data. In particular, categorical variables must be remade withfactor.

pred1 <- data.frame(week=factor(c(1,2,3), labels=c(0,12,24)))pred1 <- cbind(pred1, pred=predict(fit1, newdata=pred1))

Once the covariates and the predicted values have been stored in the same dataframe it iseasy to plot the predictions with xyplot:

xyplot(pred~week, data=pred1, type=’b’)

• residuals(fit1, type=’pearson’) extract residuals allowing you to assessyour models fit to the data. Note that the ordinary residuals (which you get if you omit theargument type=’pearson’) are hard to assess if the variance is truly heterogeneous(changes with time). The pearson residuals have been standardized to make the variancehomogeneous. To make a standard residualplot and a QQplot I use:

par(mfrow=c(1,2))plot(fitted(fit1), residuals(fit1, type=’pearson’))abline(h=0)qqnorm(residuals(fit1, type=’pearson’))abline(0,1)

12

Page 13: Analyzing baseline follow-up studies with the nlme-package in Rstaff.pubhealth.ku.dk/~jufo/courses/rm2018/ckd_demo_R.pdf · 2018. 11. 14. · Analyzing baseline follow-up studies

The most important parts of the output

Admittedly the summary function produces quite a lot of output. Here I will describe only themost interesting parts. I plan to add a commented version of the complete output in an appendixin the next version of these notes.

Model specification and convergence: The first part of the output from summary tells us whatnumerical optimisation R has performed:

Generalized least squares fit by REML

Which model was specified for the means;

Model: aix ~ week

What data the analysis has been applied to:

Data: subset(ckdlong, treatgroup == 0)

Which model was specified for the correlations (General means unstructured) . . .

Correlation Structure: GeneralFormula: ~week | id

. . . and the standard deviations:

Variance function:Structure: Different standard deviations per stratumFormula: ~1 | week

All in all this is not that interesting, but at least I can tell that R has analyzed the model I inten-ded with the correct outcome and covariates from the correct dataset.

Finally, the degrees of freedom at the end of the summary output should be noted.

Degrees of freedom: 72 total; 69 residual

Warning: A limitation of the gls function is that it cannot do small sample corrections to theresidual degrees of freedom like PROC MIXED in SAS. This implies that if sample sizes aresmall, or even moderate, the p-values and confidence intervals you get from your gls modelobject are somewhat anticonservative. Unfortunately there is not much you can do to fix theproblem (other than doing the analysis in SAS instead).

13

Page 14: Analyzing baseline follow-up studies with the nlme-package in Rstaff.pubhealth.ku.dk/~jufo/courses/rm2018/ckd_demo_R.pdf · 2018. 11. 14. · Analyzing baseline follow-up studies

Estimates and confidence intervals: The most interesting part of the output is the estima-ted time-effect, i.e. the estimated mean change in AIX occuring from baseline to the safety visitafter 12 weeks and the end point visit after 24 weeks, respectively. Note that, since week=0has be set as reference point, the intercept in this model correspons to the population mean AIXat baseline (i.e. prior to initiation of treatment).

Coefficients:Value Std.Error t-value p-value

(Intercept) 24.293605 1.895285 12.817916 0.0000week.factor12 1.135557 1.368533 0.829763 0.4095week.factor24 3.132511 1.300859 2.408034 0.0187

Confidence intervals obtained with the intervals function are:

Approximate 95% confidence intervals

Coefficients:lower est. upper

(Intercept) 20.5126148 24.293605 28.074595week.factor12 -1.5945904 1.135557 3.865705week.factor24 0.5373693 3.132511 5.727654

As appears mean AIX has increased significantly from baseline to end point, corresponding toa mild worsening in the patient population overall. This may seem a bit of a surprise but afterallchronic kidney disease is a severe illness which is difficult to treat.

Type 3 tests: If you’d rather test the hypothesis H0 : µ1 = µ2 = µ3, i.e. that no changes inmeans whatsoever occur over time. This is exactly what you get from the type 3 test using theanova-function:

Denom. DF: 69numDF F-value p-value

(Intercept) 1 164.29898 <.0001week.factor 2 3.02076 0.0553

Note the usual limitation of the type 3 test: If the hypothesis is rejected, further comparisonswould be needed to investigate between which particular time points significant differences oc-cur. If you want to perform these pairwise comparisons, I would recommend that you skip theinitial type 3 test and make proper adjustment for multiple testing.

As to the exemplified analysis you might wonder why no significant effect of time is found.It seems like a contradiction since we just noted a significant change from baseline to end point.However, making the specific comparison between baseline and end point (where the largestchange was anticipated) is a more powerfull test. Don’t forget that lack of evidence is not thesame as lack of effect (and that the CKD study was in fact underpowered).

14

Page 15: Analyzing baseline follow-up studies with the nlme-package in Rstaff.pubhealth.ku.dk/~jufo/courses/rm2018/ckd_demo_R.pdf · 2018. 11. 14. · Analyzing baseline follow-up studies

Additional interesting output

Residualplots are useful for checking the modeling assumption that data follows a multivariatenormal distribution and for detecting outliers in the data. Here I look at the pearson residualswhich are most directly comparable to the standard normal distribution (in QQplots and histo-grams). Note that a large pearson residual (either positive or negative) indicates that the outcomeis far from the expected mean outcome in the population. To identify which subjects the out-lying residuals belong to, you can match its position in the residual vector with the original data.Note, however, that the most extreme outliers should be obvious already in the spaghettiplotswhich are easier to interpret since data is shown on its original scale.

Figur 6: Pearson residuals from the oneway ANOVA type mixed model analysis.

As appears from the plots, the residuals from the CKD study comply well with the normal di-stribution save for a few not all to extreme values. Going back to the spaghettiplot (recall thatwe have restricted the analysis to the control group), we note one person who has a smallerAIX value at baseline compared to the others and one who has a larger value after 12 weekscompared to the others and to himself at the two other occations. If we checked the output datawe would find that these are also the observations giving rise to the most extreme residuals.According to the investigators the outliers are compatable with the natural variation in diseaseprogression and we decide that they do not compromise the validity of the statistical analysissince they are neither erroneous nor extreme to an extent that will seriously influence the sta-tistical results. If natural but more extreme outliers had occured, a possibility would be to dosensitivity analysis including and excluding them to check how results were affected. Erroneousoutcomes, of course, would have to be corrected or deleted.

Covariance and correlation matrices: The covariance parameters are usually of secondaryinterest to the mean parameters in linear mixed models analysis. The reasons why we want tocheck on them anyway are:

• To better understand linear mixed models and multivariate normal distributions.

15

Page 16: Analyzing baseline follow-up studies with the nlme-package in Rstaff.pubhealth.ku.dk/~jufo/courses/rm2018/ckd_demo_R.pdf · 2018. 11. 14. · Analyzing baseline follow-up studies

• To use them in power calculations for future studies.

• Implausible values indicate errors in the data or the program.

The estimated covariance matrix from the CKD study control groups is what you get fromapplying getVarCov to the gls model object:

Marginal variance covariance matrix[,1] [,2] [,3]

[1,] 88.570 63.541 67.23[2,] 63.541 74.143 64.07[3,] 67.230 64.070 88.57

Standard Deviations: 9.4112 8.6106 9.4112

Note that the standard deviations corresponding to the variances in the diagonal have beenoutputted just below. If you would rather see the correlations than the covariances, these arepart of the output we got from the summary function. Note that a correlation matrix alwayshave 1’s in the diagonal and that it is symmetric. Here it has been simplified so that only thenon-trivial parts of the correlation matrix is outputted:

Correlation Structure: GeneralFormula: ~week | idParameter estimate(s):Correlation:1 2

2 0.7843 0.759 0.791

As appears the correlation between AIX from neighbouring visits are just below 80% whilethe correlation between the baseline and end point AIX is roughly 75%. Please note that theestimated standard deviations and correlations are similar but not exactly identical to thosewe found when computing summary statistics. This is due to missing data which is implicitlyimputed by gls under a missing at random assumption. I will discuss missing data in detail inlecture 6.

Predicted population means: R code to plot the estimated trend in population means from theCKD study is contained in the program file. Here I omit the picture due to lack of space.

16

Page 17: Analyzing baseline follow-up studies with the nlme-package in Rstaff.pubhealth.ku.dk/~jufo/courses/rm2018/ckd_demo_R.pdf · 2018. 11. 14. · Analyzing baseline follow-up studies

2. Analysis of parallel group studies

In a parallel group study two homogeneous populations are followed over time and the researchinterest is to compare systematic changes in the outcome between the groups. From a statisticalpoint of view this means that we wish to compare population means between different groupsand time points while acknowledging the correlation in the repeated measurements on the thesame subject.

Here I will illustrate the analysis using data from the CKD study pretending that this was anobservational study. That is, we pretend that treatments weren’t randomized. This implies thatthe two patient groups might differ substantially already at baseline and as part of the analysiswe will estimate the difference between the two population means at baseline as well as thedifference in changes in means over time between the groups.

Occation Population mean with standard treatment Population mean with Eplerenoneweek=0 µ1 = β0 µ4 = β0 +β1week=12 µ2 = β0 +β2 µ5 = β0 +β1 +β2 +β4week=24 µ3 = β0 +β3 µ6 = β0 +β1 +β3 +β5

Tabel 2: Population means (µ) over time in assumed non-randomized treatment groups witheither standard treatment or eplerenone. Differences in means, changes over time, and differen-ces in changes over time are described by the regresssion parameters β1 – β5 with the baselinemean in the population receiving standard treatment is the intercept (β0).

To perform the analysis we specify a linear mixed model with group (treatgroup in theCKD study) and occation (week in the CKD study) as categorical covariates like in a twowayANOVA model. Please note that we are particularly interested in the group-occation intera-ction (treatgroup*week) as this reflects a potential difference in time evolution betweenthe groups. To account for the correlation in the data as well as possible changes in varian-ces/standard deviations over time we specify an unstructured covariance pattern.

R program

The program for analyzing parallel group studies differs only slightly from that used to analyzesingle group studies:

• Both group (treatgroup), time (week), and their interaction (treatgroup:week)must be included in the model formula. I am using the R shortcut treatgroup*weekto get them all in one.

Besides this the R program is similar. I refer to section 1 on single group studies for furtherexplanation of both the code and the output.

library(nlme)

17

Page 18: Analyzing baseline follow-up studies with the nlme-package in Rstaff.pubhealth.ku.dk/~jufo/courses/rm2018/ckd_demo_R.pdf · 2018. 11. 14. · Analyzing baseline follow-up studies

ckdlong$treatgroup <- factor(ckdlong$treatgroup)ckdlong$id <- factor(ckdlong$id)

fit2 <- gls(aix~treatgroup*week,data=ckdlong,correlation=corSymm(form=~visit|id),weights=varIdent(form=~1|visit),na.action=na.exclude,control=glsControl(opt=’optim’))

summary(fit2) # model summaryintervals(fit2) # estimates and confidence intervalsanova(fit2, type=’marginal’) # type 3 testsgetVarCov(fit2) # estimated covariance matrix

# Residualplotspar(mfrow=c(1,2))plot(fitted(fit2), residuals(fit2, type=’pearson’))abline(h=0)qqnorm(residuals(fit2, type=’pearson’))abline(0,1)

Among the non-essential but sometimes useful output I have included type 3 test of interaction,estimated covariance and correlation matrices, estimated standard deviations, and residual plots.To make a plot comparing the predicted population means between the two groups use:

pred2 <- expand.grid(visit=c(1,2,3), treatgroup=c(0,1))pred2$week <- factor(pred2$visit, labels=c(0,12,24))pred2$treatgroup <- factor(pred2$treatgroup)pred2 <- cbind(pred2, pred=predict(fit2, newdata=pred2))

xyplot(pred~week.factor, group=treatgroup, data=pred2, type=’b’)

An note on confounders and other covariates

If differences between parallel groups are found, one would very often be interested in whetherthese persisted when controlling for potential confounders. E.g., still pretending that the CKDstudy wasn’t randomized, we could add age and gender as explanatory variable to the linearmixed model by changing the model formula to:

aix ~ sex age week*treatgroup

Don’t forget that sex must also be made into a factor since it is a categorical covariate. Againfor the sake of a short introduction I am omitting the output from this analysis. However, if youplan to apply a similar analysis to your own data, please pay attention to the model fit. When

18

Page 19: Analyzing baseline follow-up studies with the nlme-package in Rstaff.pubhealth.ku.dk/~jufo/courses/rm2018/ckd_demo_R.pdf · 2018. 11. 14. · Analyzing baseline follow-up studies

adding more covariates to the linear mixed model you should worry whether the model is wellspecified just as you would with an ordinary linear model, i.e. that the effect of the continuouscovariate age is linear (plot the residuals in the output dataset against age to check) and that nosubstantial interactions between the covariates have been neglected. Finally, it should be notedthat timevarying confounders in longitudinal studies must be handled with great care to avoidbias. I recommend you consult with a statistician about this matter.

The most important parts of the output

Model specification and convergence: At first I make fast check of the output from summary.Just as I did with the single group study.

Generalized least squares fit by REMLModel: aix ~ treatgroup * weekData: ckdlong

...

Correlation Structure: GeneralFormula: ~visit | id...

Variance function:Structure: Different standard deviations per stratum

It seems that I managed to apply the intended mixed model with the unstructured covariance tothe right outcome in the right dataset, so I proceed to interpreting the results of the analysis.

Estimates and confidence intervals: The treatgroup effect in the twoway ANOVA typemodel describes the difference between the two patient groups at baseline (which is referencepoint for week). The week effect in the twoway ANOVA type model describes the changessince baseline in the standard treatment group (which is reference point for treatgroup).And finally the interaction effect describes the difference in changes since baseline between theEplerenone and the standard treatment group (the differences of the differences).

Coefficients:Value Std.Error t-value p-value

(Intercept) 24.343158 2.077557 11.717204 0.0000treatgroup -2.054697 2.898428 -0.708900 0.4796week12 1.088695 1.765897 0.616511 0.5386week24 3.089461 1.496081 2.065036 0.0408treatgroup:week12 -1.949151 2.482321 -0.785213 0.4337treatgroup:week24 -3.607859 2.123233 -1.699229 0.0915

19

Page 20: Analyzing baseline follow-up studies with the nlme-package in Rstaff.pubhealth.ku.dk/~jufo/courses/rm2018/ckd_demo_R.pdf · 2018. 11. 14. · Analyzing baseline follow-up studies

The approximate 95% confidence intervals we get from intervals are:

Coefficients:lower est. upper

(Intercept) 20.2351979 24.343158 28.451119treatgroup -7.7857695 -2.054697 3.676376week12 -2.4030193 1.088695 4.580410week24 0.1312542 3.089461 6.047668treatgroup:week12 -6.8574519 -1.949151 2.959151treatgroup:week24 -7.8061353 -3.607859 0.590417

As appears mean AIX is somewhat smaller in the Eplerenone group at baseline, but the dif-ference is not significant (non-surprisingly as groups were in fact randomized, but we are stillpretending they aren’t). We note a non-significant increase in mean AIX from baseline to 12weeks in the standard treatment group, and a significant one from baseline to 24 weeks. Theestimated interaction terms tells us that mean AIX changed substantially less in the Eplerenonegroup over time. In fact, when adding up the numbers, we can tell that mean AIX decreasedslightly from baseline to 12 and 24 weeks, repectively. However, the mean changes over timedo not differ significantly between the groups.

To conclude:Patients who received Eplerenone on average had a seemingly better outcome already at base-line and tended to improve slightly with time in contraty to patients on standard treatment whoexperienced a worsening in AIX over time. Still, no significant differences were found betweenthe groups. Larger studies are needed to reach certain conclusions.

Please note that we have to be careful not to base too strong conclusions on the tests since thestudy was underpowered and confidence intervals are overall wide. Also R is still not makingsmall sample to the degrees of freedom so p-values and confidence intervals are slightly anti-conservative . . .

It would be nice to have estimates and confidence intervals also for the changes over time withinthe Eplerenone group. Although they are not in this output, we could get them by changing thereference point for treatgroup to 1 (using the relevel function).

Type 3 tests: If you’d rather test the hypothesis H0 : No intercation, i.e. that changes in meansover time are similar between the groups, the type 3 test shows a non-significant p-value:

Denom. DF: 138numDF F-value p-value

(Intercept) 1 137.29288 <.0001treatgroup 1 0.50254 0.4796week 2 2.42494 0.0922treatgroup:week 2 1.47567 0.2322

20

Page 21: Analyzing baseline follow-up studies with the nlme-package in Rstaff.pubhealth.ku.dk/~jufo/courses/rm2018/ckd_demo_R.pdf · 2018. 11. 14. · Analyzing baseline follow-up studies

This implies that, in principle, you could delete the interaction from the model and proceed totest the main effects. However, since the interest of the study was to describe the potentiallydifferent time evolutions in the two groups, I would rather report the non-significant differenceswith confidence intervals.

Additional interesting output

Residual plots: Like in the analysis of the single group study, we inspect the residualplots of thepearson residuals to judge the validity of the modeling assumptions and our statistical results.

Figur 7: Pearson residuals from the twoway ANOVA type mixed model analysis.

Compared to the analysis of the control group alone, more negative pearson residuals appearin the plots but otherwise the residuals comply well with the normal distribution. We identifyall but two of the outlying residuals with data from two persons in the Eplerenone group whohad small augmentation indices already at baseline. These patients might be somewhat atypicalbut since the fulfilled the inclusion criteria, they should not be deleted from the analysis. If asignificant difference had occured at baseline, we might have performed a sensitivity analysisto check that the result did not rely solely on these two atypical patients.

Predicted means: Finally, I have made a plot showing the estimated trend in population meansfrom the two groups. This I use as a visual aid when interpreting the estimates from the analysis.

21

Page 22: Analyzing baseline follow-up studies with the nlme-package in Rstaff.pubhealth.ku.dk/~jufo/courses/rm2018/ckd_demo_R.pdf · 2018. 11. 14. · Analyzing baseline follow-up studies

Figur 8: Predicted population means from the twoway ANOVA-type mixed model analysis.

3. Analysis of randomized group studies

In a randomized group study several random samples are initially drawn from a single ho-mogeneous population. After application of different treatments their outcomes are collectedover time. Most randomized studies further include a baseline measurement which contains theoutcome prior to initiation of treatment. The research interest in such a study is to comparesystematic changes in the outcome between the treatments as any signficant difference foundwill be evidence of a difference in treatment effects (causal ones due to the randomization).Note that if no baseline measurement is collected, we cannot evaluate changes since baselineand analysis will proceed like a parallel group study (since the outcomes may differ betweenthe groups already at the first occation due to the different treatments).

From a statistical point of view we again wish to compare population means between differentgroups and time points while acknowledging the correlation in the repeated measurements onthe the same subject.

Here I will illustrate the analysis using data from the CKD study. As treatments were rando-mized, this is the proper and statistically optimal analysis from which we would want to publishthe results. The constrained linear mixed model for randomized studies only differs from thetwoway ANOVA type model for parallel groups studies in one aspect: It only needs one para-meter to describe the population means at baseline (since all random samples are drawn fromthe same population they must share the same true population mean).

22

Page 23: Analyzing baseline follow-up studies with the nlme-package in Rstaff.pubhealth.ku.dk/~jufo/courses/rm2018/ckd_demo_R.pdf · 2018. 11. 14. · Analyzing baseline follow-up studies

Occation Population mean with standard treatment Population mean with Eplerenoneweek=0 µ1 = β0week=12 µ2 = β0 +β1 µ4 = β0 +β1 +β3week=24 µ3 = β0 +β2 µ5 = β0 +β2 +β4

Tabel 3: Population means (µ) over time in assumed randomized treatment groups with eitherstandard treatment or eplerenone. Differences in means, changes over time, and differences inchanges over time are described by the regresssion parameters β1 – β4 with the baseline meanin the patient population as intercept (β0).

To perform the constrained analysis a couple of computational tricks are needed. First we haveto add a new variable to the data (in the long format), one which contains the duration ofEplerenone treatment. In the Eplerenone group this will be identical to the old variable week,while in the control group this must be set to zero at all occations. To add the new variable(called treat1week) to the data use:

ckdlong$treat1week <- 0ckdlong$treat1week[ckdlong$week==12 & ckdlong$treatgroup==1] <- 12ckdlong$treat1week[ckdlong$week==24 & ckdlong$treatgroup==1] <- 24ckdlong$treat1week <- factor(ckdlong$treat1week)

Note that if there had been more treatments involved in the study. New variables should beconstructed for all other treatments than the control. After adding the new variable, the longdata from id=1 and id=3 looks like this. Please note the difference wrt the week varable!

id week sex age treatgroup treat1week aix1 0 1 57 0 0 10.51 12 1 57 0 0 17.51 24 1 57 0 0 25.03 0 2 54 1 0 183 12 2 54 1 12 243 24 2 54 1 24 23.5

Next we have to fit the constrained linear mixed model with the gls function using the novelvaraible we have created in place of the old group variable and the interaction. To account forthe correlation in the data as well as possible changes in variance/standard deviation over timewe again specify an unstructured covariance pattern.

R program

The program for analyzing randomized group studies differs from that used to analyze parallelgroup studies in two regards:

• The time-variable (week) enter as a covariate in the model formula, but the main termtreatgroup must be omitted.

23

Page 24: Analyzing baseline follow-up studies with the nlme-package in Rstaff.pubhealth.ku.dk/~jufo/courses/rm2018/ckd_demo_R.pdf · 2018. 11. 14. · Analyzing baseline follow-up studies

• The variable (treat1week) is used in place of the interaction term (treatgroup:week).

Besides this the R code is similar to that for the single and parallel group studies. I refer tosections 1 and 2 for further explanation.

fit3 <- gls(aix~week+treat1week,data=ckdlong,correlation=corSymm(form=~visit|id),weights=varIdent(form=~1|visit),na.action=na.exclude,control=glsControl(opt=’optim’))

summary(fit3) # model summaryintervals(fit3) # estimates and confidence intervalsanova(fit3, type=’marginal’) # type 3 testsgetVarCov(fit3) # estimated covariance matrix

# Residualplotspar(mfrow=c(1,2))plot(fitted(fit3), residuals(fit3, type=’pearson’))abline(h=0)qqnorm(residuals(fit3, type=’pearson’))abline(0,1)

Among my output I include the summary from the model, confidence intervals, the type 3 test,the estimated covariance and correlation matrices, and residualplots.

To save the predicted population means in an output dataset and make a plot comparing thembetween the groups, I use the following code which is rather labourous since the variabletreat1week must be constructed once more.

pred3 <- expand.grid(visit=c(1,2,3), treatgroup=c(0,1))pred3$week <- factor(pred3$visit, labels=c(0,12,24))pred3$treatgroup <- factor(pred3$treatgroup)

pred3$treat1week <- 0pred3$treat1week[pred3$week==12 & pred3$treatgroup==1] <- 12pred3$treat1week[pred3$week==24 & pred3$treatgroup==1] <- 24pred3$treat1week <- factor(pred3$treat1week)

pred3 <- cbind(pred3, pred=predict(fit3, newdata=pred3))

xyplot(pred~week, group=treatgroup, data=pred3, type=’b’)

24

Page 25: Analyzing baseline follow-up studies with the nlme-package in Rstaff.pubhealth.ku.dk/~jufo/courses/rm2018/ckd_demo_R.pdf · 2018. 11. 14. · Analyzing baseline follow-up studies

The most important parts of the output

Model specification and convergence: At first I take a quick look at the summary. I seemsthat I managed to apply the intended mixed model with the unstructured covariance to the rightoutcome in the right dataset.

Generalized least squares fit by REMLModel: aix ~ week + treat1weekData: ckdlong

...

Correlation Structure: GeneralFormula: ~visit | id...

Variance function:Structure: Different standard deviations per stratum

Estimates and confidence intervals: The week effect in the contrained linear mixed modeldescribes the mean expected changes after initiation of standard treatment. The new variabletreat1weeks describes the expected differences in changes since baseline between the ep-lerenone and the standard treatment (the differences of the differences). Note that compared tothe twoway ANOVA type model there is no main term for treatment. We know that any dif-ferences between the groups at baseline are solely due to random sampling. Hence, we do notwish to estimate the true differences between the population means at baseline since we knowit is zero.

Coefficients:Value Std.Error t-value p-value

(Intercept) 23.287861 1.442308 16.146249 0.0000week12 1.201534 1.757492 0.683664 0.4953week24 3.360855 1.444983 2.325878 0.0215treat1week12 -2.154717 2.463749 -0.874568 0.3833treat1week24 -4.124803 1.993086 -2.069556 0.0403

Using the intervals function we obtain the approximate 95% confidence intervals:

Coefficients:lower est. upper

(Intercept) 20.4361625 23.287861 26.1395604week12 -2.2733398 1.201534 4.6764075week24 0.5038658 3.360855 6.2178439treat1week12 -7.0259874 -2.154717 2.7165528treat1week24 -8.0654892 -4.124803 -0.1841172

25

Page 26: Analyzing baseline follow-up studies with the nlme-package in Rstaff.pubhealth.ku.dk/~jufo/courses/rm2018/ckd_demo_R.pdf · 2018. 11. 14. · Analyzing baseline follow-up studies

We note a non-significant increase in mean AIX from baseline to 12 weeks in the standard tre-atment group, and a significant one from baseline to 24 weeks. The estimated interaction termstells us that mean AIX changed substantially less in the Eplerenone group over time. In fact,when adding up the numbers, we can tell that mean AIX decreased slightly from baseline to12 and 24 weeks, repectively. The mean changes over time differ significantly between the twotreatments at final follow-up with a p-value of 4%.

To conclude:A significant difference in treatment effect was found in favour of Eplerenone (P=0.04). Patientswho received Eplerenone on average had a seemingly better outcome and tended to improveslightly with time in contrary to patients on standard treatment who had experienced a wor-sening in AIX at final follow-up. However, the confidence interval for the difference betweenthe treatments is wide and larger studies are needed to reach a certain conclusion about thesuperiority of Eplerenone.

Note that, even though the higher power of the constrained linear mixed model flips the p-value in favour of Eplerenone, we still have to be careful not to base too strong conclusions onthe tests since the study was underpowered and confidence intervals are overall wide. More-over, R is still unable to do small sample corrections to the degrees of freedom which makes thep-values and confidence intervals slightly anti-conservative. This is unfortunate in this situationwhere we have a p-value which is just below 5% . . .

It would be nice to have estimates and confidence intervals also for the changes over time withinthe Eplerenone group. Although they are not in this output, we could get them by changing thereference point for the treatment to the control group.

Type 3 tests: If you’d rather test the hypothesis H0 : No intercation, i.e. that changes in me-ans over time are similar between the treatments at all occations, then look at the output fromthe type 3 tests:

Denom. DF: 139numDF F-value p-value

(Intercept) 1 260.70135 <.0001week 2 3.08312 0.0490treat1weeks 2 2.22321 0.1121

Since the presumed beneficial effect of Eplerenon was not expected to show untill after the full24 weeks of treatment, it is not surprising that this less powerful test come out with a p-valuethat is larger than the one we get from evaluating the treatment at final follow-up.

Additional interesting output

Residual plots: Like in the analysis of the single and parallel group study, we inspect theresidualplots of the pearson residuals to judge the validity of the modeling assumptions and ourstatistical results.

26

Page 27: Analyzing baseline follow-up studies with the nlme-package in Rstaff.pubhealth.ku.dk/~jufo/courses/rm2018/ckd_demo_R.pdf · 2018. 11. 14. · Analyzing baseline follow-up studies

Figur 9: Pearson residuals from the constrained linear mixed model analysis.

Appearantly the residualplots are almost identical to the ones we found in the analysis of thetwoway ANOVA type model for parallel group studies. This is not all to surprising since thetwo models are identical in all but one regards and since they are applied to the exact same data.The most outlying residuals belong to the same subjects that we have previously considered andfor the same reasons. Hence, I refer to sections 1 and 2 for further explanation.

Figur 10: Predicted population means from the constrained linear mixed model analysis.

Predicted means: Finally, I have made a plot showing the estimated trend in population me-ans from the two treatment groups. From this the difference between the twoway ANOVA typelinear mixed model for parallel group studies and the constrained linear mixed model for ran-domized groups studies should be obvious. Compared with the similar figur in section 2 thetwo curves now start out in the same point. This confirms that I have managed to specify theconstrained model correctly.

27


Recommended