From: Saari Saari on 6 Feb 2010 06:05 "Tom Lane" <tlane(a)mathworks.com> wrote in message <hj2323$lm6$1(a)fred.mathworks.com>... > > when i try again to run using matlab, it still did not produce the same > > result as how u give in 'b1'. > > b1 = [-21.6986 -38.8756 59.4756]'; > > the same error come out mentioning iteration reach the limits. i really do > > not have any idea how u can produce the coefficients just like in b1. u > > told me that my data are nearly separable previously. but i still working > > in order to get the same coefficients like in b1 as how u claimed that u > > get it previously.do you have the same code glmfit for b1?i guest u used > > different code for b1, not > > Saari, the b1 value is what I got from your posting, not from a MATLAB > command. > > Why is it that you need to get this value? It appears that MATLAB and the > other software simply performed a different number of iterations for this > singular problem where the true answer is infinite. In fact, it looks like > MATLAB performed more iterations and got a slightly better (higher, less > negative) value for the log likelihood function: > > >> sum(log(binopdf(y,1,glmval(b,x,'logit')))) % from glmfit > ans = > -2.24934057847523 > >> sum(log(binopdf(y,1,glmval(b1,x,'logit')))) % from other software > ans = > -2.24934058917271 > > Of course I just have a few digits of precision for b1, copied from your > posting. > > -- Tom > dear TOm, thanks alot for your explanation. i already generated my data and i found that the value just the same for the coefficients using Matlab. Previously might be due to the limitation or i can say problem with my own data. ii would like to ask regarding how to perform chi square test for this logistic regression? besides that, as we know in logistic regression, the significant of coefficients can be tested via wald test and log-likelihood ratio test. Iis that a direct way (embedded coding) that we can perform wald test or loglikelihood ratio test In Matlab? hopefully u can help me to solve this. thanks alot.
From: Tom Lane on 8 Feb 2010 11:10 > besides that, as we know in logistic regression, the significant of > coefficients can be tested via wald test and log-likelihood ratio test. > Iis that a direct way (embedded coding) that we can perform wald test or > loglikelihood ratio test In Matlab? The third output from glmfit is a structure that includes the following fields: 'se' standard errors of coefficient estimates B 't' t statistics for B 'p' p-values for B So to test a coefficient you can look at its standard error, t statistic, and p-value. There are other ways to do it. The linhyptest function can perform more complicated tests using outputs from glmfit. Also, you can perform a test of the difference in deviance between two models using the second output from glmfit. -- Tom
From: Saari Saari on 17 Feb 2010 04:08 "Tom Lane" <tlane(a)mathworks.com> wrote in message <hkpd2j$8s$1(a)fred.mathworks.com>... > > besides that, as we know in logistic regression, the significant of > > coefficients can be tested via wald test and log-likelihood ratio test. > > Iis that a direct way (embedded coding) that we can perform wald test or > > loglikelihood ratio test In Matlab? > > The third output from glmfit is a structure that includes the following > fields: > > 'se' standard errors of coefficient estimates B > 't' t statistics for B > 'p' p-values for B > > So to test a coefficient you can look at its standard error, t statistic, > and p-value. > > There are other ways to do it. The linhyptest function can perform more > complicated tests using outputs from glmfit. Also, you can perform a test of > the difference in deviance between two models using the second output from > glmfit. > > -- Tom > yes, i also used that third output to test the coefficient. but as in my project, i still need to test for likelihood ratio and wald test. i did try to used these function however, for example in wald test, it requires me to include three input which honestly i dont know because in normal way i did it (use webste software), wald test is generated directly when i do not need to include any input. let say with this kind of data x=[1 1 3 3 3 3 3 3 1 1 2 1 1 2 1 3 2 3 1 1 3 2 3 1 2 2 3 3 2 1 1 1 3 2 1 2 2 3 1 3 3;2 2 5 5 6 5 5 5 2 1 4 1 1 3 2 6 4 6 1 2 5 4 5 1 3 3 5 5 4 2 2 2 6 4 1 4 3 5 2 6 5;3 3 1 1 1 1 1 1 2 2 2 1 3 1 1 1 2 2 2 2 2 1 3 3 3 4 4 4 4 1 1 1 2 2 1 1 1 2 3 4 1;2 2 2 2 2 1 1 3 2 2 3 1 2 2 2 2 1 1 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 2 1 2 2 1;4 4 1 2 3 1 1 6 1 2 4 1 4 3 6 5 2 1 3 2 2 3 1 1 1 2 6 5 1 1 2 6 5 6 3 4 1 1 1 1 1]'; >> y=[0 0 0 1 0 1 1 1 0 0 1 0 0 0 0 1 1 1 0 0 1 1 1 0 0 0 1 1 1 0 0 0 1 1 0 0 0 1 0 1 1]'; >> n=[1] n = 1 >> b=glmfit(x,[y ones(41,1)],'binomial','link','logit'); >> [b,dev,st]=glmfit(x,[y ones(41,1)],'binomial','link','logit') b = -9.8295 -0.2946 2.2637 0.9285 -0.5614 0.3250 dev = 21.3815 st = beta: [6x1 double] dfe: 35 sfit: 1.1768 s: 1 estdisp: 0 covb: [6x6 double] se: [6x1 double] coeffcorr: [6x6 double] t: [6x1 double] p: [6x1 double] resid: [41x1 double] residp: [41x1 double] residd: [41x1 double] resida: [41x1 double] in this argument, [h,pValue,stat,criticalValue] = waldtest(r,R,EstCov).... what value (referring to the above data) do i need to input into this function in order to perform wald test? and actually also for likelihood ration test? i am sorry for asking this question but honestly i am still a student who need to learn this logistic in matlab myself, thus having alot of obstacle to do it.hope u can teach me. thank you
From: Saari Saari on 21 Feb 2010 07:57 Dear Tom, i guess, i already have answers for my previous question about wald test. sorry for that. by the way, currently i am working with my data (approximately 145 data) and i realized one thing that whenever i include dummy variable as parameters, it seems like this matlab cannot work. i discovered that matlab did mention about dummy variable but i am not sure whether i can include that dummy coding together with glmfit and glmval function? "Saari Saari" <rafiqah0909(a)gmail.com> wrote in message <hlgblm$hap$1(a)fred.mathworks.com>... > "Tom Lane" <tlane(a)mathworks.com> wrote in message <hkpd2j$8s$1(a)fred.mathworks.com>... > > > besides that, as we know in logistic regression, the significant of > > > coefficients can be tested via wald test and log-likelihood ratio test. > > > Iis that a direct way (embedded coding) that we can perform wald test or > > > loglikelihood ratio test In Matlab? > > > > The third output from glmfit is a structure that includes the following > > fields: > > > > 'se' standard errors of coefficient estimates B > > 't' t statistics for B > > 'p' p-values for B > > > > So to test a coefficient you can look at its standard error, t statistic, > > and p-value. > > > > There are other ways to do it. The linhyptest function can perform more > > complicated tests using outputs from glmfit. Also, you can perform a test of > > the difference in deviance between two models using the second output from > > glmfit. > > > > -- Tom > > > > yes, i also used that third output to test the coefficient. but as in my project, i still need to test for likelihood ratio and wald test. i did try to used these function however, for example in wald test, it requires me to include three input which honestly i dont know because in normal way i did it (use webste software), wald test is generated directly when i do not need to include any input. > > let say with this kind of data > x=[1 1 3 3 3 3 3 3 1 1 2 1 1 2 1 3 2 3 1 1 3 2 3 1 2 2 3 3 2 1 1 1 3 2 1 2 2 3 1 3 3;2 2 5 5 6 5 5 5 2 1 4 1 1 3 2 6 4 6 1 2 5 4 5 1 3 3 5 5 4 2 2 2 6 4 1 4 3 5 2 6 5;3 3 1 1 1 1 1 1 2 2 2 1 3 1 1 1 2 2 2 2 2 1 3 3 3 4 4 4 4 1 1 1 2 2 1 1 1 2 3 4 1;2 2 2 2 2 1 1 3 2 2 3 1 2 2 2 2 1 1 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 2 1 2 2 1;4 4 1 2 3 1 1 6 1 2 4 1 4 3 6 5 2 1 3 2 2 3 1 1 1 2 6 5 1 1 2 6 5 6 3 4 1 1 1 1 1]'; > >> y=[0 0 0 1 0 1 1 1 0 0 1 0 0 0 0 1 1 1 0 0 1 1 1 0 0 0 1 1 1 0 0 0 1 1 0 0 0 1 0 1 1]'; > >> n=[1] > > n = > > 1 > > >> b=glmfit(x,[y ones(41,1)],'binomial','link','logit'); > >> [b,dev,st]=glmfit(x,[y ones(41,1)],'binomial','link','logit') > > b = > > -9.8295 > -0.2946 > 2.2637 > 0.9285 > -0.5614 > 0.3250 > > dev = > > 21.3815 > > > st = > > beta: [6x1 double] > dfe: 35 > sfit: 1.1768 > s: 1 > estdisp: 0 > covb: [6x6 double] > se: [6x1 double] > coeffcorr: [6x6 double] > t: [6x1 double] > p: [6x1 double] > resid: [41x1 double] > residp: [41x1 double] > residd: [41x1 double] > resida: [41x1 double] > > > in this argument, [h,pValue,stat,criticalValue] = waldtest(r,R,EstCov).... > what value (referring to the above data) do i need to input into this function in order to perform wald test? and actually also for likelihood ration test? > i am sorry for asking this question but honestly i am still a student who need to learn this logistic in matlab myself, thus having alot of obstacle to do it.hope u can teach me. thank you
From: Tom Lane on 2 Mar 2010 13:03 > i guess, i already have answers for my previous question about wald test. > sorry for that. by the way, currently i am working with my data > (approximately 145 data) and i realized one thing that whenever i include > dummy variable as parameters, it seems like this matlab cannot work. i > discovered that matlab did mention about dummy variable but i am not sure > whether i can include that dummy coding together with glmfit and glmval > function? Sabri, sorry for the delay in replying. I don't understand what you mean when you say MATLAB cannot work. It is possible to create a design matrix using the dummyvar function (or creating dummy variables any other way you like) and pass it into glmfit or glmval. One thing to watch out for is that if you include dummy variables that are indicators for every group value, then the set of them will be collinear with the constant term. You can either omit one of them or use the 'constant' parameter of glmfit to omit the constant term. -- Tom
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 4 Prev: Fruit image segmentation Next: MATLAB - serial communication problem..loss of data |