私は、異なる2つのCondition
の3つの異なるTimepoint
で収集された従属変数DV
で線形混合モデルを実行したいと考えています。次のようにデータが構成されている:SASからのlme4でのランダムなエフェクトの複製方法は?
## dput(head(RawData,5))
structure(list(Participant = structure(c(2L, 2L, 2L, 2L, 4L),
.Label = c("Jessie", "James", "Gus", "Hudson", "Flossy",
"Bobby", "Thomas", "Alfie", "Charles", "Will", "Mat", "Paul", "Tim",
"John", "Toby", "Blair"), class = "factor"),
xVarCondition = c(1, 1, 0, 0, 1),
Measure = structure(c(1L, 2L, 3L, 4L, 1L),
.Label = c("1", "2", "3", "4", "5", "6", "7", "8",
"9", "10", "11", "12"), class = "factor"),
Sample = structure(c(1L, 2L, 1L, 2L, 1L),
.Label = c("1", "2"), class = "factor"),
Condition = structure(c(2L, 2L, 1L, 1L, 2L),
.Label = c("AM", "PM"), class = "factor"),
Timepoint = structure(c(2L, 2L, 2L, 2L, 1L),
.Label = c("Baseline", "Mid", "Post"), class = "factor"),
DV = c(83.6381348645853, 86.9813802115179, 69.2691666620429,
71.3949807856125, 87.8931998204771)),
.Names = c("Participant", "xVarCondition", "Measure",
"Sample", "Condition", "Timepoint", "DV"),
row.names = c(NA, 5L), class = "data.frame")
各Participant
はMeasure
によって示されるようCondition
Timepoint
3を横切るSにつき2回の試験を行います。ただし、データが欠落しているため、必ずしも参加者あたり12レベルであるとは限りません。列xVarCondition
は、ConditionのAMの各エントリに対して1を含む単純なダミー変数です。列Sample
は、それぞれTimepoint
でCondition
の2つの試験を指します。
私はRのユーザーだが、統計学者は、モデルのコードがあるべきと考えているSASのユーザーである:SASコード上記
proc mixed data=RawData covtest cl alpha=α
class Participant Condition Timepoint Measure Sample;
model &dep=Condition Timepoint/s ddfm=sat outp=pred residual noint;
random int xVarCondition xVarCondition*TimePoint*Sample
TimePoint/subject=Participant s;
は賢明な答えを与え、完璧に働いています。私たちは、上記のモデルを可能にするには結果lme4
構文を信じる:
TestModel = lmer(DV ~ Condition + Timepoint +
(1 | Participant/Timepoint) +
(0 + xVarCondition | Participant) +
(1 | Participant:xVarCondition:Measure), data = RawData)
このモデルを実行している場合しかし、私は次のエラーを取得する:
Error: number of levels of each grouping factor must be < number of observations
が正しく指定ランダム効果はありますか?
を私は両方のあなたの固定効果、 'Condition'と' Timepoint'は、両方の要因であることに気づいたと思いますこの場合、混合線形モデルが最良のアプローチであると確信していますか?また、私は 'xVarCondition'と' Condition'の違いはありません。 –
私は、参加者の変化の間に興味があるので、線形混合モデルが適切だと思います。 xVarConditionは、参加者がAM条件を完了するたびに1を持つダミー変数です。 – user2716568