Re: [R] starting values in glm(..., family = binomial(link =log))

2013-01-30 Thread Ravi Varadhan
I did not get any warnings when I ran your data/model example.

From: Fischer, Felix [mailto:felix.fisc...@charite.de]
Sent: Wednesday, January 30, 2013 11:19 AM
To: Ravi Varadhan
Cc: r-help@r-project.org
Subject: AW: [R] starting values in glm(..., family = binomial(link =log))

Thanks for your replies! It seems, that I can fit my model now, when I can 
provide the "right" starting values; however there remain warnings, such as:

1: In log(ifelse(y == 1, 1, (1 - y)/(1 - mu))) : NaNs wurden erzeugt
2: step size truncated due to divergence
3: step size truncated: out of bounds
...

That makes me feel uncomfortable and I wonder whether I can "trust" the fitted 
model. Why is this kind of regression so picky about starting values compared 
to logistic regression? And is there a way to explain the difference between 
binomial - quasibinomial to a simple mind like mine?

Best,
Felix

Von: Ravi Varadhan [mailto:ravi.varad...@jhu.edu]
Gesendet: Mittwoch, 30. Januar 2013 17:02
An: Fischer, Felix
Cc: r-help@r-project.org<mailto:r-help@r-project.org>
Betreff: [R] starting values in glm(..., family = binomial(link =log))

Try this:

Age_log_model = glm(Arthrose ~ Alter, data=x, start=c(-1, 0), 
family=quasibinomial(link = log))

Ravi

Ravi Varadhan, Ph.D.
Assistant Professor
The Center on Aging and Health
Division of Geriatric Medicine & Gerontology
Johns Hopkins University
rvarad...@jhmi.edu<mailto:rvarad...@jhmi.edu>
410-502-2619


[[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] starting values in glm(..., family = binomial(link =log))

2013-01-30 Thread Ravi Varadhan
Try this:

Age_log_model = glm(Arthrose ~ Alter, data=x, start=c(-1, 0), 
family=quasibinomial(link = log))

Ravi

Ravi Varadhan, Ph.D.
Assistant Professor
The Center on Aging and Health
Division of Geriatric Medicine & Gerontology
Johns Hopkins University
rvarad...@jhmi.edu
410-502-2619


[[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] starting values in glm(..., family = binomial(link =log))

2013-01-30 Thread Fischer, Felix
Thanks for your replies! It seems, that I can fit my model now, when I can 
provide the "right" starting values; however there remain warnings, such as:

1: In log(ifelse(y == 1, 1, (1 - y)/(1 - mu))) : NaNs wurden erzeugt
2: step size truncated due to divergence
3: step size truncated: out of bounds
...

That makes me feel uncomfortable and I wonder whether I can "trust" the fitted 
model. Why is this kind of regression so picky about starting values compared 
to logistic regression? And is there a way to explain the difference between 
binomial - quasibinomial to a simple mind like mine?

Best,
Felix

Von: Ravi Varadhan [mailto:ravi.varad...@jhu.edu]
Gesendet: Mittwoch, 30. Januar 2013 17:02
An: Fischer, Felix
Cc: r-help@r-project.org
Betreff: [R] starting values in glm(..., family = binomial(link =log))

Try this:

Age_log_model = glm(Arthrose ~ Alter, data=x, start=c(-1, 0), 
family=quasibinomial(link = log))

Ravi

Ravi Varadhan, Ph.D.
Assistant Professor
The Center on Aging and Health
Division of Geriatric Medicine & Gerontology
Johns Hopkins University
rvarad...@jhmi.edu<mailto:rvarad...@jhmi.edu>
410-502-2619


[[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] starting values in glm(..., family = binomial(link = log))

2013-01-29 Thread Ben Bolker
Fischer, Felix  charite.de> writes:

> 
> Dear R-helpers,
 
> i have a problem with a glm-model. I am trying to fit models with
> the log as link function instead of the logit.  However, in some
> cases glm fails to estimate those models and suggests to give start
> values. However, when I set start = coef(logistic_model) within the
> function call, glm still says it cannot find starting values? This
> seems to be more of a problem, when I include a continous predictor
> in the model (age instead of group). find below a minimal example.
 
 [Sorry for snipping context: gmane doesn't like it]
 

Group_logit_model = glm(data = x, Arthrose ~ Gruppe, 
   family=binomial(link = logit))
Group_log_model = glm(data = x, Arthrose ~ Gruppe, 
   family=binomial(link = log))

Age_logit_model = glm(data = x, Arthrose ~ Alter, 
   family=binomial(link = logit))
Age_log_model = glm(data = x, Arthrose ~ Alter, 
 family=binomial(link = log),
 start=c(coef(Group_log_model)[1],0))

Using the intercept from the group_log model combined with 0
for the log-slope appears to work.  It makes more sense to use
this than to use the results from a logit fit (as you tried),
because those parameters would be on a different scale.

  Another possibility for the starting
intercept value would be the coefficient of a null model
with a log-link:  

Null_log_model = glm(data = x, Arthrose ~ 1,
   family=binomial(link = log))

__
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] starting values in glm(..., family = binomial(link = log))

2013-01-29 Thread Fischer, Felix
Dear R-helpers,

i have a problem with a glm-model. I am trying to fit models with the log as 
link function instead of the logit. However, in some cases glm fails to 
estimate those models and suggests to give start values. However, when I set 
start = coef(logistic_model) within the function call, glm still says it cannot 
find starting values? This seems to be more of a problem, when I include a 
continous predictor in the model (age instead of group). find below a minimal 
example.

Do I need to set other/better starting values? I would greatly appreciate any 
hints!

Best, Felix


x = structure(list(Alter = c(28, 72, 48, 53, 49, 56, 47, 20, 72, 
 26, 28, 28, 25, 63, 42, 23, 68, 63, 44, 23, 23, 
47, 30, 22, 21, 
 30, 26, 47, 40, 43, 23, 78, 29, 20, 49, 70, 24, 
49, 43, 49, 68, 
 50, 42, 27, 70, 68, 46, 42, 40, 44, 48, 24, 23, 
24, 56, 60, 66, 
 40, 71, 45, 37, 71, 41, 53, 48, 34, 52, 26, 76, 
46, 65, 69, 75, 
 59, 30, 54, 69, 46, 50, 62, 38, 34, 30, 29, 73, 
20, 57, 64, 40, 
 28, 21, 36, 65, 22, 69, 24, 38, 61, 70, 47, 61, 
20, 58, 29, 35, 
 23, 29, 22, 21, 56, 37, 79, 27, 25, 75, 64, 22, 
48, 36, 24, 44, 
 38, 23, 54, 76, 43, 30, 47, 48, 23, 68, 28, 44, 
54, 43, 35, 47, 
 49, 44, 53, 26, 24, 56, 34, 39, 67, 74, 49, 55, 
39, 58, 69, 46, 
 56, 69, 69, 26, 58, 41, 46, 40, 49, 24, 29, 24, 
71, 41, 61, 27, 
 25, 38, 56, 26, 53, 39, 77, 40, 53, 61, 61, 54, 
62, 28, 71, 42, 
 67, 44, 20, 40, 27, 27, 22, 71, 24, 31, 63, 24, 
22, 30, 42, 43, 
 23, 46, 49, 21, 25, 30, 64, 29, 52, 29, 50, 57, 
50, 53, 50, 34, 
 58, 42, 35, 50, 35, 35, 63, 42, 37, 64, 34, 56, 
70, 48, 23, 43, 
 26, 52, 24, 31, 27, 34, 23, 44, 51, 41, 69, 47, 
37, 68, 42, 28, 
 25), Arthrose = structure(c(1L, 1L, 1L, 1L, 1L, 
1L, 2L, 1L, 1L, 
 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
 1L, 1L, 1L, 1L, 1L, 
1L, 2L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 
 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 2L, 
 1L, 1L, 1L, 1L, 2L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 1L, 
 1L, 1L, 1L, 1L, 1L, 
2L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 2L, 1L, 
 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 
 1L, 1L, 1L, 1L, 1L, 
1L, 2L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 
 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 2L, 
 1L, 1L, 1L, 1L, 1L, 
1L, 1L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