R/p.compute.R

Defines functions p.compute

Documented in p.compute

# Modification version 1.1: ajout du terme de decalage pour les covariables
# comme argument supplementaire optionnel
# Version 1.3: Correction d'une erreur avec ce terme de decalage 
p.compute <-
function(alpha,decal=0)
{
    p <- NULL
    if((length(alpha)==1)&&(is.na(alpha))) p <- 1
    else
    {
        for(i in 1:length(alpha))
        {
            if(alpha[i]==-Inf) p[i] <- 0
            else if(alpha[i]==Inf) p[i] <- 1-ifelse(i==1,0,sum(p[1:(i-1)]))
            else 
            {
                cum.p <- ifelse(i==1,0,sum(p[1:(i-1)]))
                cum.alpha <- sum(alpha[1:i][!is.infinite(alpha[1:i])])+decal
                p[i] <- exp(cum.alpha)/(1+exp(cum.alpha))-cum.p
            }
        }
        p[length(alpha)+1] <- 1-sum(p)
    }
    p
}

Try the LCAextend package in your browser

Any scripts or data that you put into this service are public.

LCAextend documentation built on May 2, 2019, 2:02 a.m.