Re: [R] 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.

2012-07-15 Thread Jeremy Little
I have also reinstalled the MuMIn package as suggested at...

http://r.789695.n4.nabble.com/Error-message-number-of-items-to-replace-is-not-a-multiple-of-replacement-length-td3257893.html

...however, this made no difference.

any help is appreciated.

thank you

--
View this message in context: 
http://r.789695.n4.nabble.com/Package-MuMIn-dredge-Error-in-ret-cbind-x-se-rep-if-is-null-df-NA-real-else-df-number-of-items-to-re-tp4636105p4636604.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.


[R] 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.

2012-07-11 Thread Jeremy Little
Hello R community,

I am attempting to run multiple logistic regressions (multinomial, via
package 'nnet'), with Automated Model Selection (dredge, package 'MuMIn').

The aim is to reduce the number of predictor variables by assessing relative
performance of each variable, which can be done in a coarse fashion using
the Automated Model Selection option in package 'MuMIn' [dredge].

The data file is large (585000 rows) and has no NA, - or blank values
(attached data file with 200 rows).

Following the dredge command, I get the following error and warning (see end
of message for details):
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
In addition: Warning message:
In cbind(x, se, rep(if (is.null(df)) NA_real_ else df, length.out = n),  :
  number of rows of result is not a multiple of vector length (arg 3).

I am unclear what this means and how to resolve the issue.
If anyone has any idea how to address this error, I would very much
appreciate your response.

Thank you in advance.

Jeremy


My script is as follows :


## LOAD PACKAGES
library(MASS)
library(MuMIn)
library(nnet)
library(AICcmodavg)

Jdata- read.delim(/Analysis/20120709 JLittle data file.txt, header=T)

attach(Jdata)
names(Jdata)

##NNET
##MULTINOMIAL LOGISTIC REGRESSION
##multinom(formula, data, weights, subset, na.action, contrasts = NULL, 
##Hess = FALSE, summ = 0, censored = FALSE,
##model = FALSE, ...)

##Full Model
##14 variables

model1 - multinom(JVeg5~Elevation + Lat_Y_pos + Coast_dist + Coast_SE +
Coast_E + Stream_dist + Subregion + Rock_Name + Slope + Aspect + Hillshade +
Wind_310 + TPI + Landform, data=Jdata, maxit=600)

##with 14 variables, maximum iterations reached without convergence,
therefore...
##have added maxit=600 argument, this increases maximum number of iterations
##from 100 to 600 (convergence at 550).

summary(model1)

##MuMIn
##dredge analysis
dredge1 - dredge(model1)



Following the last line of the script, I get the following output:

# weights:  10 (4 variable)
initial  value 44.275905 
iter  10 value 573524.741778
final  value 572802.916150 
converged
# weights:  15 (8 variable)
initial  value 44.275905 
iter  10 value 596499.388517
iter  20 value 572607.756806
final  value 572606.390789 
converged
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
In addition: Warning message:
In cbind(x, se, rep(if (is.null(df)) NA_real_ else df, length.out = n),  :
  number of rows of result is not a multiple of vector length (arg 3)



My data details:
 str(Jdata)
'data.frame': 552270 obs. of  17 variables:
 $ POINTID: int  582358 582360 582361 582359 35289 582357 582362 411225
584336 584493 ...
 $ Lat_Y_pos  : num  19.7 19.7 19.7 19.7 16 ...
 $ JVeg5  : Factor w/ 5 levels 1RF,2WSFEG,..: 5 5 5 5 1 5 5 5 5 5
...
 $ Subregion  : Factor w/ 47 levels AU-BF,AU-BK,..: 16 16 46 16 8 16 46
28 46 46 ...
 $ Rock_U_Nam : Factor w/ 607 levels Adler Hill Basalt,..: 33 33 33 33 173
33 33 585 112 112 ...
 $ Rock_Name  : Factor w/ 32 levels ALLUVIUM,ARENITE,..: 13 13 13 13 25
13 13 10 23 23 ...
 $ Elevation  : num  317 230 180 317 107 ...
 $ Slope  : num  35.5 44.7 39.1 43.5 23 ...
 $ Aspect : num  25.3 3.68 30.83 4.02 254.66 ...
 $ Hillshade  : int  182 211 167 212 200 218 216 245 214 27 ...
 $ Stream_dist: num  4241 4288 4330 4252 2160 ...
 $ Coast_dist : num  39497 39128 38883 39312 5601 ...
 $ Coast_SE   : num  404751 404821 404468 404680 28426 ...
 $ Coast_E: int  78000 77500 77250 77750 15550 78250 77000 55650 77000
76800 ...
 $ Wind_310   : int  10 10 10 10 10 10 10 10 2 10 ...
 $ TPI: num  -122.6 -109 -95.9 -94.7 -76.6 ...
 $ Landform   : int  1 1 1 1 1 1 1 1 1 1 ... 

Date File Attachment (200 rows):
http://r.789695.n4.nabble.com/file/n4636105/20120709_JLittle_data_file.txt
20120709_JLittle_data_file.txt 

--
View this message in context: 
http://r.789695.n4.nabble.com/Package-MuMIn-dredge-Error-in-ret-cbind-x-se-rep-if-is-null-df-NA-real-else-df-number-of-items-to-re-tp4636105.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.


Re: [R] Package 'MASS' (polr): Error in svd(X) : infinite or missing values in 'x'

2012-07-11 Thread Jeremy Little

Dear Jessica

thank you for the scale solution to my problem.

I tried to manually scale my data (scaling up and removing decimals),
however, this resulted in the same error message.

It remains vague to me what the precise meaning of...
the model matrix should be sensibly scaled with all columns having range
the order of one
…actually means.

Regardless, the script you have supplied works for my data and looks (at
this point) like a suitable solution.

Many many thanks for your time in resolving this issue.




Dear Rune,

thank you for your valuable input.

I used the package 'ordinal' originally for this ordinal logistic regression
and this package was straight forward and worked fine without any errors.

However, I switched to using 'MASS', as I need to run these models through
an additional package 'AICcmodavg', which requires the 'MASS' inputs. Hence,
I have needed the models to work in 'MASS'.

The str(Jdata) call gives the following:

 str(Jdata)
'data.frame':   552270 obs. of  17 variables:
 $ POINTID: int  582358 582360 582361 582359 35289 582357 582362 411225
584336 584493 ...
 $ Lat_Y_pos  : num  19.7 19.7 19.7 19.7 16 ...
 $ JVeg5  : Factor w/ 5 levels 1RF,2WSFEG,..: 5 5 5 5 1 5 5 5 5 5
...
 $ Subregion  : Factor w/ 47 levels AU-BF,AU-BK,..: 16 16 46 16 8 16 46
28 46 46 ...
 $ Rock_U_Nam : Factor w/ 607 levels Adler Hill Basalt,..: 33 33 33 33 173
33 33 585 112 112 ...
 $ Rock_Name  : Factor w/ 32 levels ALLUVIUM,ARENITE,..: 13 13 13 13 25
13 13 10 23 23 ...
 $ Elevation  : num  317 230 180 317 107 ...
 $ Slope  : num  35.5 44.7 39.1 43.5 23 ...
 $ Aspect : num  25.3 3.68 30.83 4.02 254.66 ...
 $ Hillshade  : int  182 211 167 212 200 218 216 245 214 27 ...
 $ Stream_dist: num  4241 4288 4330 4252 2160 ...
 $ Coast_dist : num  39497 39128 38883 39312 5601 ...
 $ Coast_SE   : num  404751 404821 404468 404680 28426 ...
 $ Coast_E: int  78000 77500 77250 77750 15550 78250 77000 55650 77000
76800 ...
 $ Wind_310   : int  10 10 10 10 10 10 10 10 2 10 ...
 $ TPI: num  -122.6 -109 -95.9 -94.7 -76.6 ...
 $ Landform   : int  1 1 1 1 1 1 1 1 1 1 ...

Does this provide any insight?

Thank you
##

Thank you both for your generous time and support, it is greatly
appreciated.

kind regards

Jeremy

--
View this message in context: 
http://r.789695.n4.nabble.com/Package-MASS-polr-Error-in-svd-X-infinite-or-missing-values-in-x-tp4635829p4636091.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.


Re: [R] Package 'MASS' (polr): Error in svd(X) : infinite or missing values in 'x'

2012-07-11 Thread Jeremy Little
Thanks Jessi,

your insights are extremely helpful.

If you would indulge me one more quick question on your script.
You have written...
newData-data.frame(JVeg5=factor(Jdata[,JVeg5]),scale(Jdata[,c(Elevation,Lat_Y_pos,Coast_dist,Stream_dist)]))

I wish to expand this analysis for all other variables in my data matrix, of
which one is a factor (and therefore cannot be 'scaled').

Adding these variables to your script...
newData-data.frame(JVeg5=factor(Jdata[,JVeg5]),scale(Jdata[,c(Elevation,
Slope, Aspect, Hillshade, Lat_Y_pos, Coast_dist, Coast_SE,
Coast_E, Wind_310, Stream_dist, TPI, Landform, Rock_Name)]))

...returns the error:
Error in colMeans(x, na.rm = TRUE) : 'x' must be numeric

because Rock_Name must be numeric to be scaled.

I've tried a couple of options for incorporating this factor (Rock_Name)
into the script without success.
For example:
 newData-data.frame(JVeg5=factor(Jdata[,JVeg5],
Rock_Name=factor(Jdata[,Rock_Name]), scale(Jdata[,c(Elevation, Slope,
Aspect, Hillshade, Lat_Y_pos, Coast_dist, Coast_SE, Coast_E,
Wind_310, Stream_dist, TPI, Landform)]))

Do you have a suggestion which might work for this analysis?

Thank you for your support with this, I really appreciate it.

kind regards





--
View this message in context: 
http://r.789695.n4.nabble.com/Package-MASS-polr-Error-in-svd-X-infinite-or-missing-values-in-x-tp4635829p4636244.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.


[R] Package 'MASS' (polr): Error in svd(X) : infinite or missing values in 'x'

2012-07-09 Thread Jeremy Little
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, - 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_310TPI 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.


Re: [R] Package 'MASS' (polr): Error in svd(X) : infinite or missing values in 'x'

2012-07-09 Thread Jeremy Little
Hi Jessica,

thank you for your prompt response. Yes I had deduced it had to do with the
Hessian.

However, I am not clear what all columns having range the order of one
actually means and what this means for my data. Does this mean removing
decimals (ie by shifting the decimal place)?

I would have thought that the data matrix was already sensibly scaled.

Any further insight greatly appreciated.

Regards


--
View this message in context: 
http://r.789695.n4.nabble.com/Package-MASS-polr-Error-in-svd-X-infinite-or-missing-values-in-x-tp4635829p4635928.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.