From: Saari Saari on 4 Jan 2010 00:08 Hello Currently i am working for my project regarding logistic regression using several variables. for your information, i used glmfit function to calculate the coefficients. Here, i would like to ask regarding log likelihood ratios and standard error for my coefficients. Is there any way on how to calculate log likelihood ratios and standard errors using MATLAB? i really need to find the values for log likelihood ratios and standard error because i need to use them in order to test the significant for each variable in my equation. I hope there will be anyone who are willing to answer my question. Thank you so much for your cooperation. -Eikin-
From: Tom Lane on 4 Jan 2010 11:09 > Currently i am working for my project regarding logistic regression using > several variables. for your information, i used glmfit function to > calculate the coefficients. Here, i would like to ask regarding log > likelihood ratios and standard error for my coefficients. Is there any way > on how to calculate log likelihood ratios and standard errors using > MATLAB? i really need to find the values for log likelihood ratios and > standard error because i need to use them in order to test the significant > for each variable in my equation. Eikin, the third output from glmfit is a structure that contains a field 'se' of coefficient standard errors. For the log likelihood, I suggest two things. If you are interested in testing whether one model is better than another, you can use the deviance (second output from glmfit). If you really need the log likelihood itself, you'll have to compute it using the binopdf function after obtaining fitted values for the p parameter using glmfit. -- Tom
From: Saari Saari on 6 Jan 2010 05:09 Thanks alot Tom for ypur reply. I already try using binopdf function and it works. however, i still do not clear with standard error that u have explain because i did try to use 'se' but it still do not works. this is example of mine and i hope you can show me how to get the stndard error for each of my coefficient. >> 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'); >> fitted = glmval(b,x,'logit'); >> b=glmfit(x,[y ones(41,1)],'binomial','link','logit') b = -9.8295 -0.2946 2.2637 0.9285 -0.5614 0.3250 >> fitted = glmval(b,x,'logit'); >> loglikelihood = sum(log(binopdf(y,n,fitted))) loglikelihood = -10.6908 Thank you. "Tom Lane" <tlane(a)mathworks.com> wrote in message <hht3sj$qio$1(a)fred.mathworks.com>... > > Currently i am working for my project regarding logistic regression using > > several variables. for your information, i used glmfit function to > > calculate the coefficients. Here, i would like to ask regarding log > > likelihood ratios and standard error for my coefficients. Is there any way > > on how to calculate log likelihood ratios and standard errors using > > MATLAB? i really need to find the values for log likelihood ratios and > > standard error because i need to use them in order to test the significant > > for each variable in my equation. > > Eikin, the third output from glmfit is a structure that contains a field > 'se' of coefficient standard errors. > > For the log likelihood, I suggest two things. If you are interested in > testing whether one model is better than another, you can use the deviance > (second output from glmfit). If you really need the log likelihood itself, > you'll have to compute it using the binopdf function after obtaining fitted > values for the p parameter using glmfit. > > -- Tom >
From: Tom Lane on 6 Jan 2010 10:36 > Thanks alot Tom for ypur reply. I already try using binopdf function and > it works. however, i still do not clear with standard error that u have > explain because i did try to use 'se' but it still do not works. this is > example of mine and i hope you can show me how to get the stndard error > for each of my coefficient. .... >>> b=glmfit(x,[y ones(41,1)],'binomial','link','logit'); Just get the additional outputs from glmfit. The second and third outputs are the deviance and a structure containing various information, including standard errors. For example, here I create a matrix containing a table of coefficients, standard errors, t-statistics, and p-values: [b,dev,st]=glmfit(x,y,'binomial'); coefftable = [b st.se st.t st.p] -- Tom
From: Saari Saari on 7 Jan 2010 00:07 "Tom Lane" <tlane(a)mathworks.com> wrote in message <hi2al5$2mu$1(a)fred.mathworks.com>... > > Thanks alot Tom for ypur reply. I already try using binopdf function and > > it works. however, i still do not clear with standard error that u have > > explain because i did try to use 'se' but it still do not works. this is > > example of mine and i hope you can show me how to get the stndard error > > for each of my coefficient. > ... > >>> b=glmfit(x,[y ones(41,1)],'binomial','link','logit'); > > Just get the additional outputs from glmfit. The second and third outputs > are the deviance and a structure containing various information, including > standard errors. For example, here I create a matrix containing a table of > coefficients, standard errors, t-statistics, and p-values: > > [b,dev,st]=glmfit(x,y,'binomial'); > coefftable = [b st.se st.t st.p] > > -- Tom > Thanks alot Tom for helping me to clear the doubts. By the way, i still have question to ask you. I have try several other data for this logistic regression model. However, i noticed when the data need alot of iterations before converging, the final value for the coefficients seems to be wrong. I knew that the values are wrong because i tried to use the same data using 2 other logistic regression packages. My friend told me this is because of underfitting and overfitting concept. If that so, where should i adjust or modify in order to get the same value for the same data in matlab.
|
Next
|
Last
Pages: 1 2 3 4 Prev: Fruit image segmentation Next: MATLAB - serial communication problem..loss of data |