Jeremy Little
2012-Jul-09 09:55 UTC
[R] Package 'MASS' (polr): Error in svd(X) : infinite or missing values in 'x'
Hello, I am trying to run an ordinal logistic regression (polr) using the package 'MASS'. I have successfully run other regression classes (glm, multinom) without much problem, but with the 'polr' class I get the following error: " Error in svd(X) : infinite or missing values in 'x' " which appears when I run the "summary" command. The data file is large (585000 rows) and has no NA, -9999 or blank values. My script (in brief) is as follows, with results: ############> library(MASS) > > ## ADD DATA > Jdata<- read.delim("/Analysis/20120709 JLittle data file.txt", header=T) > > attach(Jdata) > names(Jdata)[1] "POINTID" "Lat_Y_pos" "JVeg5" "Subregion" "Rock_U_Nam" "Rock_Name" "Elevation" "Slope" "Aspect" "Hillshade" "Stream_dist" "Coast_dist" "Coast_SE" [14] "Coast_E" "Wind_310" "TPI" "Landform"> > Global <- polr(JVeg5 ~ Elevation + Lat_Y_pos + Coast_dist + Stream_dist, > data=Jdata) > > summary(Global)Error in svd(X) : infinite or missing values in 'x'>##Try with omit NA command> Global <- polr(JVeg5 ~ Elevation + Lat_Y_pos + Coast_dist + Stream_dist, > data=Jdata, na.action = na.omit, Hess = TRUE) > > summary(Global)Error in svd(X) : infinite or missing values in 'x' ############ Does this imply an 'infinite value' and what would this mean? If anyone has any idea how to address this error, I would very much appreciate your response. Thank you in advance. Jeremy Date File Attachment (200 rows): http://r.789695.n4.nabble.com/file/n4635829/20120709_JLittle_data_file.txt 20120709_JLittle_data_file.txt -- View this message in context: http://r.789695.n4.nabble.com/Package-MASS-polr-Error-in-svd-X-infinite-or-missing-values-in-x-tp4635829.html Sent from the R help mailing list archive at Nabble.com.
Jessica Streicher
2012-Jul-09 16:26 UTC
[R] Package 'MASS' (polr): Error in svd(X) : infinite or missing values in 'x'
Since its something about the Hessian, and occurs in the vcov() call, have you thought about the note: "The vcov method uses the approximate Hessian: for reliable results the model matrix should be sensibly scaled with all columns having range the order of one. " ? I'm sorry i can't help you much further here, no idea about ordinal logistic regression ;) On 09.07.2012, at 11:55, Jeremy Little wrote:> Hello, > > I am trying to run an ordinal logistic regression (polr) using the package > 'MASS'. > > I have successfully run other regression classes (glm, multinom) without > much problem, but with the 'polr' class I get the following error: > " Error in svd(X) : infinite or missing values in 'x' " > which appears when I run the "summary" command. > > The data file is large (585000 rows) and has no NA, -9999 or blank values. > > My script (in brief) is as follows, with results: > > ############ >> library(MASS) >> >> ## ADD DATA >> Jdata<- read.delim("/Analysis/20120709 JLittle data file.txt", header=T) >> >> attach(Jdata) >> names(Jdata) > [1] "POINTID" "Lat_Y_pos" "JVeg5" "Subregion" "Rock_U_Nam" > "Rock_Name" "Elevation" "Slope" "Aspect" "Hillshade" > "Stream_dist" "Coast_dist" "Coast_SE" > [14] "Coast_E" "Wind_310" "TPI" "Landform" >> >> Global <- polr(JVeg5 ~ Elevation + Lat_Y_pos + Coast_dist + Stream_dist, >> data=Jdata) >> >> summary(Global) > Error in svd(X) : infinite or missing values in 'x' >> > ##Try with omit NA command >> Global <- polr(JVeg5 ~ Elevation + Lat_Y_pos + Coast_dist + Stream_dist, >> data=Jdata, na.action = na.omit, Hess = TRUE) >> >> summary(Global) > Error in svd(X) : infinite or missing values in 'x' > ############ > > Does this imply an 'infinite value' and what would this mean? > > If anyone has any idea how to address this error, I would very much > appreciate your response. > > Thank you in advance. > > Jeremy > > Date File Attachment (200 rows): > http://r.789695.n4.nabble.com/file/n4635829/20120709_JLittle_data_file.txt > 20120709_JLittle_data_file.txt > > > -- > View this message in context: http://r.789695.n4.nabble.com/Package-MASS-polr-Error-in-svd-X-infinite-or-missing-values-in-x-tp4635829.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.[[alternative HTML version deleted]]
Jessica Streicher
2012-Jul-10 07:56 UTC
[R] Package 'MASS' (polr): Error in svd(X) : infinite or missing values in 'x'
Hi Jeremy,
newData<-data.frame(JVeg5=factor(Jdata[,"JVeg5"]),scale(Jdata[,c("Elevation","Lat_Y_pos","Coast_dist","Stream_dist")]))
Global <- polr(JVeg5 ~ Elevation + Lat_Y_pos + Coast_dist + Stream_dist,
data=newData, na.action = na.omit, Hess = TRUE)
summary(Global)
Does this still do what you want? At least it doesn't produce the error like
this.
greetings Jessi
On 09.07.2012, at 11:55, Jeremy Little wrote:
> Hello,
>
> I am trying to run an ordinal logistic regression (polr) using the package
> 'MASS'.
>
> I have successfully run other regression classes (glm, multinom) without
> much problem, but with the 'polr' class I get the following error:
> " Error in svd(X) : infinite or missing values in 'x' "
> which appears when I run the "summary" command.
>
> The data file is large (585000 rows) and has no NA, -9999 or blank values.
>
> My script (in brief) is as follows, with results:
>
> ############
>> library(MASS)
>>
>> ## ADD DATA
>> Jdata<- read.delim("/Analysis/20120709 JLittle data
file.txt", header=T)
>>
>> attach(Jdata)
>> names(Jdata)
> [1] "POINTID" "Lat_Y_pos" "JVeg5"
"Subregion" "Rock_U_Nam"
> "Rock_Name" "Elevation" "Slope"
"Aspect" "Hillshade"
> "Stream_dist" "Coast_dist" "Coast_SE"
> [14] "Coast_E" "Wind_310" "TPI"
"Landform"
>>
>> Global <- polr(JVeg5 ~ Elevation + Lat_Y_pos + Coast_dist +
Stream_dist,
>> data=Jdata)
>>
>> summary(Global)
> Error in svd(X) : infinite or missing values in 'x'
>>
> ##Try with omit NA command
>> Global <- polr(JVeg5 ~ Elevation + Lat_Y_pos + Coast_dist +
Stream_dist,
>> data=Jdata, na.action = na.omit, Hess = TRUE)
>>
>> summary(Global)
> Error in svd(X) : infinite or missing values in 'x'
> ############
>
> Does this imply an 'infinite value' and what would this mean?
>
> If anyone has any idea how to address this error, I would very much
> appreciate your response.
>
> Thank you in advance.
>
> Jeremy
>
> Date File Attachment (200 rows):
> http://r.789695.n4.nabble.com/file/n4635829/20120709_JLittle_data_file.txt
> 20120709_JLittle_data_file.txt
>
>
> --
> View this message in context:
http://r.789695.n4.nabble.com/Package-MASS-polr-Error-in-svd-X-infinite-or-missing-values-in-x-tp4635829.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.
[[alternative HTML version deleted]]
Rune Haubo
2012-Jul-10 19:37 UTC
[R] Package 'MASS' (polr): Error in svd(X) : infinite or missing values in 'x'
Hi Jeremy, I think Jessica is right that probably you could make polr converge and produce a Hessian if the data are better scaled, but there might also be other things not allowing you to get the Hessian/vcov. Could be insightful if you showed us the result of str(Jdata) Also, I am thinking that perhaps the another implementation of ordinal regression models might avoid the problem. You could try the ordinal package (of which I am the author) -- the following should reproduce the MASS::polr results: install.packages(ordinal) library(ordinal) Global <- clm(JVeg5 ~ Elevation + Lat_Y_pos + Coast_dist + Stream_dist, data=Jdata) summary(Global) Another option would be Frank Harrell's lrm function in the rms package. HTH, Rune On 9 July 2012 11:55, Jeremy Little <jeremy.little at my.jcu.edu.au> wrote:> Hello, > > I am trying to run an ordinal logistic regression (polr) using the package > 'MASS'. > > I have successfully run other regression classes (glm, multinom) without > much problem, but with the 'polr' class I get the following error: > " Error in svd(X) : infinite or missing values in 'x' " > which appears when I run the "summary" command. > > The data file is large (585000 rows) and has no NA, -9999 or blank values. > > My script (in brief) is as follows, with results: > > ############ >> library(MASS) >> >> ## ADD DATA >> Jdata<- read.delim("/Analysis/20120709 JLittle data file.txt", header=T) >> >> attach(Jdata) >> names(Jdata) > [1] "POINTID" "Lat_Y_pos" "JVeg5" "Subregion" "Rock_U_Nam" > "Rock_Name" "Elevation" "Slope" "Aspect" "Hillshade" > "Stream_dist" "Coast_dist" "Coast_SE" > [14] "Coast_E" "Wind_310" "TPI" "Landform" >> >> Global <- polr(JVeg5 ~ Elevation + Lat_Y_pos + Coast_dist + Stream_dist, >> data=Jdata) >> >> summary(Global) > Error in svd(X) : infinite or missing values in 'x' >> > ##Try with omit NA command >> Global <- polr(JVeg5 ~ Elevation + Lat_Y_pos + Coast_dist + Stream_dist, >> data=Jdata, na.action = na.omit, Hess = TRUE) >> >> summary(Global) > Error in svd(X) : infinite or missing values in 'x' > ############ > > Does this imply an 'infinite value' and what would this mean? > > If anyone has any idea how to address this error, I would very much > appreciate your response. > > Thank you in advance. > > Jeremy > > Date File Attachment (200 rows): > http://r.789695.n4.nabble.com/file/n4635829/20120709_JLittle_data_file.txt > 20120709_JLittle_data_file.txt > > > -- > View this message in context: http://r.789695.n4.nabble.com/Package-MASS-polr-Error-in-svd-X-infinite-or-missing-values-in-x-tp4635829.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at 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.-- Rune Haubo Bojesen Christensen Ph.D. Student, M.Sc. Eng. Phone: (+45) 45 25 33 63 Mobile: (+45) 30 26 45 54 DTU Informatics, Section for Statistics Technical University of Denmark, Build. 305, Room 122, DK-2800 Kgs. Lyngby, Denmark
Seemingly Similar Threads
- Package MuMIn (dredge): Error in ret[, ] <- cbind(x, se, rep(if (is.null(df)) NA_real_ else df, : number of items to replace is not a multiple of replacement length.
- Problem dropping rows based on values in a column
- fPortfolio constraints, maxsumW
- Setting up infile for R CMD BATCH
- samba sam problem [version 2.2.3a on RH 8]