search for: validmu

Displaying 18 results from an estimated 18 matches for "validmu".

Did you mean: valid
2005 Jun 16
1
mu^2(1-mu)^2 variance function for GLM
...burn suggested using the variance function mu^2(1-mu)^2. This variance function isn't readily available in R's `quasi' family object, but it seems to me that the following definition could be used: }, "mu^2(1-mu)^2" = { variance <- function(mu) mu^2 * (1 - mu)^2 validmu <- function(mu) all(mu > 0) && all(mu < 1) dev.resids <- function(y, mu, wt) 2 * wt * ((2 * y - 1) * (log(ifelse(y == 0, 1, y/mu)) - log(ifelse(y == 1, 1, (1 - y)/(1 - mu)))) - 2 + y/mu + (1 - y)/(1 - mu)) I've modified the `quasi' function accord...
2015 Dec 30
1
typo in src/library/stats/man/family.Rd: names of 'validmu' and 'valideta' ??
...gt;]) 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 Ben Bolker
2005 Jun 14
1
New Family object for GLM models...
...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) * log(ifelse(y == 1, 1, (1 - y)/(1 - mu)))) aic <- function(y, n, mu...
2002 Feb 27
1
Bug in glm.fit? (PR#1331)
...ly$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) TRUE 31 validmu <- family$validmu 32 if (is.null(validmu)) 33 validmu <- function(mu) TRUE 34 if (is.null(mustart)) { 35 eval(family$initialize) 36 } 37 else { 38 mukeep <- mustart 39 eval(family$initialize) 40 mustart <- mukeep...
2019 Apr 26
1
Error in glm(..., family=quasi(..., variance=list(...)))
In a glm() call using a quasi() family, one may define a custom variance function in the form of a "list containing components varfun, validmu, dev.resids, initialize and name" (quoting the help page for family). In trying to do so, I run into the following issue that I have not seen discussed previously: x <- runif(1000, min=0, max=1) y <- x + rnorm(1000, mean=0, sd=1)*x^(3/4) vf <- function(mu) { abs(mu)^(3/4) } vm <...
2007 Feb 10
2
error using user-defined link function with mixed models (LMER)
...v = linkinv, mu.eta = mu.eta, valideta = valideta, name = link), class = "link-glm") } # Modified binomial family function (that allows logexp link function) logexposure<-function (link="logexp",ExposureDays) { variance <- function(mu) mu * (1 - mu) validmu <- function(mu) all(mu > 0) && all(mu < 1) dev.resids <- function(y, mu, wt) .Call("binomial_dev_resids", y, mu, wt, PACKAGE = "stats") aic <- function(y, n, mu, wt, dev) { m <- if (any(n > 1)) n else wt...
2006 Jan 14
2
initialize expression in 'quasi' (PR#8486)
This is not so much a bug as an infelicity in the code that can easily be fixed. The initialize expression in the quasi family function is, (uniformly for all links and all variance functions): initialize <- expression({ n <- rep.int(1, nobs) mustart <- y + 0.1 * (y == 0) }) This is inappropriate (and often fails) for variance function "mu(1-mu)".
2007 Aug 10
0
half-logit and glm (again)
...git.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") } binomial(halflogit()) Family: binomial Link function: half.logit ############################# I based this off the help for the family() function. So I try to call glmmPQL...
2012 Mar 14
1
Glm and user defined variance functions
...distribution. However, I want to use an overdispersion parameter that varies (dependent on the length of a stretch of road) so glm.nb will not do. >From what I've read I should be able to do this using GLM by specifying my own quasi family and describing the variance function using varfun, validmu, dev.resids and initiate. However I cannot find any detailed discussion of this method. Any help would be appreciated. ps I've done this in SAS so I know it should be possible! Craig
2003 Jan 16
3
Overdispersed poisson - negative observation
Dear R users I have been looking for functions that can deal with overdispersed poisson models. Some (one) of the observations are negative. According to actuarial literature (England & Verall, Stochastic Claims Reserving in General Insurance , Institute of Actiuaries 2002) this can be handled through the use of quasi likelihoods instead of normal likelihoods. The presence of negatives is not
2012 Aug 10
0
error applying user-defined link function to lmer
...git.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_con:f_Pos+(-1+cNoise*f_Pos|f_Subject), data=dens_data, family=binomial(ha...
2005 Aug 12
1
Help converting a function from S-Plus to R: family$weight
...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" "inverse" "deriv" [6] "initialize" "variance" "deviance" "weight" > My question concerns...
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
2005 Jun 02
1
glm with variance = mu+theta*mu^2?
...ferentiation data based on quasi-likelihoods" between variance = phi*mu (quasi-Poisson), variance = phi*mu^2 (quasi-exponential), and variance = mu+theta*mu^2. The "quasi" function accepted for the family argument in "glm" generates functions "variance", "validmu", and "dev.resids". I can probably write functions to mimic the "quasi" function. However, I have two questions in regard to this: (1) I don't know what to use for "dev.resids". This may not matter for fitting. I can try a couple of different thing...
2006 May 04
1
quasi glm start values
Hi, I'm tying to fit a glm using quasi with variance=mu(1-mu) (to try and get "well behaved" residuals). I get an error message: "cannot find valid starting values, please specify some". I have tried using start= and specifying coefficients from a previous fit (with different error structure) but get the same message. What would be valid starting values? I am using a
2007 Sep 22
0
How to explain the meaning of mu in the variance function of GLMs?
...uasi family will accept the literal character string (or unquoted as a name/expression) specifications "constant", "mu(1-mu)", "mu", "mu^2" and "mu^3", a length-one character vector taking one of those values, or a list containing components varfun, validmu, dev.resids, initialize and name. Thanks very much. -- With Kind Regards, oooO::::::::: (..)::::::::: :\.(:::Oooo:: ::\_)::(..):: :::::::)./::: ::::::(_/:::: ::::::::::::: [***********************************************************************] Zhi Jie,Zhang ,PHD Tel:86-21-54237149 Dept. of Epi...
2010 Oct 19
2
Strange glm(, quasipoisson) error
Dear list, I have recently encountered an odd error when running glm(dep~indep, quasipoisson): while, with a subset of my data, I could get a perfectly reasonable model, once I include all of my data (17K+ observations, 29 variables), I get the following error: Error in if (any(y < 0)) stop("negative values not allowed for the quasiPoisson family") : missing value where
2011 Apr 19
1
How to Extract Information from SIMEX Output
...0, 0, y[, 1]/n) weights <- weights * n mustart <- (n * y + 0.5)/(n + 1) } else stop("for the binomial family, y must be a vector of 0 and 1's\n", "or a 2 column matrix where col 1 is no. successes and col 2 is no. failures") }) .. ..$ validmu :function (mu) .. ..$ valideta :function (eta) .. ..$ simulate :function (object, nsim) .. ..- attr(*, "class")= chr "family" ..$ linear.predictors: Named num [1:1615] -2.162 -0.87 -1.485 -2.656 -0.818 ... .. ..- attr(*, "names")= chr [1:1615] &quot...