As part of my job, I need to fit a bunch of 'generalised logistic' (GL)* regression models (with some special restrictions that are not pertinent to this question). There is no package that currently allows me to do this so I have written my own function which just optimises the likelihood. It is messy, and not that general at the moment as it is tailored towards the specific job I need it to do.
I was thinking about turning it into a more general package, it would be the first I had written.
My questions are:
1) Am I missing a trick, and is it possible to just bolt on my own link function to GLM rather than writing it from scratch?
2) Is their information somewhere on the standards expected for a regression package, e.g., expected "summary" output, standardised names for output, standard formula input, etc?
3) Are there any good "how to write a package in R" resources that you could recommend?
I'm happy to be more specific if needed. Many thanks for any replies.
Best.
It should be possible to create your own GLM link function. You can do the following:
my_link_function <- function(mu)
{
# Body of your link function
}
my_inverse_link_function <- function(eta)
{
# Body of your inverse link function
}
my_derivative_function <- function(eta)
{
# function describing dmu / delta
}
my_valid_eta_function <- function(eta)
{
# return TRUE if eta is in domain of inverse_link_function, otherwise FALSE
}
my_link <- list(linkfun = my_link_function,
linkinv = my_inverse_link_function,
mu.eta = my_derivative_function,
valideta = my_valid_eta_function,,
name = "my_link")
class(my_link) <- "link-glm"
Now you can do this:
glm(my_var1 ~ my_var2, family = binomial(my_link))