[R] nlme formula from model specification

Mikkel Meyer Andersen mikl at mikl.dk
Thu Sep 2 14:21:24 CEST 2010


Dear Thierry,

Thanks for the quick answer. I'm moving this to r-sig-mixed-models
(but also posting on r-help to notify).

I reserved "Mixed-effects models in S and S-PLUS" by Pinheiro and
Bates, New York : Springer, 2000. Do you know any other good
references?

Cheers, Mikkel.

2010/9/2 ONKELINX, Thierry <Thierry.ONKELINX at inbo.be>:
> Dear Mikkel,
>
> You need to do some reading on terminology.
>
> In your model the fixed effects are channel 1, 2 and 3. samplenumber is
> a random effect and the error term is an error term
>
> The model you described has the notation below. You do not need to
> create the grouped data structure.
>
> lme(channel0 ~ pos + samplenumber + channel1 + channel2 + channel3,
>   random = ~ 1 | samplenumber,
>   correlation = corAR1(value = 0.5, form = ~ pos | samplenumber),
>   data = channel.matrix)
>
> HTH,
>
> Thierry
>
> PS There is a dedicated mailing list for mixed models:
> R-sig-mixed-models
>
> ------------------------------------------------------------------------
> ----
> ir. Thierry Onkelinx
> Instituut voor natuur- en bosonderzoek
> team Biometrie & Kwaliteitszorg
> Gaverstraat 4
> 9500 Geraardsbergen
> Belgium
>
> Research Institute for Nature and Forest
> team Biometrics & Quality Assurance
> Gaverstraat 4
> 9500 Geraardsbergen
> Belgium
>
> tel. + 32 54/436 185
> Thierry.Onkelinx at inbo.be
> www.inbo.be
>
> To call in the statistician after the experiment is done may be no more
> than asking him to perform a post-mortem examination: he may be able to
> say what the experiment died of.
> ~ Sir Ronald Aylmer Fisher
>
> The plural of anecdote is not data.
> ~ Roger Brinner
>
> The combination of some data and an aching desire for an answer does not
> ensure that a reasonable answer can be extracted from a given body of
> data.
> ~ John Tukey
>
>
>> -----Oorspronkelijk bericht-----
>> Van: r-help-bounces at r-project.org
>> [mailto:r-help-bounces at r-project.org] Namens Mikkel Meyer Andersen
>> Verzonden: donderdag 2 september 2010 13:30
>> Aan: r-help at r-project.org
>> Onderwerp: [R] nlme formula from model specification
>>
>> Dear R-community,
>>
>> I'm analysing some noise using the nlme-package. I'm writing
>> in order to get my usage of lme verified.
>>
>> In practise, a number of samples have been processed by a
>> machine measuring the same signal at four different channels.
>> I want to model the noise. I have taken the noise (the signal
>> is from position 1 to 3500, and after that there is only noise).
>>
>> My data looks like this:
>> channel.matrix:
>>       pos channel0 channel1 channel2 channel3 samplenumber
>>    1 3501        8        3       12        1            1
>>    2 3502        3        7        0       14            1
>>    3 3503        9        1       13        3            1
>>    4 3504        3        7        3       14            1
>>    5 3505        6        5        4        5            1
>>    6 3506        7        0       16        0            1
>> ...
>>  495 3995        5        2        9        9            1
>>  496 3996        2        4        6       10            1
>>  497 3997        3        2        7        7            1
>>  498 3998        2        4        3        9            1
>>  499 3999        3        1        6       11            1
>>  500 4000        0        3        6        7            1
>> 2301 3501        1        4        3        9            2
>> 2302 3502        3        3        4       13            2
>> 2303 3503        4        1        8        5            2
>> 2304 3504        3        1       10        2            2
>> 2305 3505        2        3        5        8            2
>> 2306 3506        0        5        8        2            2
>> ...
>>
>> The model is
>> channel0 ~ alpha_i + eps_{i, j} + channel1 + channel2 +
>> channel3 where i is sample number, j is position, and:
>>   alpha_i:                 fixed effect for each samplenumber
>>   eps_{i, j}:              random effect, here with correlation
>> structure as AR(1)
>>   channel1, ..., channel3: fixed effect for each channel not
>> depending on
>>                            samplenumber nor position
>>
>> (And then afterwards I would model channel1 ~ ... + channel2
>> + channel3 etc.)
>>
>> I then use this function call:
>> channel.matrix.grouped <- groupedData(channel0 ~ pos | samplenumber,
>>   data = channel.matrix)
>>
>> fit <- lme(channel0 ~ pos + samplenumber + channel1 +
>> channel2 + channel3,
>>   random = ~ pos | samplenumber,
>>   correlation = corAR1(value = 0.5, form = ~ pos | samplenumber),
>>   data = channel.matrix.grouped)
>>
>> Is that the right way to express the model in (n)lme-notation?
>>
>> Cheers, Mikkel.
>>
>> ______________________________________________
>> R-help at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
> Druk dit bericht a.u.b. niet onnodig af.
> Please do not print this message unnecessarily.
>
> Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer
> en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is
> door een geldig ondertekend document. The views expressed in  this message
> and any annex are purely those of the writer and may not be regarded as stating
> an official position of INBO, as long as the message is not confirmed by a duly
> signed document.
>



More information about the R-help mailing list