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 :

Algorithme de classification Newton Raphson (régression logistique)


Sujet :

R

  1. #1
    Candidat au Club
    Femme Profil pro
    ESTI
    Inscrit en
    Février 2014
    Messages
    9
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 33
    Localisation : Malaisie

    Informations professionnelles :
    Activité : ESTI
    Secteur : Industrie

    Informations forums :
    Inscription : Février 2014
    Messages : 9
    Points : 3
    Points
    3
    Par défaut Algorithme de classification Newton Raphson (régression logistique)
    Je suis débutante et j'ai besoin de votre aide. Je veux appliquer la methode de Newton Raphson à la classification. j'ai fait ce petit algorithme mais je ne sais pa comment extraire les classes ( les partitions).
    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
    mat= matrix (c (1,5,10,6,7,4,5,3,9,12,5,6,8,15,4,2,3,4,18,7,5,7,8,5,9,2,3,6,2,9,3,6,9,19,4), ncol=5,nrow=7)
    data=cbind(1,mat)
    n=dim(data)[1]
    m=dim(data)[2]
    beta<-seq(from=1,to=0.1,length=m)
    logll <- function(x , beta=c()) 
    {
      beta<-c(1,0.8,0.6,0.4,0.2,0.1)
      z<-x %*% beta
      p<-1/(1+exp(-z))
      if (p<0.5) 
        y<-0
      if (p>0.5) 
        y<-1
      logll<-sum((y*log(p)+(1-y)*log(1-p)))
    }
     
    for (i in 1:n)
    {
      x<-matrix(data[i,],ncol=m,nrow=1)
      b = maxNR(logll, start=beta, print.level=2)
      summary(b)
     
    }

  2. #2
    Membre du Club
    Homme Profil pro
    Helsinki
    Inscrit en
    Avril 2012
    Messages
    39
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Finlande

    Informations professionnelles :
    Activité : Helsinki
    Secteur : Enseignement

    Informations forums :
    Inscription : Avril 2012
    Messages : 39
    Points : 64
    Points
    64
    Par défaut Definit d'abord ta fonction
    Commence dájà par définir ta fonction maxNR.

  3. #3
    Candidat au Club
    Femme Profil pro
    ESTI
    Inscrit en
    Février 2014
    Messages
    9
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 33
    Localisation : Malaisie

    Informations professionnelles :
    Activité : ESTI
    Secteur : Industrie

    Informations forums :
    Inscription : Février 2014
    Messages : 9
    Points : 3
    Points
    3
    Par défaut
    max NR est une fonction dans le package maxLik

  4. #4
    Membre du Club
    Homme Profil pro
    Helsinki
    Inscrit en
    Avril 2012
    Messages
    39
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Finlande

    Informations professionnelles :
    Activité : Helsinki
    Secteur : Enseignement

    Informations forums :
    Inscription : Avril 2012
    Messages : 39
    Points : 64
    Points
    64
    Par défaut C'est quoi les partitions don tut parles?
    Voilà ce que donne ton modèle. Tu appeles quoi les partitions?

    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
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    ----- Initial parameters: -----
    fcn value: -0.09646085 
         parameter initial gradient free
    [1,]      1.00      0.091954550    1
    [2,]      0.82      0.073563640    1
    [3,]      0.64      0.055172730    1
    [4,]      0.46      0.036781820    1
    [5,]      0.28      0.018390910    1
    [6,]      0.10      0.009195455    1
    Condition number of the (active) hessian: 7652.405 
    -----Iteration 1 -----
    -----Iteration 2 -----
    -----Iteration 3 -----
    --------------
    gradient close to zero 
    3  iterations
    estimate: -77.09056 54.092 -49.81695 81.35279 146.798 272.3115 
    Function value: -9.081846e-12 
    ----- Initial parameters: -----
    fcn value: -0.09646085 
         parameter initial gradient free
    [1,]      1.00      0.091954550    1
    [2,]      0.82      0.073563640    1
    [3,]      0.64      0.055172730    1
    [4,]      0.46      0.036781820    1
    [5,]      0.28      0.018390910    1
    [6,]      0.10      0.009195455    1
    Condition number of the (active) hessian: 7652.405 
    -----Iteration 1 -----
    -----Iteration 2 -----
    -----Iteration 3 -----
    --------------
    gradient close to zero 
    3  iterations
    estimate: -77.09056 54.092 -49.81695 81.35279 146.798 272.3115 
    Function value: -9.081846e-12 
    ----- Initial parameters: -----
    fcn value: -0.09646085 
         parameter initial gradient free
    [1,]      1.00      0.091954550    1
    [2,]      0.82      0.073563640    1
    [3,]      0.64      0.055172730    1
    [4,]      0.46      0.036781820    1
    [5,]      0.28      0.018390910    1
    [6,]      0.10      0.009195455    1
    Condition number of the (active) hessian: 7652.405 
    -----Iteration 1 -----
    -----Iteration 2 -----
    -----Iteration 3 -----
    --------------
    gradient close to zero 
    3  iterations
    estimate: -77.09056 54.092 -49.81695 81.35279 146.798 272.3115 
    Function value: -9.081846e-12 
    ----- Initial parameters: -----
    fcn value: -0.09646085 
         parameter initial gradient free
    [1,]      1.00      0.091954550    1
    [2,]      0.82      0.073563640    1
    [3,]      0.64      0.055172730    1
    [4,]      0.46      0.036781820    1
    [5,]      0.28      0.018390910    1
    [6,]      0.10      0.009195455    1
    Condition number of the (active) hessian: 7652.405 
    -----Iteration 1 -----
    -----Iteration 2 -----
    -----Iteration 3 -----
    --------------
    gradient close to zero 
    3  iterations
    estimate: -77.09056 54.092 -49.81695 81.35279 146.798 272.3115 
    Function value: -9.081846e-12 
    ----- Initial parameters: -----
    fcn value: -0.09646085 
         parameter initial gradient free
    [1,]      1.00      0.091954550    1
    [2,]      0.82      0.073563640    1
    [3,]      0.64      0.055172730    1
    [4,]      0.46      0.036781820    1
    [5,]      0.28      0.018390910    1
    [6,]      0.10      0.009195455    1
    Condition number of the (active) hessian: 7652.405 
    -----Iteration 1 -----
    -----Iteration 2 -----
    -----Iteration 3 -----
    --------------
    gradient close to zero 
    3  iterations
    estimate: -77.09056 54.092 -49.81695 81.35279 146.798 272.3115 
    Function value: -9.081846e-12 
    ----- Initial parameters: -----
    fcn value: -0.09646085 
         parameter initial gradient free
    [1,]      1.00      0.091954550    1
    [2,]      0.82      0.073563640    1
    [3,]      0.64      0.055172730    1
    [4,]      0.46      0.036781820    1
    [5,]      0.28      0.018390910    1
    [6,]      0.10      0.009195455    1
    Condition number of the (active) hessian: 7652.405 
    -----Iteration 1 -----
    -----Iteration 2 -----
    -----Iteration 3 -----
    --------------
    gradient close to zero 
    3  iterations
    estimate: -77.09056 54.092 -49.81695 81.35279 146.798 272.3115 
    Function value: -9.081846e-12 
    ----- Initial parameters: -----
    fcn value: -0.09646085 
         parameter initial gradient free
    [1,]      1.00      0.091954550    1
    [2,]      0.82      0.073563640    1
    [3,]      0.64      0.055172730    1
    [4,]      0.46      0.036781820    1
    [5,]      0.28      0.018390910    1
    [6,]      0.10      0.009195455    1
    Condition number of the (active) hessian: 7652.405 
    -----Iteration 1 -----
    -----Iteration 2 -----
    -----Iteration 3 -----
    --------------
    gradient close to zero 
    3  iterations
    estimate: -77.09056 54.092 -49.81695 81.35279 146.798 272.3115 
    Function value: -9.081846e-12

Discussions similaires

  1. Algorithme Newton Raphson
    Par Chefcou dans le forum Calcul scientifique
    Réponses: 4
    Dernier message: 17/01/2013, 13h25
  2. Algorithme newton raphson
    Par 22011988 dans le forum SAS IML
    Réponses: 14
    Dernier message: 08/06/2012, 16h20
  3. algorithme régression logistique
    Par joyeux_lapin13 dans le forum MATLAB
    Réponses: 0
    Dernier message: 17/05/2010, 11h57

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