IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

R Discussion :

utilisation de la fonction GLS


Sujet :

R

  1. #1
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Mars 2012
    Messages
    69
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2012
    Messages : 69
    Points : 38
    Points
    38
    Par défaut utilisation de la fonction GLS
    Bonjour,
    Je dispose d'un jeu de données sur lequel je souhaite procéder à une régression linéaire. Lorsque j'utilise la fonction "lm", j'observe une hétéroscédasticité des résidus (test de bartlett). Je m'intéresse donc à la fonction gls du package "nlme" qui semble pouvoir gérer ce genre de problème. Cependant, je ne comprends pas très bien comment utiliser cette fonction.

    Voici donc ma question:
    Est-ce la manière donc la fonction estime les valeurs des coefficients et de leur erreur standard qui permet de l'utiliser sur des données avec hétéroscédasticité ou bien faut-il préciser une variable de groupe dans la formule. Un peu à la manière des modèles mixtes avec les variables aléatoires (fonction "lme" et "lmer").
    En d'autres termes, je ne sais pas si pour gérer mon problème d'hétéroscédasticité je dois préciser dans la formule de la fonction une variable de groupe, en l'occurence dans mon jeu de données ce serait la variable "Replicat".

    Voici le modèle que j'utilise:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
     
    a2=read.table("total37.txt",header=TRUE)
    m1=gls(Res~ModeF*T,a2)
    Voici un aperçu de mon jeu de données où T correspond au temps:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
     
    T   ModeF	Res	Replicat
    1	38	0	1
    1	38	0.1	1
    1	38	0.2	1
    1	38	-0.7	1
    1	38	-0.3	1
    1	38	0	1
    1	38	0	1
    1	38	0.2	1
    1	40.8	0.2	2
    1	40.8	-0.1	2
    1	40.8	-0.2	2
    1	40.8	-0.4	2
    1	42.7	0	3
    1	42.7	0	3
    1	42.7	-0.1	3
    1	42.7	-0.5	3
    1	42.7	0.1	3
    1	42.7	-0.3	3
    1	42.7	0.1	3
    1	42.7	-3.3	3
    1	41.7	0.4	4
    1	41.7	-0.8	4
    1	41.7	-0.8	4
    1	42	0.2	5
    1	42	0.4	5
    1	42	0.2	5
    1	42	0.1	5
    1	42	-0.2	5
    1	42	0.2	5
    1	41.5	-0.1	6
    1	41.5	0.2	6
    1	41.5	0.3	6
    1	41.5	0.1	6
    1	41.5	0	6
    1	41.5	-0.7	6
    1	41.5	-1.6	6
    1	41.5	-2.3	6
    1	41.5	-1	6
    7	41	0.1	1
    7	41	-0.2	1
    7	41	-0.4	1
    7	41	0.3	1
    7	41.4	-0.7	2
    7	41.4	0	2
    7	43	0.8	3
    7	43	0.3	3
    7	43	0.5	3
    7	43	0.7	3
    7	43	0.5	3
    7	43	0.6	3
    7	43	-0.1	3
    7	43	0.3	3
    7	43	0.3	3
    7	43	0	3
    7	42.9	-0.4	4
    7	42.9	-0.6	4
    7	42.9	-0.9	4
    7	44.8	-0.1	5
    7	44.8	-0.3	5
    7	44.8	-1	5
    7	44.8	-1.4	5
    7	44.8	-1.9	5
    7	44.8	-0.1	5
    7	44.8	-2.5	5
    7	42.7	0.1	6
    7	42.7	0.3	6
    7	42.7	0.2	6
    7	42.7	-0.1	6
    7	42.7	-0.1	6
    7	42.7	0.3	6
    7	42.7	-0.9	6
    7	42.7	-1.1	6
    Je mesure donc l'évolution de ma variable "Res" en fonction de ma variable "ModeF" à 2 temps différents. Pour chaque temps je dispose de 6 réplicats comportant chacun autant de pseudoréplicats que de mesures.

    Merci pour votre aide.

  2. #2
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Mars 2012
    Messages
    69
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2012
    Messages : 69
    Points : 38
    Points
    38
    Par défaut
    Bonjour,
    J'ai maintenant décidé de suivre le R Book de Michael J. Crawley pour l'utilisation de la fonction gls.

    Voici donc mon code:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    a1=read.table("total25.txt",header=TRUE)
    a1$fReplicat=factor(a1$Replicat)
    space=groupedData(Res~ModeF*T|fReplicat, a1)
    m4=gls(Res~ModeF*T, space)
    summary(m4)
    J'ai donc un premier modèles avec la fonction gls, qui ne tient pas encore compte de la corrélation de mes résidus et de l'hétéroscédasticité.
    A la suite de cela, il convient apparemment de ploter un variogramme afin d'observer visuellement cette corrélation des résidus.
    On procède, toujours selon le livre, de la manière suivante:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    plot(Variogram(m4,form=~fReplicat))
    Seulement, là, j'obtiens un message d'erreur:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    Warning messages:
    1: In simpleLoess(y, x, w, span, degree, FALSE, FALSE, normalize = FALSE,  ... :
      span too small.   fewer data values than degrees of freedom.
    2: In simpleLoess(y, x, w, span, degree, FALSE, FALSE, normalize = FALSE,  ... :
      at  -0.0070711
    3: In simpleLoess(y, x, w, span, degree, FALSE, FALSE, normalize = FALSE,  ... :
      radius  5e-005
    4: In simpleLoess(y, x, w, span, degree, FALSE, FALSE, normalize = FALSE,  ... :
      all data on boundary of neighborhood. make span bigger
    5: In simpleLoess(y, x, w, span, degree, FALSE, FALSE, normalize = FALSE,  ... :
      pseudoinverse used at -0.0070711
    6: In simpleLoess(y, x, w, span, degree, FALSE, FALSE, normalize = FALSE,  ... :
      neighborhood radius 0.0070711
    7: In simpleLoess(y, x, w, span, degree, FALSE, FALSE, normalize = FALSE,  ... :
      reciprocal condition number  1
    8: In simpleLoess(y, x, w, span, degree, FALSE, FALSE, normalize = FALSE,  ... :
      at  1.4213
    9: In simpleLoess(y, x, w, span, degree, FALSE, FALSE, normalize = FALSE,  ... :
      radius  5e-005
    10: In simpleLoess(y, x, w, span, degree, FALSE, FALSE, normalize = FALSE,  ... :
      all data on boundary of neighborhood. make span bigger
    11: In simpleLoess(y, x, w, span, degree, FALSE, FALSE, normalize = FALSE,  ... :
      There are other near singularities as well. 5e-005
    12: In simpleLoess(y, x, w, span, degree, FALSE, FALSE, normalize = FALSE,  ... :
      zero-width neighborhood. make span bigger
    13: In simpleLoess(y, x, w, span, degree, FALSE, FALSE, normalize = FALSE,  ... :
      zero-width neighborhood. make span bigger
    14: In simpleLoess(y, x, w, span, degree, FALSE, FALSE, normalize = FALSE,  ... :
      span too small.   fewer data values than degrees of freedom.
    15: In simpleLoess(y, x, w, span, degree, FALSE, FALSE, normalize = FALSE,  ... :
      at  -0.0070711
    16: In simpleLoess(y, x, w, span, degree, FALSE, FALSE, normalize = FALSE,  ... :
      radius  5e-005
    17: In simpleLoess(y, x, w, span, degree, FALSE, FALSE, normalize = FALSE,  ... :
      all data on boundary of neighborhood. make span bigger
    18: In simpleLoess(y, x, w, span, degree, FALSE, FALSE, normalize = FALSE,  ... :
      pseudoinverse used at -0.0070711
    19: In simpleLoess(y, x, w, span, degree, FALSE, FALSE, normalize = FALSE,  ... :
      neighborhood radius 0.0070711
    20: In simpleLoess(y, x, w, span, degree, FALSE, FALSE, normalize = FALSE,  ... :
      reciprocal condition number  1
    21: In simpleLoess(y, x, w, span, degree, FALSE, FALSE, normalize = FALSE,  ... :
      at  1.4213
    22: In simpleLoess(y, x, w, span, degree, FALSE, FALSE, normalize = FALSE,  ... :
      radius  5e-005
    23: In simpleLoess(y, x, w, span, degree, FALSE, FALSE, normalize = FALSE,  ... :
      all data on boundary of neighborhood. make span bigger
    24: In simpleLoess(y, x, w, span, degree, FALSE, FALSE, normalize = FALSE,  ... :
      There are other near singularities as well. 5e-005
    25: In simpleLoess(y, x, w, span, degree, FALSE, FALSE, normalize = FALSE,  ... :
      zero-width neighborhood. make span bigger
    26: In simpleLoess(y, x, w, span, degree, FALSE, FALSE, normalize = FALSE,  ... :
      zero-width neighborhood. make span bigger
    27: In simpleLoess(y, x, w, span, degree, FALSE, FALSE, normalize = FALSE,  ... :
      span too small.   fewer data values than degrees of freedom.
    28: In simpleLoess(y, x, w, span, degree, FALSE, FALSE, normalize = FALSE,  ... :
      at  -0.0070711
    29: In simpleLoess(y, x, w, span, degree, FALSE, FALSE, normalize = FALSE,  ... :
      radius  5e-005
    30: In simpleLoess(y, x, w, span, degree, FALSE, FALSE, normalize = FALSE,  ... :
      all data on boundary of neighborhood. make span bigger
    31: In simpleLoess(y, x, w, span, degree, FALSE, FALSE, normalize = FALSE,  ... :
      pseudoinverse used at -0.0070711
    32: In simpleLoess(y, x, w, span, degree, FALSE, FALSE, normalize = FALSE,  ... :
      neighborhood radius 0.0070711
    33: In simpleLoess(y, x, w, span, degree, FALSE, FALSE, normalize = FALSE,  ... :
      reciprocal condition number  1
    34: In simpleLoess(y, x, w, span, degree, FALSE, FALSE, normalize = FALSE,  ... :
      at  1.4213
    35: In simpleLoess(y, x, w, span, degree, FALSE, FALSE, normalize = FALSE,  ... :
      radius  5e-005
    36: In simpleLoess(y, x, w, span, degree, FALSE, FALSE, normalize = FALSE,  ... :
      all data on boundary of neighborhood. make span bigger
    37: In simpleLoess(y, x, w, span, degree, FALSE, FALSE, normalize = FALSE,  ... :
      There are other near singularities as well. 5e-005
    38: In simpleLoess(y, x, w, span, degree, FALSE, FALSE, normalize = FALSE,  ... :
      zero-width neighborhood. make span bigger
    39: In simpleLoess(y, x, w, span, degree, FALSE, FALSE, normalize = FALSE,  ... :
      zero-width neighborhood. make span bigger
    40: In simpleLoess(y, x, w, span, degree, FALSE, FALSE, normalize = FALSE,  ... :
      span too small.   fewer data values than degrees of freedom.
    41: In simpleLoess(y, x, w, span, degree, FALSE, FALSE, normalize = FALSE,  ... :
      at  -0.0070711
    42: In simpleLoess(y, x, w, span, degree, FALSE, FALSE, normalize = FALSE,  ... :
      radius  5e-005
    43: In simpleLoess(y, x, w, span, degree, FALSE, FALSE, normalize = FALSE,  ... :
      all data on boundary of neighborhood. make span bigger
    44: In simpleLoess(y, x, w, span, degree, FALSE, FALSE, normalize = FALSE,  ... :
      pseudoinverse used at -0.0070711
    45: In simpleLoess(y, x, w, span, degree, FALSE, FALSE, normalize = FALSE,  ... :
      neighborhood radius 0.0070711
    46: In simpleLoess(y, x, w, span, degree, FALSE, FALSE, normalize = FALSE,  ... :
      reciprocal condition number  1
    47: In simpleLoess(y, x, w, span, degree, FALSE, FALSE, normalize = FALSE,  ... :
      at  1.4213
    48: In simpleLoess(y, x, w, span, degree, FALSE, FALSE, normalize = FALSE,  ... :
      radius  5e-005
    49: In simpleLoess(y, x, w, span, degree, FALSE, FALSE, normalize = FALSE,  ... :
      all data on boundary of neighborhood. make span bigger
    50: In simpleLoess(y, x, w, span, degree, FALSE, FALSE, normalize = FALSE,  ... :
      There are other near singularities as well. 5e-005

    Si jamais quelqu'un pouvait m'expliquer le problème. Car pour inclure une corrélation dans le modèle, je dois apparemment forcément passer par les variogrammes. Ils permettent en effet de récupérer les valeurs de paramètres qu'il faut rentrer dans la partie CorClasses de la fonction gls.
    Vous avez un aperçu de mon jeu de données dans mon premier message.

    Merci.

Discussions similaires

  1. [LG]Utilisation de la fonction time
    Par kmitz dans le forum Langage
    Réponses: 4
    Dernier message: 08/04/2005, 13h05
  2. Utilisation de la fonction de déploiement
    Par mchicoix dans le forum XMLRAD
    Réponses: 4
    Dernier message: 01/03/2005, 14h35
  3. [LG]Utilisation de la fonction Random
    Par chloe95 dans le forum Langage
    Réponses: 1
    Dernier message: 01/03/2005, 14h20
  4. Utilisation de la fonction qsort
    Par Jsmeline dans le forum C
    Réponses: 8
    Dernier message: 28/01/2005, 12h40
  5. [LG]librairies : utiliser seulement quelques fonctions
    Par wwwroom dans le forum Langage
    Réponses: 13
    Dernier message: 14/05/2004, 22h50

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo