glm - prediction of a factor with several levels

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

glm - prediction of a factor with several levels

blackscorpio
Dear community,
I'm currently attempting to predict the occurence of an event (factor) having more than 2 levels with several continuous predictors. The model being ordinal, I was waiting the glm function to return several intercepts, which is not the case when looking to my results (I only have one intercept). I finally managed to perform an ordinal polytomous logisitc regression with the polr function, which gives several intercepts.
But does anyone know what was the model performed with glm and why only one intercept was given ?
Thanks a lot for your help !
Reply | Threaded
Open this post in threaded view
|

Re: glm - prediction of a factor with several levels

bbolker
blackscorpio <olivier.collignon <at> live.fr> writes:

> I'm currently attempting to predict the occurence of an event (factor)
> having more than 2 levels with several continuous predictors. The model
> being ordinal, I was waiting the glm function to return several intercepts,
> which is not the case when looking to my results (I only have one
> intercept). I finally managed to perform an ordinal polytomous logisitc
> regression with the polr function, which gives several intercepts.
> But does anyone know what was the model performed with glm and why only one
> intercept was given ?

  It's not sufficiently clear (to me at least) what you're trying to
do.  Please provide a minimal reproducible example ... As far as I know,
polr is the right way to do ordinal regression; it's not clear how you
were trying to use glm to do it.

  Ben Bolker

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: glm - prediction of a factor with several levels

zachmohr
In reply to this post by blackscorpio
As far as I know, glm only works with dichotomous or count data.  polr in the MASS package works and so does lrm {Design} for ordinal dependent variables.  I would assume that the model produced by glm is a dichotomous version of your model but not sure.  Only one intercept would be given because if you used the log link then it would have produced a dichotomous model instead of an ordered logistic regression.  My suggestion is to use polr or lrm.

On Fri, Jul 23, 2010 at 6:15 PM, blackscorpio [via R] <[hidden email]> wrote:
Dear community,
I'm currently attempting to predict the occurence of an event (factor) having more than 2 levels with several continuous predictors. The model being ordinal, I was waiting the glm function to return several intercepts, which is not the case when looking to my results (I only have one intercept). I finally managed to perform an ordinal polytomous logisitc regression with the polr function, which gives several intercepts.
But does anyone know what was the model performed with glm and why only one intercept was given ?
Thanks a lot for your help !







--
Department of Public Administration
University of Kansas
4060 Wesco Hall
Office W
Lawrence KS 66045-3177

Phone: (785) 813-1384
Email: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: glm - prediction of a factor with several levels

blackscorpio
Thanks a lot for your anwers.
To Ben Bolker  : I am trying to perform an ordinal logistic regression to predict an Y 3-class variable, having observed 3 continous predictors V1, V2, V3.
With random data my code would be something like :  

# simulate 10 observations of 3 independant N(0,1) predictors
X=rmvnorm(10,rep(0,3))
# variable to predict
Y=c(1,1,1,2,2,2,3,3,3,3)
# create data frame
A=as.data.frame(cbind(X,Y))
# turn Y into class variable
A$Y=as.factor(A$Y)
# perform logisitic regression
glm(Y~V1+V2+V3,A,family="binomial")

As only one intercept is returned, it seems indeed that a 2-class model has been performed instead, as said by zachmor.
Although I solved my problem by using polr instead of glm, I'd like to understand what glm does in such a case since it gave me better well-classification rates with the predict function.

Thanks a lot again !
Reply | Threaded
Open this post in threaded view
|

Re: glm - prediction of a factor with several levels

Marc Schwartz-3
On Jul 26, 2010, at 4:18 AM, blackscorpio wrote:

>
> Thanks a lot for your anwers.
> To Ben Bolker  : I am trying to perform an ordinal logistic regression to
> predict an Y 3-class variable, having observed 3 continous predictors V1,
> V2, V3.
> With random data my code would be something like :  
>
> # simulate 10 observations of 3 independant N(0,1) predictors
> X=rmvnorm(10,rep(0,3))
> # variable to predict
> Y=c(1,1,1,2,2,2,3,3,3,3)
> # create data frame
> A=as.data.frame(cbind(X,Y))
> # turn Y into class variable
> A$Y=as.factor(A$Y)
> # perform logisitic regression
> glm(Y~V1+V2+V3,A,family="binomial")
>
> As only one intercept is returned, it seems indeed that a 2-class model has
> been performed instead, as said by zachmor.
> Although I solved my problem by using polr instead of glm, I'd like to
> understand what glm does in such a case since it gave me better
> well-classification rates with the predict function.
>
> Thanks a lot again !


>From the Details section of ?glm:

 "For binomial and quasibinomial families the response can also be specified as a factor (****when the first level denotes failure and all others success****) ..."


So "1" is a failure and c("2", "3") denote success, thus a two level response.

BTW, if you are going to use a function (eg. rmvnorm()) from an external package, be sure to include the relevant library() call in your example code so folks don't need to guess which CRAN package(s) may be required to run it.

HTH,

Marc Schwartz

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: glm - prediction of a factor with several levels

blackscorpio
"when the first level denotes failure and all others success"

Yes, I saw this sentence in the glm help file, but I hadn't understood it this way... Anyway I checked this with a few examples and this is exactly what it does.
Thanks a lot for your help !!!

I can go back now to the polr function and try to understand why my results were better with glm.
By the way, does anyone know how I can solve the likelyhood maximization problem :

"attempt to find suitable starting values failed"

obtained with polr :

require(MASS)
data(iris)
polr(Species~Sepal.Length+Sepal.Width+Petal.Length+Petal.Width,iris)

(I know this has to be a nominal model but I do as levels were ordered for the example).
I tried to solve this by setting the "start" option to a null or a random vector by it doesn't garantee to find "a good" solution at the end.

Thanks a lot !