Re: [R] score test for logistic regression
On Jul 24, 2011, at 00:20 , Thomas Lumley wrote: > On Fri, Jul 22, 2011 at 8:00 PM, peter dalgaard wrote: >> >> On Jul 21, 2011, at 23:11 , David Winsemius wrote: >> >>> >>> On Jul 21, 2011, at 3:38 PM, zlu wrote: >>> Hi Peter, >>> >>> I'm not sure how many people still have 9 month old postings on their mail >>> client and will know that Peter Dalgaard is the intended recipient. >>> Do you have any idea or codes of construct a score test based confidence interval for coefficients in logistic regression? >>> >>> I realize that Peter knows more than I about this, so take this as working >>> hypothesis and believe anything he says more than what I say. My idea: set >>> the glm control ..., maxit=1, so you only get one iteration and then use >>> the deviance results with the usual chi-square assuptions. I fear this >>> could be too easy or else Peter would have already thought of this dodge. >>> >> >> I did think along those lines but couldn't convince myself that it would >> work. Rather, what you need is the deviance (SSD) of the approximating >> weighted regression analysis. Anyways, anova(..., test="Rao") has been >> implemented in R-devel for a while. >> >> This doesn't do confidence intervals, though. That is a somewhat harder >> problem -- you'd basically need to redo the likelihood profiling code with a >> different criterion. >> >> For a slow and dirty technique, you could see if a parameter value beta0 is >> in the CI by including an offset of beta0*x and computing the score test for >> whether the shifted parameter (beta-beta0) is zero. Then use uniroot(). >> > > I think you basically have to do this computation. The problem is > that you may not find exactly two endpoints. For the deviance-based > intervals, a unimodal likelihood is sufficient to guarantee there are > exactly two places where the deviance differs from the maximum by the > desired amount. Not quite, it could level off and never reach the amount. And I believe the unimodality needs to hold for the _profiled_ likelihood. Not sure it is actually guaranteed to be true for glm's with non-canonical links. > Things can be much messier when you are trying to > get the score divided by its estimated standard error to be 1.96. Yes. There is a similar issue with nonlinear regression models, although it seems that it is often not that big a problem in practice. -- Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd@cbs.dk Priv: pda...@gmail.com "Døden skal tape!" --- Nordahl Grieg __ 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] score test for logistic regression
On Fri, Jul 22, 2011 at 8:00 PM, peter dalgaard wrote: > > On Jul 21, 2011, at 23:11 , David Winsemius wrote: > >> >> On Jul 21, 2011, at 3:38 PM, zlu wrote: >> >>> Hi Peter, >> >> I'm not sure how many people still have 9 month old postings on their mail >> client and will know that Peter Dalgaard is the intended recipient. >> >>> Do you have any idea or codes of construct a score test based confidence >>> interval for coefficients in logistic regression? >> >> I realize that Peter knows more than I about this, so take this as working >> hypothesis and believe anything he says more than what I say. My idea: set >> the glm control ..., maxit=1, so you only get one iteration and then use the >> deviance results with the usual chi-square assuptions. I fear this could be >> too easy or else Peter would have already thought of this dodge. >> > > I did think along those lines but couldn't convince myself that it would > work. Rather, what you need is the deviance (SSD) of the approximating > weighted regression analysis. Anyways, anova(..., test="Rao") has been > implemented in R-devel for a while. > > This doesn't do confidence intervals, though. That is a somewhat harder > problem -- you'd basically need to redo the likelihood profiling code with a > different criterion. > > For a slow and dirty technique, you could see if a parameter value beta0 is > in the CI by including an offset of beta0*x and computing the score test for > whether the shifted parameter (beta-beta0) is zero. Then use uniroot(). > I think you basically have to do this computation. The problem is that you may not find exactly two endpoints. For the deviance-based intervals, a unimodal likelihood is sufficient to guarantee there are exactly two places where the deviance differs from the maximum by the desired amount.Things can be much messier when you are trying to get the score divided by its estimated standard error to be 1.96. -thomas -- Thomas Lumley Professor of Biostatistics University of Auckland __ 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] score test for logistic regression
On Jul 21, 2011, at 23:11 , David Winsemius wrote: > > On Jul 21, 2011, at 3:38 PM, zlu wrote: > >> Hi Peter, > > I'm not sure how many people still have 9 month old postings on their mail > client and will know that Peter Dalgaard is the intended recipient. > >> Do you have any idea or codes of construct a score test based confidence >> interval for coefficients in logistic regression? > > I realize that Peter knows more than I about this, so take this as working > hypothesis and believe anything he says more than what I say. My idea: set > the glm control ..., maxit=1, so you only get one iteration and then use the > deviance results with the usual chi-square assuptions. I fear this could be > too easy or else Peter would have already thought of this dodge. > I did think along those lines but couldn't convince myself that it would work. Rather, what you need is the deviance (SSD) of the approximating weighted regression analysis. Anyways, anova(..., test="Rao") has been implemented in R-devel for a while. This doesn't do confidence intervals, though. That is a somewhat harder problem -- you'd basically need to redo the likelihood profiling code with a different criterion. For a slow and dirty technique, you could see if a parameter value beta0 is in the CI by including an offset of beta0*x and computing the score test for whether the shifted parameter (beta-beta0) is zero. Then use uniroot(). -- Peter Dalgaard Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd@cbs.dk Priv: pda...@gmail.com __ 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] score test for logistic regression
On Jul 21, 2011, at 3:38 PM, zlu wrote: Hi Peter, I'm not sure how many people still have 9 month old postings on their mail client and will know that Peter Dalgaard is the intended recipient. Do you have any idea or codes of construct a score test based confidence interval for coefficients in logistic regression? I realize that Peter knows more than I about this, so take this as working hypothesis and believe anything he says more than what I say. My idea: set the glm control ..., maxit=1, so you only get one iteration and then use the deviance results with the usual chi-square assuptions. I fear this could be too easy or else Peter would have already thought of this dodge. -- David Winsemius, MD West Hartford, CT __ 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] score test for logistic regression
Hi Peter, Do you have any idea or codes of construct a score test based confidence interval for coefficients in logistic regression? James -- View this message in context: http://r.789695.n4.nabble.com/score-test-for-logistic-regression-tp3041899p3684784.html Sent from the R help mailing list archive at Nabble.com. __ 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] score test for logistic regression
On Nov 14, 2010, at 18:15 , David Winsemius wrote: > > On Nov 14, 2010, at 11:29 AM, Wang, Ying wrote: > >> Dear R experts, >> >> I'm trying to find a code to calculate the p-value from the score test for >> the logistic regression. My fit is like this: logit=beta0+beta1*x1+beta2*x2 >> ++ betak* xk. And my H0 is beta1=beta2=...=betak =0. >> >> Any help will be highly appreciated. Thank you! > > Which "score test" do you want? That's actually pretty well-defined, David. The score test is based on calculating the "efficient scores", aka the derivative of the likelihood, at the MLE under the null hypothesis, and measuring it in the x'Ax sense, where A is the inverse expected Fisher information. It is very similar to the Wald test but things get evaluated under the null rather than the alternative. In GLM's with canonical links, there is a straightforward connection to the first weighted regression step taking you from the maximum under the null towards the maximum under the alternative. Now, coercing R to generate the score tests is not _entirely_ trivial, since you need to pick glm()-related code and objects apart in exactly the right way, and I'm afraid that I don't know any pre-cooked codes for it. > > -- > David Winsemius, MD > West Hartford, CT > > __ > 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. -- Peter Dalgaard Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd@cbs.dk Priv: pda...@gmail.com __ 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] score test for logistic regression
On Nov 14, 2010, at 11:29 AM, Wang, Ying wrote: Dear R experts, I'm trying to find a code to calculate the p-value from the score test for the logistic regression. My fit is like this: logit=beta0+beta1*x1+beta2*x2 ++ betak* xk. And my H0 is beta1=beta2=...=betak =0. Any help will be highly appreciated. Thank you! Which "score test" do you want? -- David Winsemius, MD West Hartford, CT __ 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] score test for logistic regression
Dear R experts, I'm trying to find a code to calculate the p-value from the score test for the logistic regression. My fit is like this: logit=beta0+beta1*x1+beta2*x2 ++ betak* xk. And my H0 is beta1=beta2=...=betak =0. Any help will be highly appreciated. Thank you! Ying __ 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.