[R-sig-ME] plot response by levels of factor
Douglas Bates
bates at stat.wisc.edu
Wed Apr 6 19:37:10 CEST 2011
I think you may need to contact Fabian Scheipl
<fabian.scheipl at stat.uni-muenchen.de>, the author of the amer package
to get advice on this question. (And, by the way, thanks for making
the data available - it helps a lot in reproducing the problem.)
On Thu, Mar 31, 2011 at 7:33 PM, Matthew Finkbeiner
<matthew.finkbeiner at mq.edu.au> wrote:
> I am new to mixed-effects modeling, so this is probably an embarrassingly
> easy problem to solve. I have a repeated measures design where, in each
> block of trials, subjects (N=10) performed a reaching response to 10
> different target stimuli that were presented 10 times each (once per level
> of 'FactorA'), for a total of 100 trials per block. There were 5
> experimental blocks. The dependent measure is the 'angle' of the reaching
> trajectory, and this was sampled/calculated at 5 different times per
> response.
>
> I would like to plot angles ~ Sample for each level of FactorA (with CIs),
> but have not been able to figure out how to do this. The amer package
> provides a nice example of how to do this, using the following call to amer
> with the 'dog' data:
> d1<- amer(y ~ -1 + group + tp(time, k=6, by = group) + (1|dog), data = dog)
> plotF(d1, legend = 'topleft', lwd=3)
>
> But when I run a similarly structured analysis with my data, it fails. For
> example:
> fm1<- amer(angles ~ -1 + FactorA + tp(Sample, k=4, by = FactorA) + (1|Subj)
> + (1|TargItem), data = VelInts)
> Error in `*tmp*`[[ind]] : subscript out of bounds
>
> I suspect that this is because of the repeated-measures design, but don't
> know how to get around that.
>
> I have run the following analysis successfully with lmer:
>
> lmer1 <- lmer(angles ~ FactorA + Sample + (1|TargItem) + (0+key|Subj), data
> = VelInts)
>
> which produces the following:
>
> Fixed effects:
> Estimate Std. Error t value
> (Intercept) 1.6177246 0.0124393 130.05
> FactorA2 -0.0300888 0.0110805 -2.72
> FactorA3 0.0746474 0.0111035 6.72
> FactorA4 0.0506684 0.0110861 4.57
> FactorA5 0.1578699 0.0111209 14.20
> FactorA6 0.0272700 0.0110862 2.46
> FactorA7 0.0613134 0.0111036 5.52
> FactorA8 -0.0470794 0.0111091 -4.24
> FactorA9 -0.0248243 0.0111382 -2.23
> FactorA10 -0.1258571 0.0110807 -11.36
> Sample -0.0038139 0.0000701 -54.41
>
>
> But I can't figure out how to go from this to visualizing 'angles ~ Sample'
> for each level of FactorA.
>
> Any help would be much appreciated.
>
> The structure of my data is as follows:
>
>> str(VelInts)
> 'data.frame': 24205 obs. of 31 variables:
> $ .id : chr "101" "101" "101" "101" ...
> $ Subj : Factor w/ 10 levels "S1","S2","S3",..: 1 1 1 1 1 1 1 1 1 1
> ...
> $ block : num 2 2 2 2 2 2 2 2 2 2 ...
> $ trial_n : num 1 1 1 1 1 2 2 2 2 2 ...
> $ FactorA : Factor w/ 10 levels "1","2","3","4",..: 6 6 6 6 6 1 1 1 1 1
> ...
> $ fixedpattern: num 1 1 1 1 1 0 0 0 0 0 ...
> $ pattern : num 2 2 2 2 2 0 0 0 0 0 ...
> $ TargPos : num 2 2 2 2 2 1 1 1 1 1 ...
> $ LiftOff : num 241 241 241 241 241 290 290 290 290 290 ...
> $ Acc : num 1 1 1 1 1 1 1 1 1 1 ...
> $ FixDur : num 529 529 529 529 529 662 662 662 662 662 ...
> $ Missing : num 0 0 0 0 0 0 0 0 0 0 ...
> $ TargItem : num 6 6 6 6 6 1 1 1 1 1 ...
> $ RT : num 712 712 712 712 712 959 959 959 959 959 ...
> $ x : num 0.477 25.26 68.063 121.514 213.708 ...
> $ y : num 7.09 30.97 69.54 149.23 270.24 ...
> $ z : num 10.8 73.9 138.2 191.8 240.5 ...
> $ t : num 270 336 402 469 535 ...
> $ presT : num 270 336 402 468 534 ...
> $ key : num 101 101 101 101 101 102 102 102 102 102 ...
> $ pathoffset : num 0.00583 -0.00899 -0.03706 -0.043 -0.06842 ...
> $ xvel : num 92.8 571.6 746.9 869.1 1803.9 ...
> $ yvel : num 150 431 817 1476 2092 ...
> $ tangvel : num 177 716 1107 1713 2762 ...
> $ xaccel : num 5310 2967 3155 5330 1387 ...
> $ yaccel : num 7812 1132 10343 6860 2647 ...
> $ angles : num 1.503 0.887 0.796 0.887 0.902 ...
> $ Sample : int 0 25 50 75 100 0 25 50 75 100 ...
> $ G : num 6 6 6 6 6 1 1 1 1 1 ...
> $ S : num 51 51 51 51 51 1 1 1 1 1 ...
> $ SK : Factor w/ 4841 levels "100103","100113",..: 2228 2228 2228
> 2228 2228 96 96 96 96 96 ...
>
>
> And if it is helpful, the full data frame can be accessed here:
> http://www.maccs.mq.edu.au/~mfinkbei/VelInts.RData
>
>
> Thank you kindly for suggestions,
>
> Matthew
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-mixed-models at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>
More information about the R-sig-mixed-models
mailing list