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

Delphi Discussion :

Probit et régression logarithmique


Sujet :

Delphi

  1. #1
    Membre habitué
    Homme Profil pro
    Owner
    Inscrit en
    Décembre 2004
    Messages
    466
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations professionnelles :
    Activité : Owner
    Secteur : Santé

    Informations forums :
    Inscription : Décembre 2004
    Messages : 466
    Points : 137
    Points
    137
    Par défaut Probit et régression logarithmique
    Bonjour,
    Je souhaite calculer la dose minimale détectable à l'aide de la fonction Probit:
    Voici un exemple de données à traiter:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
     
    HBV	rep.	positifs	Hit Rate	Frct%0-50	SubRoutine	Prob 0-50	Probit
    0	14	0,00					
    2,5	14	8,00					
    5	14	10,00					
    10	14	13,00					
    15	14	14,00					
    20	14	14,00					
    25	14	14,00
    Je calcule le Probit à l'aide du code suivant:
    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
     
    for I := 1 to ProbitGrid.rowcount-1 do
    if ProbitGrid.Cells[0,i]<>'' then
    begin
        if StrToFloat(ProbitGrid.Cells[1,i])<>0
        then
        ProbitGrid.Cells[3,i]:=   FloatToStr(StrToFloat(ProbitGrid.Cells[2,i])/  StrToFloat(ProbitGrid.Cells[1,i])*100)
        else
        ProbitGrid.Cells[3,i]:='0';
       //SI(C3>50;(100-C3)/100;C3/100)
        if StrToFloat(ProbitGrid.Cells[3,i])>50
        then
        ProbitGrid.Cells[4,i]:=  FloatToStr((100-StrToFloat(ProbitGrid.Cells[3,i]))/100)
        else
        ProbitGrid.Cells[4,i]:= FloatToStr(StrToFloat(ProbitGrid.Cells[3,i])/100);
     
      //RACINE(LN(1/PUISSANCE(C4;2)))
        if SQR(StrToFloat(ProbitGrid.Cells[4,i]))<>0 then   ProbitGrid.Cells[5,i]:=  FloatToStr(SQRT(ln(1/SQR(StrToFloat(ProbitGrid.Cells[4,i]))))) else ProbitGrid.Cells[5,i]:='0';
     
      //+C5-((2,515517+0,802853*C5+0,010328*PUISSANCE(C5;2))/(1+1,432788*C5+0,189269*(PUISSANCE(C5;2)+0,001308*PUISSANCE(C5;3))))
        if StrToFloat(ProbitGrid.Cells[5,i])<>0
        then
         ProbitGrid.Cells[6,i]:=FloatToStr(ABS(StrToFloat(ProbitGrid.Cells[5,i]))
         -((2.515517+0.802853*StrToFloat(ProbitGrid.Cells[5,i])+0.010328*SQR(StrToFloat(ProbitGrid.Cells[5,i])))
         /(1+1.432788*StrToFloat(ProbitGrid.Cells[5,i])+0.189269*(SQR(StrToFloat(ProbitGrid.Cells[5,i]))+0.001308*Power(StrToFloat(ProbitGrid.Cells[5,i]),3)))))
         else  ProbitGrid.Cells[6,i]:='0';
     
         //SI(L5>50;5+P5;5-P5)
          if ProbitGrid.Cells[6,i]='0' then  ProbitGrid.Cells[7,i]:='0'
          else
          begin
             if StrToFloat(ProbitGrid.Cells[3,i])>50 then   ProbitGrid.Cells[7,i]:= FloatToStr(5+StrToFloat(ProbitGrid.Cells[6,i])) else
             ProbitGrid.Cells[7,i]:= FloatToStr(5-StrToFloat(ProbitGrid.Cells[6,i]));
          end;
    end;
    ensuite je dois calculer la régression logarithmique des données X (colonne 0) et Y (colonne 7) à l'aide du code suivant:
    (proposé par http://www.developpez.net/forums/u75679/gilbert-geyer/)
    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
     
    procedure RegressLog(Nuage: TNuage; var B0, B1: Extended; var StrRes: string);
    var SigX, SigY, SigLnX, SigYLnX, SigLnX2: Extended; i: integer;
    begin
      SigX := 0.0; SigY := 0.0; SigLnX := 0.0; SigYLnX := 0.0; SigLnX2 := 0.0;
      for i := 0 to High(Nuage) do
      begin
        if Nuage[i].x <= 0.0 then
        begin
          StrRes := 'Non calculable car présence d''un point X <= 0 : EXIT';
          EXIT;
        end;
        SigX := SigX + Nuage[i].x;
        SigY := SigY + Nuage[i].y;
        SigLnX := SigLnX + ln(Nuage[i].x);
        SigYLnX := SigYLnX + Nuage[i].y * ln(Nuage[i].x);
        SigLnX2 := SigLnX2 + sqr(ln(Nuage[i].x));
      end;
      b1 := (SigYLnX - SigLnX * SigY / length(Nuage)) / (SigLnX2 - sqr(SigLnX) / length(Nuage));
      b0 := (SigY / length(Nuage)) - (b1 * SigLnX / length(Nuage));
      StrRes := 'y = ' + FloatToStr(b0) + ' + ' + FloatToStr(b1) + ' * Ln(x)';
    end;
    et
    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
     
      j:=0;
    for I := 1 to ProbitGrid.rowcount-1 do
    If ProbitGrid.Cells[3,i]<>'' then
    if (StrToFloat(ProbitGrid.Cells[3,i])>0) AND (StrToFloat(ProbitGrid.Cells[3,i])<100) then
      begin
       SetLength(Nuage, j+1);
       Nuage[j].X := StrToFloat(ProbitGrid.Cells[0,i]);
       Nuage[j].Y := StrToFloat(ProbitGrid.Cells[7,i]);
       //RichEdit1.Lines.Add(ProbitGrid.Cells[0,i]+'|'+ProbitGrid.Cells[7,i]);
       j:=j+1;
      end;
     
      RegressLog(Nuage, B0, B1, StrRes);
      equation.Caption:=StrRes;
      equation.Caption:='y = '+FormatFloat('0.0000',(B0))+' + '+FormatFloat('0.0000',(B1))+' * Ln(x)';
    ensuite la limite de détection est renvoyée par la formule:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    LOD95.Caption:='LOD 95%= '+ FormatFloat('0.00',(exp((6.645-b0)/b1)));
    Malheureusement, j'obtiens des résultats différents que ceux trouvés dans la littérature
    Ici par exemple je trouve 13.31 au lieu de 10.2

    Si qq a une idée...
    Merci pour vos lumières

  2. #2
    Expert confirmé
    Avatar de anapurna
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Mai 2002
    Messages
    3 419
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Arts - Culture

    Informations forums :
    Inscription : Mai 2002
    Messages : 3 419
    Points : 5 818
    Points
    5 818
    Par défaut
    salut


    les arrondi peut être non ? ... quand je vois plus de 5 décimal j'ai des doute sur la suite du calcul
    Nous souhaitons la vérité et nous trouvons qu'incertitude. [...]
    Nous sommes incapables de ne pas souhaiter la vérité et le bonheur, et sommes incapables ni de certitude ni de bonheur.
    Blaise Pascal
    PS : n'oubliez pas le tag

  3. #3
    Membre habitué
    Homme Profil pro
    Owner
    Inscrit en
    Décembre 2004
    Messages
    466
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations professionnelles :
    Activité : Owner
    Secteur : Santé

    Informations forums :
    Inscription : Décembre 2004
    Messages : 466
    Points : 137
    Points
    137
    Par défaut
    Citation Envoyé par anapurna Voir le message
    salut


    les arrondi peut être non ? ... quand je vois plus de 5 décimal j'ai des doute sur la suite du calcul
    Disons que je n'arrondi que l'affichage de la régression... pour le calcul du LOD95 je n'arrondi rien...

  4. #4
    Modérateur
    Avatar de tourlourou
    Homme Profil pro
    Biologiste ; Progr(amateur)
    Inscrit en
    Mars 2005
    Messages
    3 858
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 61
    Localisation : France, Yvelines (Île de France)

    Informations professionnelles :
    Activité : Biologiste ; Progr(amateur)

    Informations forums :
    Inscription : Mars 2005
    Messages : 3 858
    Points : 11 301
    Points
    11 301
    Billets dans le blog
    6
    Par défaut
    Au passage, tu devrais pê nommer des constantes pour remplacer les entiers désignant des colonnes du tableau par des intitulés parlants, facilitant la compréhension du code et des calculs.
    Delphi 5 Pro - Delphi 11.3 Alexandria Community Edition - CodeTyphon 6.90 sous Windows 10 ; CT 6.40 sous Ubuntu 18.04 (VM)
    . Ignorer la FAQ Delphi et les Cours et Tutoriels Delphi nuit gravement à notre code !

  5. #5
    Membre habitué
    Homme Profil pro
    Owner
    Inscrit en
    Décembre 2004
    Messages
    466
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations professionnelles :
    Activité : Owner
    Secteur : Santé

    Informations forums :
    Inscription : Décembre 2004
    Messages : 466
    Points : 137
    Points
    137
    Par défaut
    Citation Envoyé par tourlourou Voir le message
    Au passage, tu devrais pê nommer des constantes pour remplacer les entiers désignant des colonnes du tableau par des intitulés parlants, facilitant la compréhension du code et des calculs.
    Oui, de fait.
    Voici les colonnes dans l'ordre pour ProbitGrid:
    HBV =c0
    rep. =c1
    positifs =c2
    Hit Rate =c3
    Frct%0-50 =c4
    SubRoutine =c5
    Prob 0-50 =c6
    Probit =c7

  6. #6
    Membre habitué
    Homme Profil pro
    Owner
    Inscrit en
    Décembre 2004
    Messages
    466
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations professionnelles :
    Activité : Owner
    Secteur : Santé

    Informations forums :
    Inscription : Décembre 2004
    Messages : 466
    Points : 137
    Points
    137
    Par défaut
    J'ai refais le tout sur excel et j'obtiens la même chose.
    Mon calcul d'après la formule de Gilbert Geyer comparée à la formule loi.normale.standard.inverse de Excel donne aussi la même chose.
    (colonnes I et M)

    Nom : Probit comparaison Excel.jpg
Affichages : 249
Taille : 278,1 Ko

    Le but étant de calculer la valeur de X pour un Y (Probit) de 6.645
    J'utilise donc la formule:
    exp((6.645-b0)/b1)

    En arrondissant les Hit Rate comme dans la littérature, je passe de 13.31 à 12 (mais bon, je dois trouver 10.2)
    (voir CAP/CTM dans la publication: http://www.ncbi.nlm.nih.gov/pubmed/22535983 )

    Pour info, j'ai le même type d'erreur pour d'autres évaluations...

  7. #7
    Expert confirmé
    Avatar de anapurna
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Mai 2002
    Messages
    3 419
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Arts - Culture

    Informations forums :
    Inscription : Mai 2002
    Messages : 3 419
    Points : 5 818
    Points
    5 818
    Par défaut
    salut

    dans subroutine ne devrais tu pas faire un test pour éviter cette erreur de division par zéro
    genre :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
      =SI(PUISSANCE(F5;2)=0;0;RACINE(LN(1/PUISSANCE(F5;2))))

    et si tu fais ce test la colonne Probit va changer car toutes tes valeur de probit seront renseigné

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    =SI(E5>50;5+H5;5-H5)
    car la valeur E seras a zéro ce qui implique que H aussi seras a zero donc 5-0 = 5
    Nous souhaitons la vérité et nous trouvons qu'incertitude. [...]
    Nous sommes incapables de ne pas souhaiter la vérité et le bonheur, et sommes incapables ni de certitude ni de bonheur.
    Blaise Pascal
    PS : n'oubliez pas le tag

  8. #8
    Membre habitué
    Homme Profil pro
    Owner
    Inscrit en
    Décembre 2004
    Messages
    466
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations professionnelles :
    Activité : Owner
    Secteur : Santé

    Informations forums :
    Inscription : Décembre 2004
    Messages : 466
    Points : 137
    Points
    137
    Par défaut
    Citation Envoyé par anapurna Voir le message
    salut

    dans subroutine ne devrais tu pas faire un test pour éviter cette erreur de division par zéro
    genre :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
      =SI(PUISSANCE(F5;2)=0;0;RACINE(LN(1/PUISSANCE(F5;2))))
    et sit ut fait ce test la colonne Probit va changer car toutes tes valeur de probit seront renseigné

    car la valeur E seras a zéro ce qui implique que H aussi seras a zero donc 5-0 = 5
    Merci Anapurna
    Tu penses que je dois inclure l'ensemble des points y compris le 0 et le(s) 100 dans le calcul de la droite???

    Je teste et te dis quoi...


  9. #9
    Expert confirmé
    Avatar de anapurna
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Mai 2002
    Messages
    3 419
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Arts - Culture

    Informations forums :
    Inscription : Mai 2002
    Messages : 3 419
    Points : 5 818
    Points
    5 818
    Par défaut
    salut

    je ne sais pas c'est une éventualité
    Nous souhaitons la vérité et nous trouvons qu'incertitude. [...]
    Nous sommes incapables de ne pas souhaiter la vérité et le bonheur, et sommes incapables ni de certitude ni de bonheur.
    Blaise Pascal
    PS : n'oubliez pas le tag

  10. #10
    Membre habitué
    Homme Profil pro
    Owner
    Inscrit en
    Décembre 2004
    Messages
    466
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations professionnelles :
    Activité : Owner
    Secteur : Santé

    Informations forums :
    Inscription : Décembre 2004
    Messages : 466
    Points : 137
    Points
    137
    Par défaut
    Citation Envoyé par anapurna Voir le message
    salut

    je ne sais pas c'est une éventualité
    Ben non, je n'obtiens plus de droites

Discussions similaires

  1. Suppression lignes masquées et régression logarithmique
    Par superexcelfrancois dans le forum Macros et VBA Excel
    Réponses: 0
    Dernier message: 08/11/2011, 10h58
  2. [Débutant] une régression logarithmique
    Par nahr_Elk dans le forum MATLAB
    Réponses: 1
    Dernier message: 29/04/2011, 04h17
  3. Réponses: 1
    Dernier message: 23/04/2010, 17h48
  4. Bayes et régression probit
    Par lilly74 dans le forum SAS STAT
    Réponses: 3
    Dernier message: 25/12/2009, 22h49
  5. Régression logarithmique hu.
    Par Giansolo dans le forum Méthodes prédictives
    Réponses: 6
    Dernier message: 22/03/2007, 16h18

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