similar to: scoping problem when calling lm(precomputed formula, weights) (PR#11543)

Displaying 20 results from an estimated 7000 matches similar to: "scoping problem when calling lm(precomputed formula, weights) (PR#11543)"

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
2008 May 29
1
help (using ?) does not handle trailing whitespace (PR#11537)
> ?agrep > Results in: No documentation for 'agrep ' in specified packages and libraries: you could try 'help.search("agrep ")' There is white space after agrep, that ? doesn't ignore. --please do not edit the information below-- Version: platform = i486-pc-linux-gnu arch = i486 os = linux-gnu system = i486, linux-gnu status = major = 2 minor =
2008 Jun 10
0
browser() exits when not desired, in three different scenarios (PR#11623)
Here are three different scenarios in which the browser() exits when I don't want it to. These are all related to the browser accepting either c or (return) to exit. I would like an option to turn off the (return) behavior in order to avoid these problems. # Case 1 - when calling help # Note, I am using ESS in emacs; this is probably an interaction # with ESS handling of ? help. > f
2008 Jun 11
0
[ESS] browser() exits when not desired, in three different scenarios (PR#11634)
Tim, I have reported some similar issues a while back and there was some discussion on this topic: http://tolstoy.newcastle.edu.au/R/devel/06/03/4609.html Good luck, Kevin On Tue, Jun 10, 2008 at 6:47 PM, Tim Hesterberg <timhesterberg at gmail.com> wrote: > Here are three different scenarios in which the browser() exits > when I don't want it to. These are all related to the
2008 Jun 02
0
(PR#11537) help (using ?) does not handle trailing whitespace
>>>>> "BDR" == Prof Brian Ripley <ripley at stats.ox.ac.uk> >>>>> on Fri, 30 May 2008 22:34:28 +0100 (BST) writes: BDR> I think it is ESS that is parsing this as a help BDR> request (so it can divert it to an ESS buffer). BDR> Looks like this is an ESS issue, not an R one. yes, indeed, hence much more belonging the ESS-help
2008 Aug 22
1
save() should not overwrite a file if an error occurs (PR#12583)
If save() fails because an object is not found, it should not overwrite an existing file. > a <- 1:9 > save(a, file = "a.rda") > rm(a) > load("a.rda") > a [1] 1 2 3 4 5 6 7 8 9 > rm(a) > save(a, file = "a.rda") Error in save(a, file = "a.rda") : object 'a' not found > load("a.rda") Error in
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
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
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]]
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
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 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 09
3
lm() takes weights from formula environment
I know this programmers can reason this out from R's late parameter evaluation rules PLUS the explicit match.call()/eval() lm() does to work with the passed in formula and data frame. But, from a statistical user point of view this seems to be counter-productive. At best it works as if the user is passing in the name of the weights variable instead of values (I know this is the obvious
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")
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 Sep 26
0
The 'data' argument and scoping in nls
Hi Everyone, I seek guidance to avoid wasting a lot of time and doing things badly. Several times I've solved my problems, only to find that my solutions were clumsy and not robust. (see "nested" getInitial calls; variable scoping problems: Solved?? http://finzi.psych.upenn.edu/R/Rhelp02a/archive/139943.html for one truly horrible approach). I'm sure that I'm not the
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
2004 Mar 10
1
Question concerning library function "nlme" and lexical scoping
I am running into problems calling the library function nlme from within another function. Basically,the following function (with v a list containing data and initialization values) > testfunc function(dat=v) { test<-nlsList(result~a+(b-a)/(1+(conc/(c+z*cdiff))^d) |rep,start=dat$init,data=dat$mixeddat) return(nlme(test,random=b~1)) } produces the error message Error in eval(expr, envir,
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