程序代写案例-MATH5092
时间:2021-05-12
2021/5/12 MATH5092 Mixed Models with Medical Applications
https://minerva.leeds.ac.uk/bbcswebdav/pid-8349912-dt-content-rid-18715700_2/courses/202021_37420_MATH5092M/Exercises MedApp %28with solutions%29.html 1/9
MATH5092 Mixed Models with
Medical Applications
Duncan Wilson (d.t.wilson@leeds.ac.uk)
Tuesday May 04, 2021
20 Further exercises
20.1 SHIFT
SHIFT (Self-Harm Intervention: Family Therapy) was a trial comparing a new family
therapy technique against treatment as usual for young people who self-harm. The
therapy was delivered by a trained therapist in a single session, with the child’s
parents participating. The outcome measure was a self-reported questionnaire
measuring depression, completed by the young person. The outcome is known to
have considerable measurement error associated with it.
2021/5/12 MATH5092 Mixed Models with Medical Applications
https://minerva.leeds.ac.uk/bbcswebdav/pid-8349912-dt-content-rid-18715700_2/courses/202021_37420_MATH5092M/Exercises MedApp %28with solutions%29.html 2/9
Exercise 20.1 What are the potential sources of clustering in the SHIFT trial?
Exercise 20.2 Suppose we limit ourselves to making a single measurement on each
young person, and recruit at most one young person from any one family. What trial
designs could be used? What are the units of randomisation in each case?
Exercise 20.3 Suppose we now allow for multiple young people per family, and
randomise families to treatment arms (thus nesting families in treatment arms).
Suppose further we allocate therapists to young people in such a way as to ensure
therapists are also nested in treatment arms. Ignoring all covariates other than
treatment received, write down a model we could use to analyse the trial data, both
in mathematical notation and using the lmer syntax.
Exercise 20.4 Using this design and analysis, derive an expression for the design
effect when assuming each therapist treats of young people, and each family
contains young people.
Exercise 20.5 Use the design effect to determine the sample size required to have a
type I error rate of (one-sided) and a power of to detect a difference in
means of size given the following variance components:
Exercise 20.6 After data collection, a Bayesian analysis gives posterior samples for
the three variance components and . Based on these, give an expression
for an estimate of the posterior probability that the correlation between the outcomes
of two young people who share a therapist but not a family is greater than .
Solution to exercise 20.1
10
2
0.025 0.8
δ = 2
= 2, = 7, = 1.σ
2
u
σ
2
v
σ
2
e

2
u
σ
2
v
σ
2
e
0.1
2021/5/12 MATH5092 Mixed Models with Medical Applications
https://minerva.leeds.ac.uk/bbcswebdav/pid-8349912-dt-content-rid-18715700_2/courses/202021_37420_MATH5092M/Exercises MedApp %28with solutions%29.html 3/9
There are three potential sources of clustering.
1. The therapist. We might expect there to be some variability in the average
outcomes of therapists, given their varying levels of experience and ability.
2. The family. It is possible that the trial recruits two or more young people from
the same family. If this happens, we might expect the outcomes of these
young people to be correlated with each other.
3. The young person. The fact that the outcome is acceptable to measurement
error suggests repeated measures could be taken. In this case, the young
people can be thought of as clusters with the individual measures made on a
young person correlated with each other.
Note that the data structure may be non-hierarchical. If both therapist an family are
clusters, observations at the young person level may be cross-classified with these.
There does not seem to be any possibility of a multiple membership structure since it
is unlikely that a young person will move between families over the course of the
trial, and the fact that treatment is delivered in a single session means they will not
see more than one therapist.
Solution to exercise 20.2
The main choices we have are between a crossed and nested design with respect
to therapists.
2021/5/12 MATH5092 Mixed Models with Medical Applications
https://minerva.leeds.ac.uk/bbcswebdav/pid-8349912-dt-content-rid-18715700_2/courses/202021_37420_MATH5092M/Exercises MedApp %28with solutions%29.html 4/9
In a crossed design we randomise young people to receive the therapy or treatment
as usual. We then allocate therapists to young people such that each therapist treats
young people in both arms of the trial. A crossed design will be more efficient than a
nested design, but may suffer from contamination.
In a nested design we randomise the therapists to the intervention or control arm,
and then allocate young people to therapists. A nested design will require a larger
sample size than a crossed design, but will eliminate the threat of contamination.
Solution to exercise 20.3
We could model the outcome of the -th young person in arm as
where is a binary indicator of treatment, the functions give the
therapist and family of the -th young person, and all the random effects are normally
distributed and independent:
In R we would use
lmer(y ~ trt + (1 | u) + (1 | v))
i k
= + + + + ,y
ik
β
0
β
1
x
k
u
t(ik)
v
f(ik)
e
ik
x
k
t(ik), f(ik)
i
∼ N(0, ),     ∼ N(0, ),     ∼ N(0, ).u
jk
σ
2
u
v
lk
σ
2
v
e
ik
σ
2
e
∼ N (0, + /n)e
ik
σ
2
e
σ
2
z
2021/5/12 MATH5092 Mixed Models with Medical Applications
https://minerva.leeds.ac.uk/bbcswebdav/pid-8349912-dt-content-rid-18715700_2/courses/202021_37420_MATH5092M/Exercises MedApp %28with solutions%29.html 5/9
where u and v are variables recording the therapist and family of each young
person.
Solution to exercise 20.4
First, we need to derive an expression for the sample mean in each arm. Denote by
the total number of young people in each arm. Then
since we can get rid of the fixed effects and all the sets of random effects are
independent of each other. Moreover, the individual sets of random effects are
independent. Denote the number of young people seen by therapists by and the
number of young people in each family by , and denote the number of therapists
and families by . Then,
N
var( )
1
N

i=1
N
y
ik
= var( + + + + )
1
N
2

i=1
N
β
0
β
1
x
k
u
t(ik)
v
f(ik)
e
ik
= [var( )+ var( )+ var( )] ,
1
N
2

i=1
N
u
t(ik)

i=1
N
v
f(ik)

i=1
N
e
ik
n
t
n
f
,m
t
n
t
2021/5/12 MATH5092 Mixed Models with Medical Applications
https://minerva.leeds.ac.uk/bbcswebdav/pid-8349912-dt-content-rid-18715700_2/courses/202021_37420_MATH5092M/Exercises MedApp %28with solutions%29.html 6/9
To use this expression to obtain a design effect, we want to first multiply it by
(since the variance of the sample mean difference is just the sum of the sample
mean variance in each arm due to the nested design), and divide it by the variance
of the sample mean difference if clustering were ignored. The latter is
where . Putting the above expression in terms of gives
var( )
1
N

i=1
N
y
ik
= [var( )+ var( )+ var( )]
1
N
2

i=1
N
u
t(ik)

i=1
N
v
f(ik)

i=1
N
e
ik
= [var( )+ var( )+ var( )]
1
N
2

j=1
m
t
n
t
u
t(ik)

j=1
m
f
n
f
v
f(ik)

i=1
N
e
ik
= [ var( ) + var( ) + var( )]
1
N
2

j=1
m
t
n
2
t
u
t(ik)

j=1
m
f
n
2
f
v
f(ik)

i=1
N
e
ik
= [ + +N ]
1
N
2
m
t
n
2
t
σ
2
u
m
f
n
2
f
σ
2
v
σ
2
e
= [ + + ] .
1
N
n
t
σ
2
u
n
f
σ
2
v
σ
2
e
2
,

2
N
= + +σ
2
σ
2
u
σ
2
v
σ
2
e
σ
2
var( )
1
N

i=1
N
y
ik
= [ + + ]
1
N
n
t
σ
2
u
n
f
σ
2
v
σ
2
e
= [1 + + ] ,
σ
2
N
( − 1)n
t
σ
2
u
σ
2
( − 1)n
f
σ
2
v
σ
2
2021/5/12 MATH5092 Mixed Models with Medical Applications
https://minerva.leeds.ac.uk/bbcswebdav/pid-8349912-dt-content-rid-18715700_2/courses/202021_37420_MATH5092M/Exercises MedApp %28with solutions%29.html 7/9
so the design effect is
Solution to exercise 20.5
Using the numbers provided, the design effect works out as
We can find the number of young people required in each arm if clustering is ignored
using R:
power.t.test(n = NULL, delta = 2, sd = sqrt(10), power = 0.8, alt
ernative = "one.sided", sig.level = 0.025)
1 + + .
( − 1)n
t
σ
2
u
σ
2
( − 1)n
f
σ
2
v
σ
2
1 + + = 3.5.
(10 − 1) × 2
10
(2 − 1) × 7
10
2021/5/12 MATH5092 Mixed Models with Medical Applications
https://minerva.leeds.ac.uk/bbcswebdav/pid-8349912-dt-content-rid-18715700_2/courses/202021_37420_MATH5092M/Exercises MedApp %28with solutions%29.html 8/9
##
## Two-sample t test power calculation
##
## n = 40.22769
## delta = 2
## sd = 3.162278
## sig.level = 0.025
## power = 0.8
## alternative = one.sided
##
## NOTE: n is number in *each* group
Multiplying by the design effect gives young people in each arm. Given the
constraints on numbers of young people per therapist and family, we need to
increase this to young people, therapists and families per arm.
Solution to exercise 20.6
The correlation is
Denoting the -th posterior samples of variance components by, e.g., , we can
then obtain a set of posterior samples of the correlation. The -th sample is:
140.80
150 15 75
ρ = .
σ
2
u
+ +σ
2
u
σ
2
v
σ
2
e
i σ
2(i)
u
i
2021/5/12 MATH5092 Mixed Models with Medical Applications
https://minerva.leeds.ac.uk/bbcswebdav/pid-8349912-dt-content-rid-18715700_2/courses/202021_37420_MATH5092M/Exercises MedApp %28with solutions%29.html 9/9
We then use these in a Monte Carlo estimate of the posterior mean:
where is the indicator function.
= .ρ
(i)
σ
2(i)
u

2(i)
u
σ
2(i)
c
Pr[ρ > 0.1 | y] ≈ I( > 0.1),
1
N

i=1
N
ρ
(i)
I(. )



































































































































































































































































































































































































































































































学霸联盟


essay、essay代写