[R] Problem with effects package

2012-04-11 Thread Michael Kubovy
 sessionInfo()
R version 2.15.0 (2012-03-30)
Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] grid  datasets  splines   utils stats
[6] graphics  grDevices methods   base 

other attached packages:
 [1] effects_2.1-0   colorspace_1.1-1   
 [3] nnet_7.3-1  nlme_3.1-103   
 [5] lattice_0.20-6  reshape_0.8.4  
 [7] plyr_1.7.1  catdata_1.0
 [9] cacheSweave_0.6-1   stashR_0.3-5   
[11] filehash_2.2-1  BiocInstaller_1.4.3
[13] ctv_0.7-4   sos_1.3-1  
[15] brew_1.0-6  Hmisc_3.9-3
[17] survival_2.36-12MASS_7.3-17

loaded via a namespace (and not attached):
[1] cluster_1.14.2 digest_0.5.2   tools_2.15.0  

# copy and paste the following:
library( catdata )
data( unemployment )
unempt - unemployment
unempt$durbin - unempt$durbin - 1
library( reshape )
unempt -  melt( table( unempt ) )
unempw - cast( unempt, age ~ durbin )
names( unempw ) - c( 'age', 'short', 'long' )
modt - glm( durbin ~ age, weights = value, family = binomial, data = unempt )
modw - glm( cbind( short, long ) ~ age, family = binomial, data = unempw )
library( effects )
modt.ef - effect( 'age', modt ) # works!
modw.ef - effect( 'age', modw ) # doesn't work!
# Error in eval(expr, envir, enclos) : object 'age' not found
# end

__
Professor Michael Kubovy
University of Virginia
Department of Psychology
for mail add:   for FedEx or UPS add: 
P.O.Box 400400  Gilmer Hall, Room 102
Charlottesville, VA 22904-4400  485 McCormick Road
USA Charlottesville, VA 
22903
roomphone
Office:B011 +1-434-982-4729
Lab:B019+1-434-982-4751
WWW:http://www.people.virginia.edu/~mk9y/


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Problem with effects package

2012-04-11 Thread John Fox
Dear Michael,

From ?effect (under Warnings and Limitations):

Binomial generalized linear models cannot have a matrix of successes and 
failures on the left-hand side of the model formula; instead specify the 
proportion of successes (i.e., successes/(successes + failures)) as the 
response, and give the number of binomial trials (i.e., successes + failures) 
in the weights argument to glm.

Best,
 John


John Fox
Sen. William McMaster Prof. of Social Statistics
Department of Sociology
McMaster University
Hamilton, Ontario, Canada
http://socserv.mcmaster.ca/jfox/


On Wed, 11 Apr 2012 07:20:51 -0400
 Michael Kubovy kub...@virginia.edu wrote:
  sessionInfo()
 R version 2.15.0 (2012-03-30)
 Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)
 
 locale:
 [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
 
 attached base packages:
 [1] grid  datasets  splines   utils stats
 [6] graphics  grDevices methods   base 
 
 other attached packages:
  [1] effects_2.1-0   colorspace_1.1-1   
  [3] nnet_7.3-1  nlme_3.1-103   
  [5] lattice_0.20-6  reshape_0.8.4  
  [7] plyr_1.7.1  catdata_1.0
  [9] cacheSweave_0.6-1   stashR_0.3-5   
 [11] filehash_2.2-1  BiocInstaller_1.4.3
 [13] ctv_0.7-4   sos_1.3-1  
 [15] brew_1.0-6  Hmisc_3.9-3
 [17] survival_2.36-12MASS_7.3-17
 
 loaded via a namespace (and not attached):
 [1] cluster_1.14.2 digest_0.5.2   tools_2.15.0  
 
 # copy and paste the following:
 library( catdata )
 data( unemployment )
 unempt - unemployment
 unempt$durbin - unempt$durbin - 1
 library( reshape )
 unempt -  melt( table( unempt ) )
 unempw - cast( unempt, age ~ durbin )
 names( unempw ) - c( 'age', 'short', 'long' )
 modt - glm( durbin ~ age, weights = value, family = binomial, data = unempt )
 modw - glm( cbind( short, long ) ~ age, family = binomial, data = unempw )
 library( effects )
 modt.ef - effect( 'age', modt ) # works!
 modw.ef - effect( 'age', modw ) # doesn't work!
 # Error in eval(expr, envir, enclos) : object 'age' not found
 # end
 
 __
 Professor Michael Kubovy
 University of Virginia
 Department of Psychology
 for mail add: for FedEx or UPS add: 
 P.O.Box 400400Gilmer Hall, Room 102
 Charlottesville, VA 22904-4400485 McCormick Road
 USA   Charlottesville, VA 
 22903
   roomphone
 Office:B011   +1-434-982-4729
 Lab:B019  +1-434-982-4751
 WWW:http://www.people.virginia.edu/~mk9y/


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Problem with effects package

2011-07-30 Thread Lars Bishop
Dear List,

Several times I use this package I get the error message shown below.
When I work out simple examples, it turns out to be fine, but when
working with real and moderate size data sets I always get the same
error.

Do you know what could be the cause of the problem?


Error in apply(mod.matrix[, components], 1, prod) :
  subscript out of bounds
Error in plot(effect(myvariable, glm.sev1)) :
  error in evaluating the argument 'x' in selecting a method for
function 'plot'

Thanks,
Lars/

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Problem with effects package

2011-07-30 Thread John Fox
Dear Lars,

There's not nearly enough information here to know what's wrong. I can guess
(but shouldn't have to) that the model glm.sev1 is a generalized linear
model of some sort, probably fit by glm(). At a minimum, it would help to
know what command you used to fit the model, the history of commands leading
to the error, and version and session information. Ideally you'd include a
reproducible example. 

The size of the data set should be irrelevant to this error, so if you could
supply the information I requested, along with a small subset of your data
on which the model can be fit, I can try to figure out what's wrong.

Best,
 John


John Fox
Senator William McMaster
  Professor of Social Statistics
Department of Sociology
McMaster University
Hamilton, Ontario, Canada
http://socserv.mcmaster.ca/jfox


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On Behalf Of Lars Bishop
 Sent: July-30-11 3:01 PM
 To: r-help@r-project.org
 Subject: [R] Problem with effects package
 
 Dear List,
 
 Several times I use this package I get the error message shown below.
 When I work out simple examples, it turns out to be fine, but when
 working with real and moderate size data sets I always get the same
 error.
 
 Do you know what could be the cause of the problem?
 
 
 Error in apply(mod.matrix[, components], 1, prod) :
   subscript out of bounds
 Error in plot(effect(myvariable, glm.sev1)) :
   error in evaluating the argument 'x' in selecting a method for
 function 'plot'
 
 Thanks,
 Lars/
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-
 guide.html
 and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Problem with effects package

2011-07-30 Thread Jeff Newmiller
Not with a description like that.
You need to make a reproducible example. Try using head () or subset to make a 
smaller data set. Provide the data (using e.g. dput()). Provide the commands 
that trigger the errors. Who knows... you might even see the issue yourself 
then.
---
Jeff Newmiller The . . Go Live...
DCN:jdnew...@dcn.davis.ca.us Basics: ##.#. ##.#. Live Go...
Live: OO#.. Dead: OO#.. Playing
Research Engineer (Solar/Batteries O.O#. #.O#. with
/Software/Embedded Controllers) .OO#. .OO#. rocks...1k
--- 
Sent from my phone. Please excuse my brevity.

Lars Bishop lars...@gmail.com wrote:

Dear List,

Several times I use this package I get the error message shown below.
When I work out simple examples, it turns out to be fine, but when
working with real and moderate size data sets I always get the same
error.

Do you know what could be the cause of the problem?


Error in apply(mod.matrix[, components], 1, prod) :
subscript out of bounds
Error in plot(effect(myvariable, glm.sev1)) :
error in evaluating the argument 'x' in selecting a method for
function 'plot'

Thanks,
Lars/

_

R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Problem with effects package

2011-07-30 Thread Lars Bishop
ok. Here's an example:

R version 2.11.1
effects_2.0-10

var1 - c(25631.9392, 2521.2590,  6656.6516,  1362.5997,  6369.9818,
27253.4223,  2073.1909,  9959.3792,
  3318.2500, 15323.8103, 11583.8717,  3054.5558,   625.6597,
2500., 11996.2271)
var2 - as.factor(c(B:=500, B:=500, B:=500, B:=500, B:=500,
B:=500, B:=500, B:=500,
   B:=500, C:750-1000, C:750-1000, B:=500,
B:=500, B:=500, B:=500))

glm1 - glm(var1 ~ var2, family = Gamma(link = log))
summary(glm1)
library(effects)
plot(effect(var2, glm1))

Error in apply(mod.matrix[, components], 1, prod) :
  subscript out of bounds
Error in plot(effect(var2, glm1)) :
  error in evaluating the argument 'x' in selecting a method for function 'plot'



On Sat, Jul 30, 2011 at 3:10 PM, jim holtman jholt...@gmail.com wrote:
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

 We can not help unless we at least have the data that you are using.

 On Sat, Jul 30, 2011 at 3:01 PM, Lars Bishop lars...@gmail.com wrote:
 Dear List,

 Several times I use this package I get the error message shown below.
 When I work out simple examples, it turns out to be fine, but when
 working with real and moderate size data sets I always get the same
 error.

 Do you know what could be the cause of the problem?


 Error in apply(mod.matrix[, components], 1, prod) :
  subscript out of bounds
 Error in plot(effect(myvariable, glm.sev1)) :
  error in evaluating the argument 'x' in selecting a method for
 function 'plot'

 Thanks,
 Lars/

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.




 --
 Jim Holtman
 Data Munger Guru

 What is the problem that you are trying to solve?


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Problem with effects package

2011-07-30 Thread John Fox
Dear Lars,

The problem is the : in the levels of var2, which confuses effect() about
the structure of the model, since a colon indicates interaction. Try, e.g.,
removing the colons:

var2 - as.factor(c(B=500, B=500, B=500, B=500, B=500, B=500,
B=500, B=500,
   B=500, C750-1000, C750-1000, B=500, B=500,
B=500, B=500))

Then,

 effect(var2, glm1)

 var2 effect
var2
B=500 C750-1000 
 7947.932 13453.841


(See how helpful it can be to furnish a reproducible example?)

I agree, BTW, that this is a deficiency in effect(); I'll look into it when
I have a chance.

Finally, there really is no advantage to making an effect display for a
model with a single predictor, though perhaps this isn't what you were doing
in your actual application.

Best,
 John

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On Behalf Of Lars Bishop
 Sent: July-30-11 4:30 PM
 To: jim holtman; r-help@r-project.org
 Subject: Re: [R] Problem with effects package
 
 ok. Here's an example:
 
 R version 2.11.1
 effects_2.0-10
 
 var1 - c(25631.9392, 2521.2590,  6656.6516,  1362.5997,  6369.9818,
 27253.4223,  2073.1909,  9959.3792,
   3318.2500, 15323.8103, 11583.8717,  3054.5558,   625.6597,
 2500., 11996.2271)
 var2 - as.factor(c(B:=500, B:=500, B:=500, B:=500, B:=500,
 B:=500, B:=500, B:=500,
B:=500, C:750-1000, C:750-1000, B:=500,
 B:=500, B:=500, B:=500))
 
 glm1 - glm(var1 ~ var2, family = Gamma(link = log))
 summary(glm1)
 library(effects)
 plot(effect(var2, glm1))
 
 Error in apply(mod.matrix[, components], 1, prod) :
   subscript out of bounds
 Error in plot(effect(var2, glm1)) :
   error in evaluating the argument 'x' in selecting a method for
 function 'plot'
 
 
 
 On Sat, Jul 30, 2011 at 3:10 PM, jim holtman jholt...@gmail.com wrote:
  PLEASE do read the posting guide
  http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
  We can not help unless we at least have the data that you are using.
 
  On Sat, Jul 30, 2011 at 3:01 PM, Lars Bishop lars...@gmail.com
 wrote:
  Dear List,
 
  Several times I use this package I get the error message shown below.
  When I work out simple examples, it turns out to be fine, but when
  working with real and moderate size data sets I always get the same
  error.
 
  Do you know what could be the cause of the problem?
 
 
  Error in apply(mod.matrix[, components], 1, prod) :
   subscript out of bounds
  Error in plot(effect(myvariable, glm.sev1)) :
   error in evaluating the argument 'x' in selecting a method for
  function 'plot'
 
  Thanks,
  Lars/
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
  http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
 
 
 
  --
  Jim Holtman
  Data Munger Guru
 
  What is the problem that you are trying to solve?
 
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-
 guide.html
 and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Problem with effects package

2011-07-30 Thread Lars Bishop
Thanks for your quick response on this issue John!

Yes, in my real dataset I have many predictors and more observations
than in this example. I've started to remove one predictor at the time
until this one was found to be causing the problem.

Thanks again!
Lars.

On Sat, Jul 30, 2011 at 5:33 PM, John Fox j...@mcmaster.ca wrote:
 Dear Lars,

 The problem is the : in the levels of var2, which confuses effect() about
 the structure of the model, since a colon indicates interaction. Try, e.g.,
 removing the colons:

 var2 - as.factor(c(B=500, B=500, B=500, B=500, B=500, B=500,
 B=500, B=500,
                   B=500, C750-1000, C750-1000, B=500, B=500,
 B=500, B=500))

 Then,

 effect(var2, glm1)

  var2 effect
 var2
    B=500 C750-1000
  7947.932 13453.841


 (See how helpful it can be to furnish a reproducible example?)

 I agree, BTW, that this is a deficiency in effect(); I'll look into it when
 I have a chance.

 Finally, there really is no advantage to making an effect display for a
 model with a single predictor, though perhaps this isn't what you were doing
 in your actual application.

 Best,
  John

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On Behalf Of Lars Bishop
 Sent: July-30-11 4:30 PM
 To: jim holtman; r-help@r-project.org
 Subject: Re: [R] Problem with effects package

 ok. Here's an example:

 R version 2.11.1
 effects_2.0-10

 var1 - c(25631.9392, 2521.2590,  6656.6516,  1362.5997,  6369.9818,
 27253.4223,  2073.1909,  9959.3792,
           3318.2500, 15323.8103, 11583.8717,  3054.5558,   625.6597,
 2500., 11996.2271)
 var2 - as.factor(c(B:=500, B:=500, B:=500, B:=500, B:=500,
 B:=500, B:=500, B:=500,
                    B:=500, C:750-1000, C:750-1000, B:=500,
 B:=500, B:=500, B:=500))

 glm1 - glm(var1 ~ var2, family = Gamma(link = log))
 summary(glm1)
 library(effects)
 plot(effect(var2, glm1))

 Error in apply(mod.matrix[, components], 1, prod) :
   subscript out of bounds
 Error in plot(effect(var2, glm1)) :
   error in evaluating the argument 'x' in selecting a method for
 function 'plot'
 


 On Sat, Jul 30, 2011 at 3:10 PM, jim holtman jholt...@gmail.com wrote:
  PLEASE do read the posting guide
  http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
  We can not help unless we at least have the data that you are using.
 
  On Sat, Jul 30, 2011 at 3:01 PM, Lars Bishop lars...@gmail.com
 wrote:
  Dear List,
 
  Several times I use this package I get the error message shown below.
  When I work out simple examples, it turns out to be fine, but when
  working with real and moderate size data sets I always get the same
  error.
 
  Do you know what could be the cause of the problem?
 
 
  Error in apply(mod.matrix[, components], 1, prod) :
   subscript out of bounds
  Error in plot(effect(myvariable, glm.sev1)) :
   error in evaluating the argument 'x' in selecting a method for
  function 'plot'
 
  Thanks,
  Lars/
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
  http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
 
 
 
  --
  Jim Holtman
  Data Munger Guru
 
  What is the problem that you are trying to solve?
 

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-
 guide.html
 and provide commented, minimal, self-contained, reproducible code.



__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.