Re: [R] Consistency of Logistic Regression

2010-11-12 Thread Benjamin Godlove
I think it is likely I am missing something.  Here is a very simple example:

R code:

mat - matrix(nrow = 10, ncol = 2, c(1,0,1,0,0,1,0,0,1,1),
c(5,4,1,6,3,6,5,3,7,9), dimnames = list(c(1,2,3,4,5,6,7,8,9,10),
c(column1,column2)))

g - glm(mat[1:10] ~ mat[11:20], family = binomial (link = logit))

g$converged


SAS code:

data mat;
input col1 col2;
datalines;
1 5
0 4
1 1
0 6
0 3
1 6
0 5
0 3
1 7
1 9
;

proc logistic data=mat descending;
model col1 = col2 / link=logit;
run;

SAS output (in case you don't have access to SAS):
Convergence criterion satisfied

  Estimate   SE
Intercept-1.6118  1.7833
col20.3293  0.3383


Of course, with an example this small, it is not so surprising that the two
methods differ; and they hardly differ by a single S.  But as the datasets
get larger, the difference is more pronounced.  Let me know if you would
like me to send you a large dataset.  I get the feeling I am doing something
wrong in R, so please let me know what you think.

Thank you!

Ben Godlove

On Thu, Nov 11, 2010 at 1:59 PM, Albyn Jones jo...@reed.edu wrote:

 do you have factors (categorical variables) in the model?  it could be
 just a parameterization difference.

 albyn

 On Thu, Nov 11, 2010 at 12:41:03PM -0500, Benjamin Godlove wrote:
  Dear R developers,
 
  I have noticed a discrepancy between the coefficients returned by R's
 glm()
  for logistic regression and SAS's PROC LOGISTIC.  I am using dist =
 binomial
  and link = logit for both R and SAS.  I believe R uses IRLS whereas SAS
 uses
  Fisher's scoring, but the difference is something like 100 SE on the
  intercept.  What accounts for such a huge difference?
 
  Thank you for your time.
 
  Ben Godlove
 
[[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.
 

 --
 Albyn Jones
 Reed College
 jo...@reed.edu



[[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.


[R] Consistency of Logistic Regression

2010-11-11 Thread Benjamin Godlove
Dear R developers,

I have noticed a discrepancy between the coefficients returned by R's glm()
for logistic regression and SAS's PROC LOGISTIC.  I am using dist = binomial
and link = logit for both R and SAS.  I believe R uses IRLS whereas SAS uses
Fisher's scoring, but the difference is something like 100 SE on the
intercept.  What accounts for such a huge difference?

Thank you for your time.

Ben Godlove

[[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.


[R] feedback/question on function update()

2010-09-18 Thread Benjamin Godlove
Hi,

First let me say I am a big fan of R and appreciate all your time and
effort.

The update() function does not seem to work in a for loop.  Consider the
following:

mdat - matrix(c(1,2,3, 11,23,13, 12,4,8), nrow = 3, ncol=3, byrow=TRUE)
reg - lm(mdat[7:9]~1)
for(i in 1:2) {
reg - update(reg,.~.+mdat[((i-1)*3 + 1):(i*3)]) #update reg twice
}
reg # reg should have two independent variables, but it only has one



The update() function in conjunction with a for loop will only consider the
last update, and not save all the previous ones.  Is there a way around
this?

I appreciate your time.

- Ben Godlove

[[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.