Hi Peter, It gives me breakdown of all categories with their respective freq. Diploma general honors 50 45 105 On Sat, Jul 9, 2016 at 4:07 PM, peter dalgaard <pdalgd at gmail.com> wrote:> > What does table(m11$prog) tell you? > -pd > > > On 09 Jul 2016, at 12:29 , Shivi Bhatia <shivipmp82 at gmail.com> wrote: > > > > Dear Team, > > > > I am running a multinomial logistic regression model for one of the > > fictitious data before i implement the same on my real data. > > Here i am trying to predict based some scores and economic group whether > a > > person will go for a diploma, general or honors. > > > > The code below: > > m11$prog2<- relevel(m11$prog, ref = "honors" > > > > already loaded the nnet library. However i got the below error: > > Error in relevel.factor(m11$prog, ref = "honors") : > > 'ref' must be an existing level > > > > I have tried searching on SO and nabble but did not find an answer that > > could help. > > > > Please suggest what is incorrect. Also checked the class of the var and > is > > a factor variable. > > > > [[alternative HTML version deleted]] > > > > ______________________________________________ > > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > > 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, Professor, > Center for Statistics, Copenhagen Business School > Solbjerg Plads 3, 2000 Frederiksberg, Denmark > Phone: (+45)38153501 > Office: A 4.23 > Email: pd.mes at cbs.dk Priv: PDalgd at gmail.com > > > > > > > > > >[[alternative HTML version deleted]]
Hmm, and levels(m11$prog)? (There's a chance that a space has sneaked in, but your HTML mail makes it hard to see column alignment) -pd> On 09 Jul 2016, at 12:50 , Shivi Bhatia <shivipmp82 at gmail.com> wrote: > > Hi Peter, > It gives me breakdown of all categories with their respective freq. > Diploma general honors > 50 45 105 > > On Sat, Jul 9, 2016 at 4:07 PM, peter dalgaard <pdalgd at gmail.com> wrote: > > What does table(m11$prog) tell you? > -pd > > > On 09 Jul 2016, at 12:29 , Shivi Bhatia <shivipmp82 at gmail.com> wrote: > > > > Dear Team, > > > > I am running a multinomial logistic regression model for one of the > > fictitious data before i implement the same on my real data. > > Here i am trying to predict based some scores and economic group whether a > > person will go for a diploma, general or honors. > > > > The code below: > > m11$prog2<- relevel(m11$prog, ref = "honors" > > > > already loaded the nnet library. However i got the below error: > > Error in relevel.factor(m11$prog, ref = "honors") : > > 'ref' must be an existing level > > > > I have tried searching on SO and nabble but did not find an answer that > > could help. > > > > Please suggest what is incorrect. Also checked the class of the var and is > > a factor variable. > > > > [[alternative HTML version deleted]] > > > > ______________________________________________ > > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > > 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, Professor, > Center for Statistics, Copenhagen Business School > Solbjerg Plads 3, 2000 Frederiksberg, Denmark > Phone: (+45)38153501 > Office: A 4.23 > Email: pd.mes at cbs.dk Priv: PDalgd at gmail.com > > > > > > > > > >-- Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Office: A 4.23 Email: pd.mes at cbs.dk Priv: PDalgd at gmail.com
Dear Shivi Are you sure that the level is "honors" and not " honors" or "honors " or something similar? On 09/07/2016 11:50, Shivi Bhatia wrote:> Hi Peter, > It gives me breakdown of all categories with their respective freq. > Diploma general honors > 50 45 105 > > On Sat, Jul 9, 2016 at 4:07 PM, peter dalgaard <pdalgd at gmail.com> wrote: > >> >> What does table(m11$prog) tell you? >> -pd >> >>> On 09 Jul 2016, at 12:29 , Shivi Bhatia <shivipmp82 at gmail.com> wrote: >>> >>> Dear Team, >>> >>> I am running a multinomial logistic regression model for one of the >>> fictitious data before i implement the same on my real data. >>> Here i am trying to predict based some scores and economic group whether >> a >>> person will go for a diploma, general or honors. >>> >>> The code below: >>> m11$prog2<- relevel(m11$prog, ref = "honors" >>> >>> already loaded the nnet library. However i got the below error: >>> Error in relevel.factor(m11$prog, ref = "honors") : >>> 'ref' must be an existing level >>> >>> I have tried searching on SO and nabble but did not find an answer that >>> could help. >>> >>> Please suggest what is incorrect. Also checked the class of the var and >> is >>> a factor variable. >>> >>> [[alternative HTML version deleted]] >>> >>> ______________________________________________ >>> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see >>> 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, Professor, >> Center for Statistics, Copenhagen Business School >> Solbjerg Plads 3, 2000 Frederiksberg, Denmark >> Phone: (+45)38153501 >> Office: A 4.23 >> Email: pd.mes at cbs.dk Priv: PDalgd at gmail.com >> >> >> >> >> >> >> >> >> >> > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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. >-- Michael http://www.dewey.myzen.co.uk/home.html
Dear Shivi Just printing it will not tell you. I did not mean 'Have you spelled it correctly?' I meant 'Is there a stray space somewhere?'. Peter has the same suspicion. On 09/07/2016 12:49, Shivi Bhatia wrote:> Hi Michael, > > I did check again and used the print command but it is spelled as honors. > > Hi Peter, > there are only 3 levels : Diploma general honors. I have downloaded > the data set from url : > > "http://quantedu.com/wp-content/uploads/2014/05/d1.txt" > > On Sat, Jul 9, 2016 at 5:06 PM, Michael Dewey <lists at dewey.myzen.co.uk > <mailto:lists at dewey.myzen.co.uk>> wrote: > > Dear Shivi > > Are you sure that the level is "honors" and not " honors" or "honors > " or something similar? > > > On 09/07/2016 11:50, Shivi Bhatia wrote: > > Hi Peter, > It gives me breakdown of all categories with their respective freq. > Diploma general honors > 50 45 105 > > On Sat, Jul 9, 2016 at 4:07 PM, peter dalgaard <pdalgd at gmail.com > <mailto:pdalgd at gmail.com>> wrote: > > > What does table(m11$prog) tell you? > -pd > > On 09 Jul 2016, at 12:29 , Shivi Bhatia > <shivipmp82 at gmail.com <mailto:shivipmp82 at gmail.com>> wrote: > > Dear Team, > > I am running a multinomial logistic regression model for > one of the > fictitious data before i implement the same on my real data. > Here i am trying to predict based some scores and > economic group whether > > a > > person will go for a diploma, general or honors. > > The code below: > m11$prog2<- relevel(m11$prog, ref = "honors" > > already loaded the nnet library. However i got the below > error: > Error in relevel.factor(m11$prog, ref = "honors") : > 'ref' must be an existing level > > I have tried searching on SO and nabble but did not find > an answer that > could help. > > Please suggest what is incorrect. Also checked the class > of the var and > > is > > a factor variable. > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org <mailto:R-help at r-project.org> > mailing list -- To UNSUBSCRIBE and more, see > 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, Professor, > Center for Statistics, Copenhagen Business School > Solbjerg Plads 3, 2000 Frederiksberg, Denmark > Phone: (+45)38153501 > Office: A 4.23 > Email: pd.mes at cbs.dk <mailto:pd.mes at cbs.dk> Priv: > PDalgd at gmail.com <mailto:PDalgd at gmail.com> > > > > > > > > > > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org <mailto:R-help at r-project.org> mailing list > -- To UNSUBSCRIBE and more, see > 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. > > > -- > Michael > http://www.dewey.myzen.co.uk/home.html > >-- Michael http://www.dewey.myzen.co.uk/home.html
> On Jul 9, 2016, at 4:32 AM, peter dalgaard <pdalgd at gmail.com> wrote: > > Hmm, and levels(m11$prog)?Shivi; See what this returns: "honors" %in% levels(m11$prog) The level is probably something like " honors" It's fairly easy to inadvertently create leading or trailing spaces when reading from comma-separated files.> test <- read.csv( text = " honors, others\n honors, others\n", header=FALSE) > testV1 V2 1 honors others 2 honors others> nchar(test$V1)Error in nchar(test$V1) : 'nchar()' requires a character vector> nchar(as.character(test$V1))[1] 7 7> "honors" %in% levels(test$V1)[1] FALSE -- David.> > (There's a chance that a space has sneaked in, but your HTML mail makes it hard to see column alignment) > > -pd > >> On 09 Jul 2016, at 12:50 , Shivi Bhatia <shivipmp82 at gmail.com> wrote: >> >> Hi Peter, >> It gives me breakdown of all categories with their respective freq. >> Diploma general honors >> 50 45 105 >> >> On Sat, Jul 9, 2016 at 4:07 PM, peter dalgaard <pdalgd at gmail.com> wrote: >> >> What does table(m11$prog) tell you? >> -pd >> >>> On 09 Jul 2016, at 12:29 , Shivi Bhatia <shivipmp82 at gmail.com> wrote: >>> >>> Dear Team, >>> >>> I am running a multinomial logistic regression model for one of the >>> fictitious data before i implement the same on my real data. >>> Here i am trying to predict based some scores and economic group whether a >>> person will go for a diploma, general or honors. >>> >>> The code below: >>> m11$prog2<- relevel(m11$prog, ref = "honors" >>> >>> already loaded the nnet library. However i got the below error: >>> Error in relevel.factor(m11$prog, ref = "honors") : >>> 'ref' must be an existing level >>> >>> I have tried searching on SO and nabble but did not find an answer that >>> could help. >>> >>> Please suggest what is incorrect. Also checked the class of the var and is >>> a factor variable. >>> >>> [[alternative HTML version deleted]] >>> >>> ______________________________________________ >>> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see >>> 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, Professor, >> Center for Statistics, Copenhagen Business School >> Solbjerg Plads 3, 2000 Frederiksberg, Denmark >> Phone: (+45)38153501 >> Office: A 4.23 >> Email: pd.mes at cbs.dk Priv: PDalgd at gmail.com >> >> >> >> >> >> >> >> >> >> > > -- > Peter Dalgaard, Professor, > Center for Statistics, Copenhagen Business School > Solbjerg Plads 3, 2000 Frederiksberg, Denmark > Phone: (+45)38153501 > Office: A 4.23 > Email: pd.mes at cbs.dk Priv: PDalgd at gmail.com > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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.David Winsemius Alameda, CA, USA