search for: linkfun

Displaying 20 results from an estimated 36 matches for "linkfun".

2008 May 20
1
"NOTE" warning
Dear all I am using NAMESPACE in my package but I would like the user to be able to overwrite four functions: own.linkfun, own.linkinv, own.mu.eta and own.valideta. These are used to defined "own" link functions. Is there any way of doing that without getting the when I am checking the package? This is what I am getting: make.link.gamlss : linkfun: no visible binding for global variable 'own.linkfu...
2008 Apr 03
1
help with R semantics
...g > 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 w...
2008 Jun 13
1
Writing a new link for a GLM.
Hi, I wish to write a new link function for a GLM. R's glm routine does not supply the "loglog" link. I modified the make.link function adding the code: }, loglog = { linkfun <- function(mu) -log(-log(mu)) linkinv <- function(eta) exp(-exp(-eta)) mu.eta <- function(eta) exp(-exp(-eta)-eta) valideta <- function(eta) all(eta != 0) }, stop(sQuote(link), " link not recognised")) structure(list(linkfun = linkfun, lin...
2005 Apr 14
0
predict.glm(..., type="response") dropping names (and a propsed (PR#7792)
...test other cases. Best, Andy --- R-beta/src/library/stats/R/family.R 2005-03-04 04:40:03.000000000 -0500 +++ R-beta-fix/src/library/stats/R/family.R 2005-04-14 08:30:03.000000000 -0400 @@ -25,9 +25,9 @@ else if(!is.character(link) && !is.na(lambda <- as.numeric(link))) { linkfun <- function(mu) mu^lambda linkinv <- function(eta) - pmax(.Machine$double.eps, eta^(1/lambda)) + pmax(eta^(1/lambda), .Machine$double.eps) mu.eta <- function(eta) - pmax(.Machine$double.eps, (1/lambda) * eta^(1/lambda - 1)) + pm...
2007 Feb 10
2
error using user-defined link function with mixed models (LMER)
...ith my user-defined link function. Actually, glmmPQL seems to work, but as I want to evaluate a suite of competing models, I'd like to use ML or REML estimation methods in order to end up with meaningful log-likelihoods. Here's the link function I use: logexp <- function(days = 1) { linkfun <- function(mu) qlogis(mu^(1/days)) linkinv <- function(eta) plogis(eta)^days mu.eta <- function(eta) days*.Call("logit_mu_eta", eta, PACKAGE = "stats")*plogis(eta)^(days-1) valideta <- function(eta) TRUE link <- paste("logexp(&qu...
2005 Jun 14
1
New Family object for GLM models...
...someone could help me provide a solution to this problem. I have appended the function i wrote. Add.haz<-function () { env <- new.env(parent = .GlobalEnv) assign(".nziek", nziek, envir = env) famname<-"Addhaza" link="addlink" linkfun<-function(mu) -log(1-mu) linkinv<-function(eta) 1-exp(-eta) variance<-function(mu) mu*(1-mu) validmu<-function(mu) all(mu > 0) && all(mu < 1) mu.eta<-function(mu) 1/(1-mu) dev.resids <- function(y, mu, wt) 2 * wt * (y * log(ifelse...
2012 Aug 10
0
error applying user-defined link function to lmer
...{ half.logit=function(mu) qlogis(2*mu-1) half.logit.inv=function(eta) .5*plogis(eta)+.5 half.logit.deriv=function(eta) .5*(exp(eta/2)+exp(-eta/2))^-2 half.logit.inv.indicator=function(eta) TRUE half.logit.indicator=function(mu) mu>.5 & mu<1 link <- "half.logit" structure(list(linkfun = half.logit, linkinv = half.logit.inv, ??????????????????? mu.eta = half.logit.deriv, validmu = half.logit.indicator ,valideta = half.logit.inv.indicator, name = link), ?????????????? class = "link-glm") } # submit halflogit function to lmer rcNrPSrcNxPSxP<-lmer(Correct~-1+cNoise*f_Po...
2009 Jul 21
0
Custom Link/Family for lmer
...sly been using glm with a custom link function, but my understanding is that lmer does not currently allow a custom link. Therefore, I was investigating if other procedures for mixed models will allow a custom link function. here is the custom link function: logexp <- function(days = 1) { linkfun <- function(mu) qlogis(mu^(1/days)) linkinv <- function(eta) plogis(eta)^days mu.eta <- function(eta) days * plogis(eta)^(days-1) * .Call("logit_mu_eta", eta, PACKAGE = "stats") valideta <- function(eta) TRUE link <- paste("logexp("...
2010 Mar 26
1
Linear mixed models with custom link functions in R
...ow I've been doing this with glm() is shown below to illustrate what I'm hoping to scale up to a mixed model. Thanks very much for your time and thoughts. ----------------- library(MASS) logexp <- function(days = 1) ##Custom link function from Shaffer (2004) Auk 121:526-540. { linkfun <- function(mu) qlogis(mu^(1/days)) linkinv <- function(eta) plogis(eta)^days mu.eta <- function(eta) days * plogis(eta)^(days-1) * .Call("logit_mu_eta", eta, PACKAGE = "stats") valideta <- function(eta) TRUE link <- paste("logexp("...
2005 Jun 16
1
mu^2(1-mu)^2 variance function for GLM
...\"constant\"", variancetemp), domain = NA)) initialize <- expression({ n <- rep.int(1, nobs) mustart <- y + 0.1 * (y == 0) }) aic <- function(y, n, mu, wt, dev) NA structure(list(family = "quasi", link = linktemp, linkfun = stats$linkfun, linkinv = stats$linkinv, variance = variance, dev.resids = dev.resids, aic = aic, mu.eta = stats$mu.eta, initialize = initialize, validmu = validmu, valideta = stats$valideta, varfun = variancetemp), class = "family") }
2009 Jan 23
4
glm binomial loglog (NOT cloglog) link
I would like to do an R glm() with family = binomial(link="loglog") Right now, the cloglog link exists, which is nice when the data have a heavy tail to the left. I have the opposite case and the loglog link is what I need. Can someone suggest how to add the loglog link onto glm()? It would be lovely to have it there by default, and it certainly makes sense to have the two opposite
2010 Jan 12
1
Problems with betareg()
Hi, In using the betareg package, I encounter the following error message: Error in lm.wfit(x, linkfun(y), weights, offset = offset) : NA/NaN/Inf in foreign function call (arg 4) Any help will be most appreciated. Thanks in advance. Alex
2012 Aug 15
3
Basic question -loading data
Hi all, New user here - I include the following command in the prompt read.csv("document.csv", header = TRUE ) and the output shows up. But when I include the following command summary(data) I get the following message "Error in object[[i]] : object of type 'closure' is not subsettable" Can someone please advise why R is not reading my data? Thanks
2012 Mar 02
1
Vector errors and missing values
Hi, I am trying to run two Non-Gaussian regressions: logistic and probit. I am receiving two different errors when I try to run these regressions and I am not sure what they mean or how to fix my syntax. Here is the logistic regression error: Error in family$linkfun(mustart) : Argument mu must be a nonempty numeric vector Here is the probit regression error: Error in pmax(eta, -thresh) : cannot mix 0-length vectors with others The dataset that I am using has some missing data. R puts NA values in place of the missing values. I am not sure if this is what...
2006 Jul 30
1
Parametric links for glm?
...and glm that (essentially) added a "..." argument to binomial permitting the parameters to be passed down to the fitting routines. So, in the Gosset case, for example, had the following passage in make.link, involving a free degrees of freedom parameter nu: }, Gosset = { linkfun <- function(mu) qt(mu,nu) linkinv <- function(eta) { thresh <- -qqt(.Machine$double.eps,nu) eta <- pmin(thresh, pmax(eta, -thresh)) pt(eta,nu) } mu.eta <- function(eta) pmax(dt(eta,nu), .Machine$double.eps) va...
2005 Aug 12
1
Help converting a function from S-Plus to R: family$weight
Hi all I am converting an S-Plus function into R. The S-Plus code uses some of the glm families, and family objects. The family objects in S-Plus and R have many different features, for example: In R: > names(Gamma()) [1] "family" "link" "linkfun" "linkinv" "variance" [6] "dev.resids" "aic" "mu.eta" "initialize" "validmu" [11] "valideta" In S-Plus: > names(Gamma()) [1] "family" "names" "link"...
2005 Jul 13
1
Fieller's Conf Limits and EC50's
....unscaled b0<-coef[1] b1<-coef[2] var.b0<-vcov[1,1] var.b1<-vcov[2,2] cov.b0.b1<-vcov[1,2] alpha<-1-conf.level zalpha.2 <- -qnorm(alpha/2) gamma <- zalpha.2^2 * var.b1 / (b1^2) eta = family(obj)$linkfun(p) #based on calcs in V&R's dose.p EC50 <- (eta-b0)/b1 const1 <- (gamma/(1-gamma))*(EC50 + cov.b0.b1/var.b1) const2a <- var.b0 + 2*cov.b0.b1*EC50 + var.b1*EC50^2 - gamma*(var.b0 - cov.b0.b1^2/var.b1) const2 <- zalpha.2...
2006 Apr 16
3
second try; writing user-defined GLM link function
I apologize for my earlier posting that, unbeknownst to me before, apparently was not in the correct format for this list. Hopefully this attempt will go through, and no-one will hold the newbie mistake against me. I could really use some help in writing a new glm link function in order to run an analysis of daily nest survival rates. I've struggled with this for weeks now, and can at least
2002 Mar 29
1
glm start/offset bugs (PR#1422)
...weights, ! offset=offset, family=family, control=control, intercept=TRUE)$deviance } *************** *** 152,156 **** "and correspond to initial coefs for", deparse(xnames))) ! else as.vector(if (NCOL(x) == 1) x * start else x %*% start) else family$linkfun(mustart) mu <- linkinv(eta) --- 152,157 ---- "and correspond to initial coefs for", deparse(xnames))) ! else offset + ! as.vector(if (NCOL(x) == 1) x * start else x %*% start) else family$linkfun(mustart) mu <- linkinv(eta) --fupGvO...
2020 Mar 23
5
help with rchk warnings on Rf_eval(Rf_lang2(...))
Thanks, that's really useful. One more question for you, or someone else here: const ArrayXd glmLink::linkFun(const ArrayXd& mu) const { return as<ArrayXd>(::Rf_eval(::Rf_lang2(as<SEXP>(d_linkFun), as<SEXP>(Rcpp::NumericVector(mu.data(), mu.data() + mu.size())) ), d_rho); } I guess I need that to read PROTECT(::Rf_eval(PROTECT(::Rf_lang2(...),...) , but as w...