[R] difference between lrm's Model L.R. and anova's Chi-Square

2008-03-02 Thread johnson4
I am running lrm() with a single factor. I then run anova() on the fitted
model to obtain a p-value associated with having that factor in the model.

I am noticing that the Model L.R. in the lrm results is almost the same
as the Chi-Square in the anova results, but not quite; the latter value
is always slightly smaller.

anova() calculates the p-value based on Chi-Square, but I have
independent evidence that Model L.R. is the actual -2*log(LR), so should
I be using that?

Why are the values different?

prob_a - inv.logit(rnorm(1,0,1))
prob_b - inv.logit(rnorm(1,0,1))
data - data.frame(
factor=c(rep(a,500),rep(b,500)),
outcome=c(sample(c(1,0),100,replace=T,prob=c(prob_a,1-prob_a)),
  sample(c(1,0),100,replace=T,prob=c(prob_b,1-prob_b
fit - lrm(outcome~factor,data)

fit   # gives Model L.R. e.g. 8.23, 11.76, 6.89...
anova(fit)# gives Chi-Square e.g. 8.19, 11.69, 6.85...

__
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] difference between lrm's Model L.R. and anova's Chi-Square

2008-03-02 Thread johnson4
Quoting Frank E Harrell Jr [EMAIL PROTECTED]:
 anova (anova.Design) computes Wald statistics.  When the log-likelihood
 is very quadratic, these statistics will be very close to log-likelihood
 ratio chi-square statistics.  In general LR chi-square tests are better;
 we use Wald tests for speed.  It's best to take the time and do
 lrtest(fit1,fit2) in Design, where one of the two fits is a subset of
 the other.

 Frank Harrell

Thanks, this is great, but in my case, there's just one factor,

fit1 - lrm(outcome~factor,data)

and I'm having trouble constructing the subset 'null model', as e.g.

fit2 - lrm(outcome~1,data)

returns an error message.

How do I construct a null model with lrm() so that I can use lrtest() to test a
model with only one predictor?

I apologize for asking what must be a very simple question but I have been
unable to find the answer by searching R-help.

Thanks,
Dan

P.S. Second point: I have another case where I use lmer(), and there the null
model includes a random effect so I don't get the problem above. It looks like
with lmer objects anova() uses LLR, not Wald. Is that right?

__
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] difference between lrm's Model L.R. and anova's Chi-Square

2008-03-02 Thread Frank E Harrell Jr
[EMAIL PROTECTED] wrote:
 Quoting Frank E Harrell Jr [EMAIL PROTECTED]:
 anova (anova.Design) computes Wald statistics.  When the log-likelihood
 is very quadratic, these statistics will be very close to log-likelihood
 ratio chi-square statistics.  In general LR chi-square tests are better;
 we use Wald tests for speed.  It's best to take the time and do
 lrtest(fit1,fit2) in Design, where one of the two fits is a subset of
 the other.

 Frank Harrell
 
 Thanks, this is great, but in my case, there's just one factor,
 
 fit1 - lrm(outcome~factor,data)
 
 and I'm having trouble constructing the subset 'null model', as e.g.
 
 fit2 - lrm(outcome~1,data)
 
 returns an error message.
 
 How do I construct a null model with lrm() so that I can use lrtest() to test 
 a
 model with only one predictor?

The overall LR chi-square test statistic is in the standard output of 
lrm (which uses print.lrm).

 
 I apologize for asking what must be a very simple question but I have been
 unable to find the answer by searching R-help.
 
 Thanks,
 Dan
 
 P.S. Second point: I have another case where I use lmer(), and there the null
 model includes a random effect so I don't get the problem above. It looks like
 with lmer objects anova() uses LLR, not Wald. Is that right?

Please check the lmer documentation.

Frank

 


-- 
Frank E Harrell Jr   Professor and Chair   School of Medicine
  Department of Biostatistics   Vanderbilt University

__
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] difference between lrm's Model L.R. and anova's Chi-Square

2008-03-01 Thread johnson4
I am running lrm() with a single factor. I then run anova() on the fitted
model to obtain a p-value associated with having that factor in the model.

I am noticing that the Model L.R. in the lrm results is almost the same
as the Chi-Square in the anova results, but not quite; the latter value
is always slightly smaller.

anova() calculates the p-value based on Chi-Square, but I have
independent evidence that Model L.R. is the actual -2*log(LR), so should
I be using that?

Why are the values different?

prob_a - inv.logit(rnorm(1,0,1))
prob_b - inv.logit(rnorm(1,0,1))
data - data.frame(
factor=c(rep(a,500),rep(b,500)),
outcome=c(sample(c(1,0),100,replace=T,prob=c(prob_a,1-prob_a)),
  sample(c(1,0),100,replace=T,prob=c(prob_b,1-prob_b
fit - lrm(outcome~factor,data)

fit   # gives Model L.R. e.g. 8.23, 11.76, 6.89...
anova(fit)# gives Chi-Square e.g. 8.19, 11.69, 6.85...

PreviousNext|   Save|   Delete  |   Reply   |

__
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] difference between lrm's Model L.R. and anova's Chi-Square

2008-03-01 Thread Frank E Harrell Jr
[EMAIL PROTECTED] wrote:
 I am running lrm() with a single factor. I then run anova() on the fitted
 model to obtain a p-value associated with having that factor in the model.
 
 I am noticing that the Model L.R. in the lrm results is almost the same
 as the Chi-Square in the anova results, but not quite; the latter value
 is always slightly smaller.
 
 anova() calculates the p-value based on Chi-Square, but I have
 independent evidence that Model L.R. is the actual -2*log(LR), so should
 I be using that?
 
 Why are the values different?

anova (anova.Design) computes Wald statistics.  When the log-likelihood 
is very quadratic, these statistics will be very close to log-likelihood 
ratio chi-square statistics.  In general LR chi-square tests are better; 
we use Wald tests for speed.  It's best to take the time and do 
lrtest(fit1,fit2) in Design, where one of the two fits is a subset of 
the other.

Frank Harrell

 
 prob_a - inv.logit(rnorm(1,0,1))
 prob_b - inv.logit(rnorm(1,0,1))
 data - data.frame(
 factor=c(rep(a,500),rep(b,500)),
 outcome=c(sample(c(1,0),100,replace=T,prob=c(prob_a,1-prob_a)),
   sample(c(1,0),100,replace=T,prob=c(prob_b,1-prob_b
 fit - lrm(outcome~factor,data)
 
 fit   # gives Model L.R. e.g. 8.23, 11.76, 6.89...
 anova(fit)# gives Chi-Square e.g. 8.19, 11.69, 6.85...
 
 Previous  Next|   Save|   Delete  |   Reply   |
 
 __
 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.
 


-- 
Frank E Harrell Jr   Professor and Chair   School of Medicine
  Department of Biostatistics   Vanderbilt University

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