[R-sig-ME] Free statistical analysis material?

Maarten Jung M@@rten@Jung @ending from m@ilbox@tu-dre@den@de
Fri May 18 13:52:20 CEST 2018


Hi Luca,

I think this is not an issue specific to lmer() or mixed models. Maybe this
post [1] and especially the section "Running Fewer than J-1 Contrasts for J
Groups" are also informative.
Anyways, see my comments on CrossValidated.
Also, you can *always*, i.e. independent of whether the matrix is square or
not, use the generalized inverse/pseudoinverse matrix returned by
MASS::ginv(rbind(contrast1, contrast2, ...)). However, you then have to set
column names to name the contrasts.

[1]
https://rstudio-pubs-static.s3.amazonaws.com/65059_586f394d8eb84f84b1baaf56ffb6b47f.html

Cheers,
Maarten

On Fri, May 18, 2018 at 11:45 AM, Luca Danieli <mr.lucedan at hotmail.it>
wrote:

> Hello again Ben and all R users,
>
> I am having the problem that I cannot make a contrast hypothesis for a
> rectangular matrix, because I cannot invert it. Somehow, I had read
> somewhere to use the method "pseudoinverse()" instead of "solve()".
>
> But in the analysis, I cannot get the p_value of my contrast hypothesis.
> Does somebody have a suggestion on how to either:
>
>   *   create a square matrix when I have few hypothesis with a lot of
> conditions (e.g., ps_c1 = c(0.5, 0.5, -1/6, -1/6, -1/6, -1/6, -1/6, -1/6)).
> Matrix 2x8.
>   *   get the p_value of a rectangular matrix contrast hypothesis?
>
> A more detailed explanation is on stackexchange:
> https://stats.stackexchange.com/questions/346523/get-p-value
> -about-contrast-hypothesis-for-rectangular-matrix#346523
>
> Best
> Luca
>
>
> ________________________________
> From: Ben Bolker <bbolker at gmail.com>
> Sent: 14 May 2018 21:45
> To: Luca Danieli; r-sig-mixed-models at r-project.org
> Subject: Re: [R-sig-ME] Free statistical analysis material?
>
>
>   The ugly spam e-mail is a known problem.  I get it too. I think the R
> mailing list administrators (I am not one of them!) are aware of the
> issue, in the meantime I think the advice given was "ignore it or update
> your spam filters".
>
>   Your 'contrast' vector for 8  conditions seems reasonable.  It really
> represents a single row of the *inverse* contrast matrix (since it
> describes the linear combination of group means that determines the
> parameter value not the linear combination of values that determines a
> group mean).  It would have to be embedded in the same kind of
> conversion code as in the examples you showed for closure and expertise
> in your example.
>
>   Did you read the PDF I linked to?
>
>   cheers
>    Ben Bolker
>
> On 2018-05-14 04:38 PM, Luca Danieli wrote:
> > Thank you for confirming the confusion.
> >
> > In general, in the example the first contrast is about the first
> > effect/variable (in this case a "musical closure") and has 4 conditions,
> > so I create a contrast like:
> >
> > condition 4 > conditions 1, 2, 3
> >
> > -> cl_c1 = c(-1/3,-1/3,-1/3,1)
> >
> > Now I want to look at another effect/variable (named "position"). This
> > has 8 conditions and I have to make a contrast like
> >
> > conditions 1, 2 > conditions 3, 4, 5, 6, 7, 8
> > Hipotetically should be (?):
> >
> > -> ps_c1 = c(0.5, 0.5, -1/6, -1/6, -1/6, -1/6, -1/6, -1/6)
> >
> > ? Guess I am wrong?
> >
> > Btw, I received the following reply from the mailing list by a certain
> > Elisa Rose. Maybe you want to dig into the issue?
> >
> > Hey  {fullname}   ///I guess that given the mailing list it couldn't
> > detect my name
> > Thanks for your response. Can I have a pic or two to start talking?
> > Please respond with pics/infos, Hope to hear back from you asap.
> >
> > Thanks,
> >
> > ------------------------------------------------------------------------
> > *From:* R-sig-mixed-models <r-sig-mixed-models-bounces at r-project.org> on
> > behalf of Ben Bolker <bbolker at gmail.com>
> > *Sent:* 14 May 2018 20:56
> > *To:* r-sig-mixed-models at r-project.org
> > *Subject:* Re: [R-sig-ME] Free statistical analysis material?
> >
> >
> >   Contrasts are confusing, and not specific to LMMs.  You might see if
> >
> > http://bbolker.github.io/mixedmodels-misc/notes/contrasts.pdf
> >
> > helps at all.  (From a quick glance at your question & code below, I'm
> > not sure what you mean by "2 conditions > 6 conditions" ???)
> >
> > On 2018-05-14 03:48 PM, Luca Danieli wrote:
> >> Hello everybody,
> >>
> >> I am trying the difficult task to conclude an interdisciplinary PhD.
> >> Statistics looks nice, and I have learned a lot about the basic
> principles and methodologies, and how they work.
> >>
> >> But I miss a lot. In particular all the little variations and methods
> due to interpretations and methodologies (for example now I am looking at
> the function of contrasts in mixed-effects models), and generally, from
> theory to applied statistics there is an incredible gap.
> >>
> >> Is anybody in this list (as I don't really have a mentor on statistics
> nor I know statisticians) be able to point me to some free materials
> (books, tutorials) to study the topic in detail, but not too much in detail?
> >>
> >> For example, in this moment, I am trying to figure the following script
> out. I understand it on its general lines, but there are really obscure
> points in my head on understanding the "why".
> >> In the following example, what I don't understand is just the
> contrasts, but the person who is following me (who is a very nice person)
> has given me the task to figure out the best way to make a contrast "2
> conditions > 6 conditions". She has suggested some guessing, but she is not
> a specialist.
> >>
> >> I was thinking that maybe you that are specialists know some free
> not-too-long source that I could read to move around.
> >>
> >> ----
> >>
> >> library(lmerTest)
> >>
> >> str(datasheet.complete)
> >> # set Score as numeric
> >> datasheet.complete$Score = as.numeric(datasheet.complete$Score)
> >>
> >> levels(datasheet.complete$Closure)
> >>
> >> # closure contrasts
> >> cl_c1 = c(-1/3,-1/3,-1/3,1)
> >> cl_c2 = c(-1/2,-1/2,1,0)
> >> cl_c3 = c(-1,1,0,0)
> >> closuremat.temp = rbind(constant = 1/4,cl_c1,cl_c2,cl_c3)
> >> closuremat = solve(closuremat.temp)
> >> closuremat = closuremat[, -1]
> >> closuremat
> >>
> >> # expertise contrasts
> >>
> >> exp_c1 = c(-1/2,-1/2,1)
> >> exp_c2 = c(-1,1,0)
> >> expmat.temp = rbind(constant = 1/3,exp_c1,exp_c2)
> >> expmat = solve(expmat.temp)
> >> expmat = expmat[, -1]
> >> expmat
> >>
> >> # set contrast
> >> contrasts(datasheet.complete$Closure) = closuremat
> >> contrasts(datasheet.complete$ExpertiseType) = expmat
> >>
> >>
> >> modela = lmer(Score~1+(1|Participant)+(1|Item), data =
> datasheet.complete, REML = TRUE)
> >> modelb = update(modela,.~.+ExpertiseType)
> >> modelc = update(modelb,.~.+Closure)
> >> modeld = update(modelc,.~.+ExpertiseType*Closure)
> >>
> >> anova(modela,modelb,modelc,modeld)
> >>
> >> model = lmer(Score~Closure*ExpertiseType+(1|Participant)+(1|Item),
> data = datasheet.complete, REML = TRUE)
> >> summary(model)
> >>
> >>
> >>        [[alternative HTML version deleted]]
> >>
> >> _______________________________________________
> >> R-sig-mixed-models at r-project.org mailing list
> >> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
> >>
> >
> > _______________________________________________
> > R-sig-mixed-models at r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>
>         [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-mixed-models at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>

	[[alternative HTML version deleted]]



More information about the R-sig-mixed-models mailing list