Re: [R] Exact logistic regression, data frame issue
On 11 Jan 2014, at 19:09 , Razi Zaidi wrote: > Hi there > > I have the dataframe below saved in an object /tst/ > > agegrp bmigrp pep n > 1 1 a 0 2 > 2 2 a 0 2 > 3 3 a 0 0 > 4 1 b 0 47 > 5 2 b 0 43 > 6 3 b 0 31 > 7 1 c 0 200 > 8 2 c 1 152 > 9 3 c 2 137 > > When i run Exact Logistic regression analysis: > > elrm (formula = pep/n ~ bmigrp, interest = ~ bmigrp, iter = 22000, dataset > = tst, burnIn = 5000) > > I get the following error: > > *Error in data.frame(..., check.names = FALSE) : > arguments imply differing number of rows: 9, 8* > > I was wondering if anyone knew what i was doing wrong. Well, it's a contributed package, which presumably has a maintainer, but a little debugging suggests that line 3 gets zapped in the calculation of design.frame. Presumably it isn't happy with n=0. Passing dataset=test[-3,] makes something happen. -pd -- 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 __ 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] Exact logistic regression, data frame issue
Hi there I have the dataframe below saved in an object /tst/ agegrp bmigrp pep n 1 1 a 0 2 2 2 a 0 2 3 3 a 0 0 4 1 b 0 47 5 2 b 0 43 6 3 b 0 31 7 1 c 0 200 8 2 c 1 152 9 3 c 2 137 When i run Exact Logistic regression analysis: elrm (formula = pep/n ~ bmigrp, interest = ~ bmigrp, iter = 22000, dataset = tst, burnIn = 5000) I get the following error: *Error in data.frame(..., check.names = FALSE) : arguments imply differing number of rows: 9, 8* I was wondering if anyone knew what i was doing wrong. Thanks in advance - Best Wishes Razi Zaidi [[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] exact logistic regression with correlated data?
hi all, does anyone know if R can do exact logistic regression with correlated binary data? Thanks!! Yue -- View this message in context: http://r.789695.n4.nabble.com/exact-logistic-regression-with-correlated-data-tp4635900.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] exact logistic regression
I believe that this code will work (...for very small) samples, but let some correct me if there is something wrong. require(logistf);require(combinat) permY<-permn(data$y) ntimes<-length(permY) results<-matrix(nrows=ntimes,ncols=number_of_coefficients) for(i in 1:ntimes){ results[i,]<-logistf(unlist(permY[i])~factor_A+factor_B,data=data)} observed<-logistf(y~factor_A+factor_B,data=data)$coefficients # Exact p-values will be: sum(results[,1]>=observed[1])/ntimes # One for intercept sum(results[,2]>=observed[2])/ntimes sum(results[,3]>=observed[3])/ntimes -- Mi³ego dnia [[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] exact logistic regression
Dear Łukas Thank you very much ...FOR EACH ROW... That's cool data2elrm<-cbind(mydata,n=1) With best regards Denis У Пят, 04/02/2011 у 22:16 +0100, Łukasz Ręcławowicz піша: > > > 2011/2/4 Den > To use elrm() I have to aggregate my data,which is really time > consuming > when I look for the way out through many variables. > You don't have to do that. One exception is that the binomial response > should be specified as success/trials, where success gives the number > of successes and trials gives the number of binomial trials for each > row of dataset. > So... when one row = one trial: > > > data2elrm<-cbind(mydata,n=rep(1,dim(mydata)[1])) > > > > But the worst thing > is that I am not not sure if I can trust to p-values in > output. > It depends, but it's always a "guess". > > -- > Miłego dnia > > > > __ 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] exact logistic regression
Dear Brad Dear Jinko Dear David Sorry for the noise out of nothing. It was because of my ignorance and misunderstanding of algorithms of elrm. elrm is great for the assessment of multivariable model where Stata simply runs out of memory fails, while Stata can make exact calculations on one variable. What scared on the first place was variation in p-values when changing 'iter' option. Now I work with small dataset of 73 trials with 59 successes and trying to handle with categorical independent variables. Could you please suggest which number of iterations and burnIn is better to choose? Could you please comment how to interpret p-value for joint effect? For instance, I couldn't get the example in Zamar D, McNeney B and Graham J. elrm: Software Implementing Exact-like Inference for Logistic Regression Models. Journal of Statistical Software 2007, 21(3). on page 9, where p value of 0.76555 is consistent with the model used. And finally, could you please tell if I have to cite numbers number of iterations and burnIn in publication? With best regards Denis P.S. Sorry for naive questions У Пят, 04/02/2011 у 14:52 -0800, Brad McNeney піша: > You might get a more useful response if you CC the package maintainer, David > Zamar, who I don't think is a member of this list. I wonder if you could > elaborate on the reason (and provide a test data set) for your distrust of > the output. > > Brad > > - Original Message - > From: "Den" > To: "R-help" > Sent: Friday, 4 February, 2011 8:44:04 AM > Subject: [R] exact logistic regression > > Hate to say that, but it looks like Stata is way above R, considering > exact logistic regression. > To use elrm() I have to aggregate my data,which is really time consuming > when I look for the way out through many variables. But the worst thing > is that I am not not sure if I can trust to p-values in output. > > I would be happy,however, if someone could contradict me on this issue. > With best regards > Denis > > __ > 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] exact logistic regression
data2elrm<-cbind(mydata,n=rep(1,dim(mydata)[1])) > More logic would be: data2elrm2<-cbind(mydata,n=rep(1,nrow(mydata))) Sorry for obfuscation. -- Mi³ego dnia [[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] exact logistic regression
2011/2/4 Den > To use elrm() I have to aggregate my data,which is really time consuming > when I look for the way out through many variables. You don't have to do that. *One exception is that the binomial response should be specified as success/trials, where success gives the number of successes and trials gives the number of binomial trials for each row of dataset. * So... when one row = one trial: data2elrm<-cbind(mydata,n=rep(1,dim(mydata)[1]))* * But the worst thing > is that I am not not sure if I can trust to p-values in output. > It depends, but it's always a "guess". -- Mi³ego dnia [[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] exact logistic regression
Hate to say that, but it looks like Stata is way above R, considering exact logistic regression. To use elrm() I have to aggregate my data,which is really time consuming when I look for the way out through many variables. But the worst thing is that I am not not sure if I can trust to p-values in output. I would be happy,however, if someone could contradict me on this issue. With best regards Denis __ 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] exact logistic regression
Dear Łukasz Thank you very much for information Dear R people could you please help please with following questions Sorry for my silly questions, because I am not a mathematician. 1. Is elrm() works similar as exact regression in SAS or Stata? After double check in Stata and R some results from my data vary greatly. 2. How to obtain p-value from MCMClogit() from MCMCpack? Thank you Denis __ 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] exact logistic regression
2011/2/3 Den > > Thank you again > It is funny how stupid I was Elrm, clogit {survival} or exactLoglinTest are only "exact-like", the truth is, R don't have it... and glm is poor. http://sas-and-r.blogspot.com/2010/12/example-818-monte-carlo-experiment.html http://sas-and-r.blogspot.com/2010/11/example-816-exact-logistic-regression.html http://www.cytel.com/Papers/scra-2003.pdf http://support.sas.com/rnd/app/papers/exactlogistic2009.pdf -- Mi³ego dnia [[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] exact logistic regression
Dear Dennis Thank you again It is funny how stupid I was. I was afraid of the word "inference" in elrm package description while performing my first search. elrm package looks like what I need. They have very good intro with examples Zamar D, McNeney B and Graham J. elrm: Software Implementing Exact-like Inference for Logistic Regression Models. Journal of Statistical Software 2007, 21(3). http://www.jstatsoft.org/v21/i03 In case if someone else needs to perform exact logistic regression with R I suggest to read the paper above first. The whole idea looks pretty attractive in particular for biomedical research : binary outcome, small sample size... and smart name of analysis method:) With best regards Denis У Срд, 02/02/2011 у 12:25 -0800, Dennis Murphy піша: > Hi: > > Try package elrm - its description file says that it performs exact > logistic regression by MCMC. I found this as the first set of hits I > got from > > # install.packages('sos') # if necessary > library(sos) > findFn('exact logistic regression') > > HTH, > Dennis > > On Wed, Feb 2, 2011 at 8:43 AM, Den wrote: > Hello to R people > Does anybody know to calculate exact logistic regression in R? > Does such option exist anywhere? > Surprisingly, could not find it using search engine. It is > hard to > believe, however, that such useful function is not implemented > in R yet? > Could you help, please > > Thank you > Denis > > __ > 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] exact logistic regression
Hi: Try package elrm - its description file says that it performs exact logistic regression by MCMC. I found this as the first set of hits I got from # install.packages('sos') # if necessary library(sos) findFn('exact logistic regression') HTH, Dennis On Wed, Feb 2, 2011 at 8:43 AM, Den wrote: > Hello to R people > Does anybody know to calculate exact logistic regression in R? > Does such option exist anywhere? > Surprisingly, could not find it using search engine. It is hard to > believe, however, that such useful function is not implemented in R yet? > Could you help, please > > Thank you > Denis > > __ > 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.
[R] exact logistic regression
Hello to R people Does anybody know to calculate exact logistic regression in R? Does such option exist anywhere? Surprisingly, could not find it using search engine. It is hard to believe, however, that such useful function is not implemented in R yet? Could you help, please Thank you Denis __ 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.