similar to: help with weights in lm and glm

Displaying 20 results from an estimated 11000 matches similar to: "help with weights in lm and glm"

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
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.
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
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
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 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:
2011 Aug 28
4
How do I get a weighted frequency table?
? stato filtrato un testo allegato il cui set di caratteri non era indicato... Nome: non disponibile URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20110828/d35f51a1/attachment.pl>
2010 Apr 16
2
Weights in binomial glm
I have some questions about the use of weights in binomial glm as I am not getting the results I would expect. In my case the weights I have can be seen as 'replicate weights'; one respondent i in my dataset corresponds to w[i] persons in the population. From the documentation of the glm method, I understand that the weights can indeed be used for this: "For a binomial GLM prior
2005 Aug 04
0
add1.lm and add1.glm not handling weights and offsets properly (PR#8049)
I am using R 2.1.1 under Mac OS 10.3.9. Two related problems (see notes 1. and 2. below) are illustrated by results of the following: y <- rnorm(10) x <- z <- 1:10 is.na(x[9]) <- TRUE lm0 <- lm(y ~ 1) lm1 <- lm(y ~ 1, weights = rep(1, 10)) add1(lm0, scope = ~ x) ## works ok add1(lm1, scope = ~ x) ## error lm2 <- lm(y ~ 1, offset = 1:10) add1(lm0, scope = ~ z) ##
2005 Aug 05
0
(PR#8049) add1.lm and add1.glm not handling weights and
David, Thanks. The reason add1.lm (and drop1.lm) do not support offsets is that lm did not when they were written, and the person who added offsets to lm did not change them. (I do wish they had not added an offset arg and just used the formula as in S's glm.) That is easy to add. For the other point, some care is needed if 'x' is supplied and the upper scope reduces the number
2008 May 30
0
scoping problem when calling lm(precomputed formula, weights) (PR#11543)
On 5/30/2008 11:40 AM, rocket at google.com wrote: > I've run into a scoping problem in R. No, in your use of it. > I'm calling a function that > * creates a formula ... incorrectly. > * 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
2002 Mar 01
1
glm with binomial errors in R and GLIM
Hi all, In my continuous transition of GLIM to R I try to make a glm with binomial errors. The data file have 3 vectors: h -> the factor that is ajusted (have 3 levels) d -> number of animais alive (the response) n -> total number of animals To test proportion of alive, make d/n. In GLIM: $yvar d$ $error binomial n$ $fit +h$ scale deviance = 25.730 (change = -9.138) at cycle 4
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")
1999 Dec 07
1
using weights in lm()
Hello! When I know the vector of the variance of the disturbances (i.e. the structure of heteroskedasticity), say Var(u_{i})=v_{i}, what is the weights I should use as argument to lm(): M <- lm(y~x,weigths=1/v) or M <- lm(y~x,weights=1/(v^0.5)) ??? In the help pages I did not find a clear answer to this question, so please could someone help me! Thanks, Wolfgang Koller
2016 Apr 08
0
R.squared in summary.lm with weights
On 07/04/2016 5:21 PM, Murray Efford wrote: > Following some old advice on this list, I have been reading the code for summary.lm to understand the computation of R-squared from a weighted regression. Usually weights in lm are applied to squared residuals, but I see that the weighted mean of the observations is calculated as if the weights are on the original scale: > > [...] > f
2008 Aug 07
1
Fitted values with small weights in lm.wfit (PR#11979)
Full_Name: Alexander Blocker Version: 2.7.1 OS: Ubuntu 8.04 / Windows XP Submission from: (NULL) (76.119.235.225) When running lm(modeleq, weights=wt, data=dataset) with small weights (<1e-10), I have encountered an odd phenomenon with fitted values. Due to numerical precision issues, the fitted values and residuals returned by lm.wfit (from its .Fortran call to dqrls) can differ greatly from
2017 Oct 07
1
Discourage the weights= option of lm with summarized data
In the Details section of lm (linear models) in the Reference manual, it is suggested to use the weights= option for summarized data. This must be discouraged rather than encouraged. The motivation for this is as follows. With summarized data the standard errors get smaller with increasing numbers of observations. However, the standard errors in lm do not get smaller when for instance all weights
2010 Jul 22
1
does package "QuantPsych" function lm.beta can handle results of a regression with weights?
Hello, and sorry for not providing an example. I run a regular linear regression (using lm) and use weights with it (weights = ...). I use "QuantPsych" package, its function lm.beta to extract standardized regression weights from my lm regression object. When I don't use weights, everything is fine. But when I do use weights, I get an error that refers to lm.beta code: "In b *
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