[R] help with R semantics

Ken Knoblauch ken.knoblauch at inserm.fr
Thu Apr 3 17:44:32 CEST 2008


Hi,
Charles Annis, P.E. <Charles.Annis <at> StatisticalEngineering.com> writes:
> logit.FC <- function(POD.floor = 0, POD.ceiling =1)
> {   if (POD.floor < 0 | POD.floor > 1) stop ("POD.floor must be between zero
> and one.") 
>     if (POD.ceiling < 0 | POD.ceiling > 1) stop ("POD.ceiling must be
> between zero and one.")
>     if (POD.ceiling - POD.floor < difference.criterion) stop
> (paste("POD.ceiling-POD.floor difference must be greater than
> ",difference.criterion," to discourage answer-shopping.", sep=""))
>     linkfun <- function(mu) {
>     mu <- qlogis( (mu - POD.floor)/(POD.ceiling - POD.floor) )
>     }
>     linkinv <- function(eta) {
>     eta <- POD.floor + (POD.ceiling - POD.floor)*plogis(eta)
>     }
>     mu.eta <- function(eta) {
>     (POD.ceiling - POD.floor)*dlogis(eta)# derivitaive of mu with respect to
> eta
>     }
>     valideta <- function(eta) TRUE
>     link <- paste("logit.FC(", POD.floor, ",", POD.ceiling, ")", sep = "")
>     structure(list(linkfun = linkfun, linkinv = linkinv, mu.eta = mu.eta, 
>     valideta = valideta, name = link), class = "link-glm")
> }
> 
> Thanks.
> 
> Charles Annis, P.E.
> 
>  <mailto:Charles.Annis <at> StatisticalEngineering.com>
> Charles.Annis <at> StatisticalEngineering.com
> phone: 561-352-9699
> eFax:  614-455-3265
>  <http://www.StatisticalEngineering.com>
> http://www.StatisticalEngineering.com
> 
> 	[[alternative HTML version deleted]]
> 
I defined the following link in the psyphy package that might
be along similar lines
> probit.lambda
function (m = 2, lambda = 0) 
{
    m <- as.integer(m)
    if (m < 2) 
        stop("m must be an integer > 1")
    linkfun <- function(mu) {
        mu <- pmax(mu, 1/m + .Machine$double.eps)
        mu <- pmin(mu, 1 - lambda)
        qnorm((m * mu - 1)/(m * (1 - lambda) - 1))
    }
    linkinv <- function(eta) {
        1/m + ((m - 1)/m - lambda) * pnorm(eta)
    }
    mu.eta <- function(eta) ((m - 1)/m - lambda) * dnorm(eta)
    valideta <- function(eta) TRUE
    link <- paste("probit.lambda(", m, ",", lambda, ")", sep = "")
    structure(list(linkfun = linkfun, linkinv = linkinv, mu.eta = mu.eta, 
        valideta = valideta, name = link), class = "link-glm")
}
<environment: namespace:psyphy>

HTH,

ken



More information about the R-help mailing list