search for: linkinv

Displaying 20 results from an estimated 51 matches for "linkinv".

Did you mean: linking
2008 Apr 03
1
help with R semantics
...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("...
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.linkfun' make.l...
2002 Feb 27
1
Bug in glm.fit? (PR#1331)
...al(cc, parent.frame())) 16 } 17 if (is.null(weights)) 18 weights <- rep(1, nobs) 19 if (is.null(offset)) 20 offset <- rep(0, nobs) 21 variance <- family$variance 22 dev.resids <- family$dev.resids 23 aic <- family$aic 24 linkinv <- family$linkinv 25 mu.eta <- family$mu.eta 26 if (!is.function(variance) || !is.function(linkinv)) 27 stop("illegal `family' argument") 28 valideta <- family$valideta 29 if (is.null(valideta)) 30 valideta <- function(eta) TRU...
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, linkinv = linkinv, mu.eta = mu.eta, valideta...
2005 Apr 14
0
predict.glm(..., type="response") dropping names (and a propsed (PR#7792)
.../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)) + pmax((1/lambda) * eta^(1/lambda - 1), .Machine$d...
2007 Feb 10
2
error using user-defined link function with mixed models (LMER)
...L 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(", days, ")", sep="") str...
2005 Jun 14
1
New Family object for GLM models...
...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(y == 0, 1, y/mu)) + (1 - y) *...
2012 Aug 10
0
error applying user-defined link function to lmer
...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_Pos+f_Shape_con+f_Shape_...
2009 Jul 21
0
Custom Link/Family for lmer
...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(", days, ")", sep="") struct...
2010 Mar 26
1
Linear mixed models with custom link functions in R
...low 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(", days, ")", sep="") struct...
2005 Jun 16
1
mu^2(1-mu)^2 variance function for GLM
...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") }
2007 Aug 02
1
simulate() and glm fits
...d(seed) n <- length(fitted(fit)) theta <- model.matrix(fit$terms, data=fit$data) %*% coef(fit) ymat <- matrix(NA, nrow=n, ncol=nsim) for (s in 1:nsim) { if ("poisson"==fit$family$family) { ymat[,s] <- rpois(n, fit$family$linkinv(theta)) } else if ("binomial"==fit$family$family) { ymat[,s] <- rbinom(n, 1, fit$family$linkinv(theta)) } } as.data.frame(ymat) } # Eg: simulate.glm.hack(fit.poisson)[[1]] # [1] 1 6 4 7 5 9 7 3 3 4 2 4 3 7 4 4 7 2 4 6 simula...
2014 Jan 13
1
predict.glm line 28. Please explain
...pred <- predict.lm(object, newdata, se.fit, scale = 1, type = ifelse(type == "link", "response", type), terms = terms, na.action = na.action) switch(type, response = {pred <- family(object)$linkinv(pred)}, link = , terms = ) } } else { ## summary.survreg has no ... argument. if(inherits(object, "survreg")) dispersion <- 1. if(is.null(dispersion) || dispersion == 0) dispersion <- summary(object, dispersion=dispersion)$dispersion...
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
2005 Apr 13
3
A suggestion for predict function(s)
...else { pred <- predict.lm(object, newdata, se.fit, scale = 1, type = ifelse(type == "link", "response", type), terms = terms, na.action = na.action) switch(type, response = { pred <- family(object)$linkinv(pred) }, link = , terms = ) } } else { if (inherits(object, "survreg")) dispersion <- 1 if (is.null(dispersion) || dispersion == 0) dispersion <- summary(object, dispersion = dispersion)$dispersion residual.scale <- as.vector(sqrt(di...
2007 Jan 26
0
R crash with modified lmer code
...0) Y <- as.double(glmFit$y) mer <- .Call(mer_create, fl, Zt, X, Y, 0, nc, cnames) if (!is.null(start)) mer <- setOmega(mer, start) gVerb <- getOption("verbose") weights <- glmFit$prior.weights eta <- glmFit$linear.predictors linkinv <- quote(family$linkinv(eta)) mu.eta <- quote(family$mu.eta(eta)) mu <- family$linkinv(eta) variance <- quote(family$variance(mu)) dev.resids <- quote(family$dev.resids(Y, mu, weights)) LMEopt <- get("LMEoptimize<-") doLMEopt <- quote(LMEopt...
2015 Dec 30
1
typo in src/library/stats/man/family.Rd: names of 'validmu' and 'valideta' ??
...ub.com/wch/r-source/blob/trunk/src/library/stats/man/family.Rd>]) it says: valid.mu: logical function. Returns ?TRUE? if a mean vector ?mu? is within the domain of ?variance?. valid.eta: logical function. Returns ?TRUE? if a linear predictor ?eta? is within the domain of ?linkinv?. However, the real names of these elements are "validmu" and "valideta" (no dots); try names(poisson()) or names(binomial()) and see ... Can someone on R-core fix this and save me the trouble of filing a bug report ... ? Or have I misunderstood something? cheers...
2009 Mar 31
1
Can not get a prediction interval from Predict
I am trying to get a prediction interval from a glm regression. With newdat being my set of values to be fitted, and glmreg the name of my regression, I am using the following code. predict(glmreg, newdat, se.fit = TRUE, interval = "confidence", level = 0.90) The problem is that I am only getting the standard error and the fitted value, not a prediction interval. Any help would be
2004 Mar 01
1
glm logistic model, prediction intervals on impact af age 60 compared to age 30
...y=binomial("logit"),data=emrisk) #predictions for age 30 and 60 preds<-predict(model2d,data.frame(Age=c(30,60)),se.fit=TRUE) # prediction interval predsxx<-cbind(fit=preds$fit,lower=preds$fit-1.96*preds$se,upper=preds$fit+1.96*preds$se) #transformation model2dres<-family(model2d)$linkinv(predsxx) In my next step I want to know the confidence interval (CI) for the change in risk for the allergic event to occur for age 60 compared to age 30. The estimates from the model suggest a 80 pct. higher risk for age 60 compared to age 30. (100*model2dres[2]/model2dres[1]) But how should...
2011 Sep 01
3
betareg question - keeping the mean fixed?
...he following: svec<-c(qlogis(mean(data1$scaled)),0,0,0) f<-betareg(scaled~-1 | expt_label + grouped_hpi, data=data1, link.phi="log", control=betareg.control(start=svec)) I understood that y~-1 could be used to give a fixed mean of 0.5 however I get the following error: Error in linkinv(x %*% beta + offset) : Argument eta must be a nonempty numeric vector I think I can work round this by using: svec2<-c(qlogis(mean(data1$scaled)),0,0,0,0,0) f2<-betareg(scaled ~ expt_label + grouped_hpi | expt_label + grouped_hpi, data=data1, + link.phi="log",con...