# R/glm.fun.R In gpls: Classification using generalized partial least squares

```"h" <-
# g-inverse, i.e. inverse funtion of link function
if (family=="normal"){
else cat("link function not recognized for ",family, " choose from identity!\n")
}
else if (family=="binomial") {
{
ifelse(is.infinite(exp(x)),1,exp(x)/(1+exp(x)))

}
else cat("link function not recognized for ",family, " choose from logit,probit and cloglog!\n")
}
else if (family=="poisson") {
else cat("link function not recognized for ", family, " chosse from log!\n" )
}
else if (family=="gamma"){
else cat("link function not recognized for ",family, " choose from reciprocal!\n")
}
}

"hp" <-
# first derivative of h wrt eta, the linear predictor

if (family=="normal"){
else cat("link function not recognized for ",family, " choose from identity!\n")}
else if (family=="binomial") {
else cat("link function not recognized for ",family, " choose from logit,probit and cloglog!\n")
}
else if (family=="poisson") {
else cat("link function not recognized for ", family, " chosse from log!\n" )
}
}

"g" <-
# mu-link function for generalized linear model
if (family=="normal"){
else cat("link function not recognized for ",family, " choose from identity!\n")}
if (family=="binomial") {
else cat("link function not recognized for ",family, " choose from logit,probitand cloglog!\n")
}
else if (family=="poisson") {
else cat("link function not recognized for ", family, " choose from log!\n" )
}
}

"bpp" <-
# variance function
if (family=="normal"){
else cat("link function not recognized for ",family, " choose from identity!\n")}
else if (family=="binomial") {
else cat("link function not recognized for ",family, " choose from logit,probit and cloglog!\n")
}
else if (family=="poisson") {
else cat("link function not recognized for ", family, " chosse from log!\n" )
}
}

"psi" <-
function(x,family="normal") {
# initial value for dependent variable
if (family=="binomial") return((x+0.5)/2)
else if (family=="poisson") return(log(x+0.5))
else return(x)}

"probcal" <- function(y,eta)
{ # return P(Y=y), now only works for logit link for binomial family
p <- 0
for ( i in 1:length(y))
p[i] <- ifelse(y[i]==1, exp(eta[i])/(1+exp(eta[i])) ,1/(1+exp(eta[i])))
p
}
```

## Try the gpls package in your browser

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

gpls documentation built on Nov. 8, 2020, 6:50 p.m.