# Assessing a test by seeing if variance between subjects is greater than within subjects

I am assessing a new measure (termed Val) and it's unclear even if it imparts any useful data at this stage. I have data taken from multiple locations within each subject, and I have repeated the measurement some time later at each location. There is therefore an R dataframe that looks as so.

    Patient Location Repeat Val
1         1        1      1  90
2         1        1      2  60
3         1        2      1  90
4         1        2      2  80
5         1        3      1  90
6         1        3      2  90
...
171      10       13      1  90
172      10       13      2 110
173      10       14      1  80
174      10       14      2  70
175      10       15      1  80
176      10       15      2  80


I was thinking a useful test would be seeing if the variances between repeats within locations within patients is lower than:

• variances between locations within patients
• between patients

I thought I would try to do this by fitting a normal linear model, and then mixed models at the 'patient' level, and then the 'location within patient' level, as follows.

> library(lmerTest)
>
> #NON_hierarchical_model <- glm(get(dependent_variable) ~ Condition, data=input_data)
> model_basic <- glm(R50 ~ Repeat, data=df_ims2)
> goodness_of_fit_basic_model <- logLik(model_basic)*-2
>
> # Add patient (ignoring different locations within)
> model_patient <- lmer(R50 ~ Repeat + (1|Patient), REML=FALSE ,data=df_ims2)
>
> table_of_variances <- as.data.frame(VarCorr(model_patient))
> table_of_variances
grp        var1 var2     vcov    sdcor
1  Patient (Intercept) <NA> 183.3986 13.54247
2 Residual        <NA> <NA> 468.2709 21.63957
> variance_of_means <- table_of_variances$vcov[1] > variance_of_individual_datapoints <- (table_of_variances$vcov[1] + table_of_variances$vcov[2]) > icc <- variance_of_means / variance_of_individual_datapoints > icc [1] 0.2814289 > > goodness_of_fit_location_model <- logLik(model_patient)*-2 > improvement_in_goodness_of_fit_location <- goodness_of_fit_basic_model - goodness_of_fit_location_model > betterfit_location <- 1-pchisq(improvement_in_goodness_of_fit_location[1],df=1) > betterfit_location [1] 1.254552e-14 > > # Account for locations within patients > model_location_patient <- lmer(R50 ~ Repeat + (1|Patient/Location), REML=FALSE ,data=df_ims2) > > table_of_variances_2 <- as.data.frame(VarCorr(model_location_patient)) > table_of_variances_2 grp var1 var2 vcov sdcor 1 Location:Patient (Intercept) <NA> 336.6867 18.34902 2 Patient (Intercept) <NA> 157.9312 12.56707 3 Residual <NA> <NA> 151.8574 12.32304 > variance_of_means_2 <- (table_of_variances_2$vcov[1] + table_of_variances_2$vcov[2]) > variance_of_individual_datapoints_2 <- (table_of_variances_2$vcov[1] + table_of_variances_2$vcov[2] + table_of_variances_2$vcov[3])
> icc_2 <- variance_of_means_2 / variance_of_individual_datapoints_2
> icc_2
[1] 0.7650995
>
> goodness_of_fit_location_patient_model <- logLik(model_location_patient)*-2
> improvement_in_goodness_of_fit_location_patient <-  goodness_of_fit_location_model - goodness_of_fit_location_patient_model
> betterfit_location_patient <- 1-pchisq(improvement_in_goodness_of_fit_location_patient[1],df=1)
> betterfit_location_patient
[1] 0


This shows the ICC for repeats within patients (ignoring locations) is around 0.28, and for locations within patients it is around 0.76, and p < 0.0001 for improvement for both models step-wise.

I therefore believe I can say the variance within patients is lower than the variance within patients, and the variance within locations is lower than the variance between locations, within the same patient?

Is this correct and fair?