Title: | Fidelity patterns in simulation experiments for cluster randomized trials in implementation science research |
---|---|
Description: | The package provides functions to coduct simulation experiments for investigating the performance of effect estimation within parallel/stepped-wedged cluster randomized trials under consideration of implementation error (measured by fidelity). |
Authors: | Diana Trutschel [aut] |
Maintainer: | Catherine Blatter <[email protected]> |
License: | CC BY 4.0 |
Version: | 0.1.1 |
Built: | 2025-02-17 05:30:56 UTC |
Source: | https://github.com/INS-Basel/fidelitysim |
Calculation of performance measure of estimation: Bias as the difference between the estimated and actual values
bias(vec, theta)
bias(vec, theta)
vec |
Estimated value from simulation |
theta |
True value |
Bias of effect estimation
Calculation of all points in between a given start point and end point for a given total number of points
calc.X.values(x.B, x.E, time.points)
calc.X.values(x.B, x.E, time.points)
x.B |
starting point (begin) |
x.E |
end point |
time.points |
number of points on total |
all exact points
Simulate a loss of data points within a full study data obtained within I clusters and observed over K time points
Data.loss.SWD(data.all, I, K, B = "0", C = 0, D = 0)
Data.loss.SWD(data.all, I, K, B = "0", C = 0, D = 0)
data.all |
given data of a study (can be simulated or obtained) |
I |
Number of clusters within the study |
K |
Number of time points within the study |
B |
Type of cluster loss: 0 = No cluster loss, 1 = Cluster missing at random, 2 = Cluster is missing at beginning, 3 = Cluster is missing at end of the study |
C |
Number of clusters which getting lost |
D |
Number of individual loss (chosen randomly from all individuals within the study) |
Matrix of data which is remained after data loss
Calculates for given start Fidelity and end Fidelity the within Fidelity for a given number of time points using an exponential function, where with the par.slope stretching and compression of the function can be influenced. Here the exponential function is derived as the reflection of the logarithm function on the straight line par.slope has to be greater than 0, near zero then the values are almost constant, the greater then the values are going against the linear line
find.Fidelity.exp(time.points, Fid.End, Fid.T1, par.slope = 1)
find.Fidelity.exp(time.points, Fid.End, Fid.T1, par.slope = 1)
time.points |
number of time points |
Fid.End |
Fidelity at the end (final time point) |
Fid.T1 |
Fidelity at the begin (starting time point) |
par.slope |
Slope for the logarithmic function has to be greater 0, the greater towards 1 the more linear is the function |
a matrix: first column with time points, second column corresponding Fidelity for the time points
calculates for given start Fidelity and end Fidelity the within Fidelity for a given number of time points using a linear function
find.Fidelity.linear(time.points, Fid.End, Fid.T1)
find.Fidelity.linear(time.points, Fid.End, Fid.T1)
time.points |
number of time points |
Fid.End |
Fidelity at the end (final time point) |
Fid.T1 |
Fidelity at the begin (starting time point) |
a matrix: first column with time points, second column corresponding Fidelity for the time points
Calculates for given start Fidelity and end Fidelity the within Fidelity for a given number of time points using a logarithmic function to approximate Fidelity in between, where with the par.slope stretching and compression of the function can be influenced. par.slope has to be greater than 0, near zero then the values are almost constant, the greater then the values are going against the linear line.
find.Fidelity.log(time.points, Fid.End, Fid.T1, par.slope = 1)
find.Fidelity.log(time.points, Fid.End, Fid.T1, par.slope = 1)
time.points |
number of time points |
Fid.End |
Fidelity at the end (final time point) |
Fid.T1 |
Fidelity at the begin (starting time point) |
par.slope |
Slope for the logarithmic function has to be greater 0, the greater towards 1 the more linear is the function |
a matrix: first column with time points, second column corresponding Fidelity for the time points
Given a design of a hypothetical cluster randomized stepped wedge study and their pattern of fidelity over time conduct the function the corresponding design matrix which can be used for linear regression modeling
implemMatrix.crossover(nC, nT, nSw, swP = NULL, pattern)
implemMatrix.crossover(nC, nT, nSw, swP = NULL, pattern)
nC |
Number of cluster |
nT |
Number of time points |
nSw |
Number of cluster with switches from control condition 0 to treatment condition 1 at each time point |
swP |
Number of timepoints the for clusters be at control |
pattern |
Fidelity pattern (deviation from 1) for each time point |
Design matrix of size nT x nC for a cross-over cluster randomized trial with values of 0 for control condition and values between 0 and 1 for degree of implementation of treatment (fidelity)' @return
Given a design of a hypothetical cluster parallel randomized study and their pattern of fidelity over time conduct the function the corresponding design matrix which can be used for linear regression modeling
implemMatrix.parallel(nC, nT, nSw, pattern)
implemMatrix.parallel(nC, nT, nSw, pattern)
nC |
Number of cluster |
nT |
Number of time points |
nSw |
Number of cluster with control condition 0 (nC-nSw is then the number of cluster with treatment condition 1) |
pattern |
Fidelity pattern (deviation from 1) for each time point |
Design matrix of size nT x nC for a parrallel cluster randomized trial with values of 0 for control condition and values between 0 and 1 for degree of implementation of treatment (fidelity)
Calculation of several performance measure for the estimates obtained from the simulation repeats
performanceMeas(vecEst, vecSe, vec.p, theta, alpha = 0.05)
performanceMeas(vecEst, vecSe, vec.p, theta, alpha = 0.05)
vecEst |
vector of estimated effect values from simulation repeats |
vecSe |
vector of estimated standard error from simulation repeats |
vec.p |
vector of significance (probability of being sampled from null hypothesis) from simulation repeats |
theta |
true value for effect |
alpha |
Type I error rate = significance level for testing the null hypothesis |
Vector of Performance measures:
Average of the estimates of the parameter of interest
Empirical standard error as an assessment of the estimation uncertainty
Bias = mean deviation of the estimates from the true value of the parameter of interest is an indicator of accuracy
Coverage of a confidence interval is a measurement that can be used to control the Type I error
Empirical power = the proportion of simulation samples in which the H0 of no effect is rejected at a significance level when H0 is false
Simulation for ?????? Repeats anzSim times the following steps
Determining the design matrix regarding the chosen design (Design, Number of cluster, time points, individuals) knowing Fidelity pattern and possible data loss
Sample data of the given study design and expected data loss using the package "samplingDataCRT"
Estimation of Effects using linear mixed model estimation
simulation( anzSim, type, sigma.1, sigma.2 = NULL, sigma.3, K, J, I, mu.0, theta, betas, X, X.A, B.cond = "0", C.cond = 0, D.cond = 0 )
simulation( anzSim, type, sigma.1, sigma.2 = NULL, sigma.3, K, J, I, mu.0, theta, betas, X, X.A, B.cond = "0", C.cond = 0, D.cond = 0 )
anzSim |
Number of simulation repeats |
type |
Study design type = "cross-sec" for cross-sectional or "long" for longitudinal |
sigma.1 |
Within variability or error variance (Hughes&Hussey sigma) |
sigma.2 |
Between individual variance (only used when the individuals are followed over time: longitudinal study) |
sigma.3 |
Between clusters variability (Hughes&Hussey tau) |
K |
Number of time points (measurement) |
J |
Number of Individuals (=individuals per cluster) |
I |
Number of cluster |
mu.0 |
Baseline mean within the model specification |
theta |
Intervention effect |
betas |
Time trend could be included |
X |
Design matrix for building linear model of given ooptimal study |
X.A |
Design matrix for building linear model of sampling real data given real setting |
B.cond |
Condition for type of cluster loss: 0 = No cluster loss, 1 = Cluster missing at random, 2 = Cluster is missing at beginning, 3 = Cluster is missing at end of the study |
C.cond |
Condition for number of clusters which getting lost |
D.cond |
Condition for Number of individual loss (chosen randomly from all individuals within the study) |
Vector of Estimates summaru=ies and performance measures (see function performanceMeas
):
Average of the estimates of the parameter of interest
Empirical standard error as an assessment of the estimation uncertainty
Bias = mean deviation of the estimates from the true value of the parameter of interest is an indicator of accuracy
Coverage of a confidence interval is a measurement that can be used to control the Type I error
Empirical power = the proportion of simulation samples in which the H0 of no effect is rejected at a significance level when H0 is false
Reference for linear model formulation of stepped wedge cluster randomized trials by Hussey and Hughes "Design and analysis of stepped wedge cluster randomized trials", Contemporary Clinical Trials, 2007 https://www.sciencedirect.com/science/article/pii/S1551714406000632 as well as performance measurements for simulation studies by Burton et al. “The design of simulation studies in medical statistics”, Stat Med, 2006 https://pubmed.ncbi.nlm.nih.gov/16947139/