[R-sig-ME] Non-linear mixed model
Juan Pablo Edwards Molina
edwardsmolina at gmail.com
Thu Sep 14 15:39:22 CEST 2017
Thanks for your time and explanations Jesus...
I really appreciate it.
Best regards,
Juan Edwards
On Thu, Sep 14, 2017 at 10:22 AM, Jesus Maria Frias Celayeta
<jesus.frias at dit.ie> wrote:
> Hi Juan,
>
> If you have been fitting n1 to subsets of the data for each of the climate
> region you can use that information but you need to know which climate
> region is your baseline.
>
> you need to run something like
>
> levels(df$Clima1)
>
> The first level will be your baseline in the analytical contrast matrix and
> that will be the first starting parameters.
> The second starting parameter will be thx for the Clima2 subset minus
> thx.clima1
> The third starting parameter will be thx for the Clima3 subset minus
> thx.clima1
> and so on...
>
> regards,,
>
> Jesus
>
>
>
>
>
> On 14 September 2017 at 14:16, Juan Pablo Edwards Molina
> <edwardsmolina at gmail.com> wrote:
>>
>> Thanks Jesus for your quick reply! I will read the nlme help as you
>> suggested..
>>
>> I will try your first suggestion...
>>
>> for the starters of ths: can I use the overall model estimates?
>>
>> start = c(thy = 5.5, thq = -0.08, thc = -0.01, thx.clima1=xxx,
>> thx.clima2=xxx...,thx.climan=xxx),
>>
>> and just for curiosity, is it needed to group the data before modeling it?
>> df <- groupedData(diam~temp|race, data=d, order=FALSE)
>>
>>
>> Thanks again!
>>
>> Juan
>> Juan
>>
>>
>> On Thu, Sep 14, 2017 at 10:06 AM, Jesus Maria Frias Celayeta
>> <jesus.frias at dit.ie> wrote:
>> > Hi Juan,
>> >
>> > You probably want to have a look at the "fixed" argument in the nlme
>> > help
>> > page.
>> >
>> > If the variable that gives you the indicator of the climate region is
>> > Clima1
>> > you probably will need something like
>> >
>> > n2 <- nlme(diam ~ thy * exp(thq * (temp - thx)^2 + thc * (temp -
>> > thx)^3),
>> > fixed = list(thy + thq + thc ~ 1, thx~Clima1),
>> > random = thy + thq + thx + thc ~ 1 | race,
>> > start = c(thy = 5.5, thq = -0.08, thc = -0.01,
>> > thx.clima1=xxx,
>> > thx.clima2=xxx...,thx.climan=xxx),
>> > data = df)
>> >
>> > Note that you will need estimates for your baseline ths and for the
>> > analytical contrasts defined.
>> >
>> > If you want to see if the addition of Clima1 to the model is giving you
>> > joy
>> > then you need
>> > anova(n1,n2)
>> >
>> > and from summary(n2) you will see if any of your climate regions are
>> > different from the baseline control.
>> >
>> > Alternatively 1) you may choose different contrast .2) you can give a
>> > try to
>> > multiple comparisons. Both are well documented in this list (or the
>> > R-help).
>> >
>> > all the best,
>> >
>> > Jesus
>> >
>> > Jesus
>> >
>> >
>> >
>> > On 14 September 2017 at 13:57, Juan Pablo Edwards Molina
>> > <edwardsmolina at gmail.com> wrote:
>> >>
>> >> Dear list members,
>> >>
>> >> I´m trying to test the effect of the climate region classification on
>> >> the in vitro growth of a sample (n =20) of fungus races. I grew them
>> >> in several temperatures (20, 22, 25, 28, 31) that I knew they could
>> >> have the maximum growth:
>> >>
>> >> race state Clima1 Kopp Kopp2 temp rep diam
>> >> 1 TO F Aw B 20 1 4.4
>> >> 1 TO F Aw B 20 2 4.1
>> >> 1 TO F Aw B 20 3 4.3
>> >> 1 TO F Aw B 22 1 4.8
>> >> 1 TO F Aw B 22 2 4.5
>> >> 1 TO F Aw B 22 3 4.4
>> >> ..
>> >>
>> >>
>> >> The approach that I´m considering is to fitt a non- linear model:
>> >>
>> >> diam ~ thy * exp (thq*(temp-thx)² + thc*(temp-thx)³)
>> >>
>> >> # thx: Optimum temperature
>> >> # thy: Diameter at optimum
>> >> # thq: Curvature
>> >> # thc: Skewness
>> >>
>> >> Since I have particular interest on "thx": How should I include the
>> >> effect of my climate classiification variables on that coefficient?
>> >>
>> >> This is my try in nlme:
>> >>
>> >> df <- groupedData(diam~temp|race, data=d, order=FALSE)
>> >>
>> >> n1 <- nlme(diam ~ thy * exp(thq * (temp - thx)^2 + thc * (temp -
>> >> thx)^3),
>> >> fixed = thy + thq + thx + thc ~ 1,
>> >> random = thy + thq + thx + thc ~ 1 | race,
>> >> start = c(thy = 5.5, thq = -0.08, thx = 25, thc = -0.01),
>> >> data = df)
>> >>
>> >> The overall model converged and this is the summary:
>> >>
>> >> ======================================================
>> >> Nonlinear mixed-effects model fit by maximum likelihood
>> >> Model: diam ~ thy * exp(thq * (temp - thx)^2 + thc * (temp - thx)^3)
>> >> Data: df
>> >> AIC BIC logLik
>> >> 619.2972 652.1712 -301.6486
>> >>
>> >> Random effects:
>> >> Formula: list(thy ~ 1, thx ~ 1)
>> >> Level: race
>> >>
>> >> Structure: General positive-definite, Log-Cholesky parametrization
>> >> StdDev Corr
>> >> thy 0.00002186836 thy
>> >> thx 0.00001466761 0
>> >> Residual 0.47302438540
>> >>
>> >> Fixed effects: thy + thq + thx + thc ~ 1
>> >> Value Std.Error DF t-value p-value
>> >> thy 5.456386 0.03598277 427 151.63885 0.0000
>> >> thq -0.011081 0.00043084 427 -25.71992 0.0000
>> >> thx 25.908119 0.17218070 427 150.47052 0.0000
>> >> thc 0.000458 0.00015103 427 3.03271 0.0026
>> >> Correlation:
>> >> thy thq thx
>> >> thq -0.567
>> >> thx 0.217 0.289
>> >> thc -0.231 -0.192 -0.924
>> >>
>> >> Standardized Within-Group Residuals:
>> >> Min Q1 Med Q3 Max
>> >> -3.53487665 -0.64456754 0.06126737 0.67103195 2.17757223
>> >>
>> >> Number of Observations: 450
>> >> Number of Groups: 20
>> >>
>> >> =========================================================
>> >>
>> >> Thanks in advance... Any help would be very helpful!
>> >>
>> >> J. Edwards
>> >>
>> >> _______________________________________________
>> >> R-sig-mixed-models at r-project.org mailing list
>> >> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>> >
>> >
>> >
>> >
>> > --
>> >
>> > Jesús María Frías Celayeta, PhD CFS
>> >
>> > Ceannaire Acadúil, Institiúid na hInbhuanaitheachta Comhshaoil agus na
>> > Sláinte | Academic Leader, Environmental Sustainability and Health
>> > Institute
>> >
>> > Institiúid Teicneolaíochta Bhaile Átha Cliath | Dublin Institute of
>> > Technology
>> >
>> > Gráinseach Ghormáin | Grangegorman
>> >
>> > Baile Átha Cliath 7 | Dublin 7
>> >
>> > D07 H6K8
>> >
>> > F: +353-1-4025410 M: +353-879697289
>> >
>> > E: jesus.frias at dit.ie
>> >
>> > W: http://www.dit.ie/eshi
>> >
>> >
>> > This email originated from DIT. If you received this email in error,
>> > please
>> > delete it from your system. Please note that if you are not the named
>> > addressee, disclosing, copying, distributing or taking any action based
>> > on
>> > the contents of this email or attachments is prohibited. www.dit.ie
>> >
>> > Is ó ITBÁC a tháinig an ríomhphost seo. Má fuair tú an ríomhphost seo
>> > trí
>> > earráid, scrios de do chóras é le do thoil. Tabhair ar aird, mura tú an
>> > seolaí ainmnithe, go bhfuil dianchosc ar aon nochtadh, aon chóipeáil,
>> > aon
>> > dáileadh nó ar aon ghníomh a dhéanfar bunaithe ar an ábhar atá sa
>> > ríomhphost
>> > nó sna hiatáin seo. www.dit.ie
>> >
>> > Tá ITBÁC ag aistriú go Gráinseach Ghormáin – DIT is on the move to
>> > Grangegorman
>
>
>
>
> --
>
> Jesús María Frías Celayeta, PhD CFS
>
> Ceannaire Acadúil, Institiúid na hInbhuanaitheachta Comhshaoil agus na
> Sláinte | Academic Leader, Environmental Sustainability and Health Institute
>
> Institiúid Teicneolaíochta Bhaile Átha Cliath | Dublin Institute of
> Technology
>
> Gráinseach Ghormáin | Grangegorman
>
> Baile Átha Cliath 7 | Dublin 7
>
> D07 H6K8
>
> F: +353-1-4025410 M: +353-879697289
>
> E: jesus.frias at dit.ie
>
> W: http://www.dit.ie/eshi
>
>
> This email originated from DIT. If you received this email in error, please
> delete it from your system. Please note that if you are not the named
> addressee, disclosing, copying, distributing or taking any action based on
> the contents of this email or attachments is prohibited. www.dit.ie
>
> Is ó ITBÁC a tháinig an ríomhphost seo. Má fuair tú an ríomhphost seo trí
> earráid, scrios de do chóras é le do thoil. Tabhair ar aird, mura tú an
> seolaí ainmnithe, go bhfuil dianchosc ar aon nochtadh, aon chóipeáil, aon
> dáileadh nó ar aon ghníomh a dhéanfar bunaithe ar an ábhar atá sa ríomhphost
> nó sna hiatáin seo. www.dit.ie
>
> Tá ITBÁC ag aistriú go Gráinseach Ghormáin – DIT is on the move to
> Grangegorman
More information about the R-sig-mixed-models
mailing list