similar to: lm() takes weights from formula environment

Displaying 20 results from an estimated 70000 matches similar to: "lm() takes weights from formula environment"

2020 Aug 09
2
lm() takes weights from formula environment
Doesn't this preclude "y ~ ." style notations? > On Aug 9, 2020, at 11:56 AM, Duncan Murdoch <murdoch.duncan at gmail.com> wrote: > > This is fairly clearly documented in ?lm: > > "All of weights, subset and offset are evaluated in the same way as variables in formula, that is first in data and then in the environment of formula." > > There
2020 Aug 09
0
lm() takes weights from formula environment
This is fairly clearly documented in ?lm: "All of weights, subset and offset are evaluated in the same way as variables in formula, that is first in data and then in the environment of formula." There are lots of possible places to look for weights, but this seems to me like a pretty sensible search order. In most cases the environment of the formula will have a parent environment
2020 Aug 09
0
lm() takes weights from formula environment
On 09/08/2020 3:01 p.m., John Mount wrote: > Doesn't this preclude "y ~ ." style notations? Yes, but you can use "y ~ . - w". Duncan Murdoch > >> On Aug 9, 2020, at 11:56 AM, Duncan Murdoch <murdoch.duncan at gmail.com> wrote: >> >> This is fairly clearly documented in ?lm: >> >> "All of weights, subset and offset are
2020 Aug 10
3
lm() takes weights from formula environment
I wish I had started with "I am disappointed that lm() doesn't continue its search for weights into the calling environment" or "the fact that lm() looks only in the formula environment and data frame for weights doesn't seem consistent with how other values are treated." But I did not. So I do apologize for both that and for negative tone on my part. Simplified
2020 Aug 10
1
lm() takes weights from formula environment
Thank you for your suggestion. I do know how to work around the issue. I usually build a fresh environment as a child of base-environment and then insurt the weights there. I was just trying to provide an example of the issue. emptyenv() can not be used, as it is needed for the eval (errors out even if weights are not used with "could not find function list"). For some applications
2008 May 30
2
scoping problem when calling lm(precomputed formula, weights) from function (PR#11540)
I've run into a scoping problem in R. I'm calling a function that * creates a formula * calculates a weight vector * calls lm with that formula and weights This fails. Here's a simplified reproduce example: # f works, g doesn't, h is a workaround rm(w) data <- data.frame(y=runif(20), x=runif(20), z=runif(20)) f <- function(k){ w <- data$z^k coef(lm(y~x, data
2020 Aug 10
0
lm() takes weights from formula environment
On 10/08/2020 1:42 p.m., John Mount wrote: > I wish I had started with "I am disappointed that lm() doesn't continue its search for weights into the calling environment" or "the fact that lm() looks only in the formula environment and data frame for weights doesn't seem consistent with how other values are treated." Normally searching is done automatically by
2010 Dec 16
1
defining a formula method for a weighted lm()
In the vcdExtra package on R-Forge, I have functions and generic methods for calculating log odds ratios for R x C x strata tables. I'd like to define methods for fitting weighted lm()s to the resulting loddsratio objects, but I'm having problems figuring out how to do this generally. # install.packages("vcdExtra", repos="http://R-Forge.R-Project.org")
2006 Mar 16
2
DIfference between weights options in lm GLm and gls.
Dear R-List users, Can anyone explain exactly the difference between Weights options in lm glm and gls? I try the following codes, but the results are different. > lm1 Call: lm(formula = y ~ x) Coefficients: (Intercept) x 0.1183 7.3075 > lm2 Call: lm(formula = y ~ x, weights = W) Coefficients: (Intercept) x 0.04193 7.30660 > lm3 Call:
2010 Oct 22
1
lm looking for weights outside of the user-defined function
Dear R'ers, I am fighting with a problem that is driving me crazy. I use "lm" in my user-defined function, but it seems to be looking for weights outside of my function's environment: ### Generating example data: x<-data.frame(y=rnorm(100,0,1),a=rnorm(100,1,1),b=rnorm(100,2,1)) myweights<-runif(100) data.for.regression<-x[1:3] ### Creating function
2006 Jun 22
2
weights in lm, glm (PR#9023)
Full_Name: James Signorovitch Version: 2.2.1 OS: WinXP Submission from: (NULL) (134.174.182.203) In the code below, fn1() and fn2() fail with the messages given in the comments. Strangely, fn2() fails for all data sets I've tried except for those with 100 rows. The same errors occur if glm() is used in place of lm(), or if R 2.1.1 is used on a unix system. Thanks for looking into this.
2006 Aug 04
2
why does lm() not allow for negative weights?
Dear List, Why do commonly used estimator functions (such as lm(), glm(), etc.) not allow negative case weights? I suspect that there is a good reason for this. Yet, I can see reasonable cases when one wants to use negative case weights. Take lm() for example: ### n <- 20 Y <- rnorm(n) X <- cbind(rep(1,n),runif(n),rnorm(n)) Weights <- rnorm(n) # Includes Pos and Neg Weights Weights
2013 Mar 11
1
glm and lm can't find weights
Hello, and apologies for not providing an example. However, my question is more general. I have a lengthy function. This function is using another internal function that modifies the data frame I am reading in. This internal function is using the command model.frame (with data and weights inside) and returns a data frame I am using for further analyses. However, when I try to run my function
2006 Sep 03
2
lm, weights and ...
> lm2 <- function(...) lm(...) > lm2(mpg ~ wt, data=mtcars) Call: lm(formula = ..1, data = ..2) Coefficients: (Intercept) wt 37.285 -5.344 > lm2(mpg ~ wt, weights=cyl, data=mtcars) Error in eval(expr, envir, enclos) : ..2 used in an incorrect context, no ... to look in Can anyone explain why this is happening? (Obviously this is a manufactured example, but it
2009 Jun 01
1
LM/GLM can't find weights vector from within a function (PR#13735)
Full_Name: Alberto Gaidys Version: 2.9.0 OS: Mac OS X 10.5.7 Submission from: (NULL) (201.81.185.155) When calling LM or GLM from within a function, R gives a message error that it can't find the specified weights object "Erro em eval(expr, envir, enclos) : objeto 'W' n?o encontrado" (Error in eval(expr, envir, enclos) : object 'W' not found). The call from within
2008 Apr 29
2
function to generate weights for lm?
Hi, I would like to use a weighted lm model to reduce heteroscendasticity. I am wondering if the only way to generate the weights in R is through the laborious process of trial and error by hand. Does anyone know if R has a function that would automatically generate the weights need for lm? Thanks, -- Tom [[alternative HTML version deleted]]
2013 Jan 29
3
how to suppress the intercept in an lm()-like formula method?
I'm trying to write a formula method for canonical correlation analysis, that could be called similarly to lm() for a multivariate response: cancor(cbind(y1,y2,y3) ~ x1+x2+x3+x4, data=, ...) or perhaps more naturally, cancor(cbind(y1,y2,y3) ~ cbind(x1,x2,x3,x4), data=, ...) I've adapted the code from lm() to my case, but in this situation, it doesn't make sense to include an
2017 Aug 03
2
rnorm is not truly random used in the lm function
To whom it may concern, I happened to run the following R code just to check the layout of the output, but found that the code doesn't work the way I thought it should work. '' > lm(rnorm(100) ~ rnorm(100)) Call: lm(formula = rnorm(100) ~ rnorm(100)) Coefficients: (Intercept) -0.07966 Warning messages: 1: In model.matrix.default(mt, mf, contrasts) : the response appeared
2003 Jun 12
1
help with weights in lm and glm
Dear all Could someone explain to why weights does not works in lm and glm in the example below? Thanks in advance, Roseli. function(model){ www<-fitted(model) lm(formula(model),weights=www) } The message error is: Error in eval(expr,envir,enclos): object "www" not found. [[alternate HTML version deleted]]
2006 May 20
1
(PR#8877) predict.lm does not have a weights argument for newdata
Dear R developers, I am a little disappointed that my bug report only made it to the wishlist, with the argument: Well, it does not say it has. Only relevant to prediction intervals. predict.lm does calculate prediction intervals for linear models from weighted regression, so they should be correct, right? As far as I can see they are bound to be wrong in almost all cases, if no weights