[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.
Jeremy Little
jeremy.little at my.jcu.edu.au
Wed Jul 11 06:49:25 CEST 2012
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, -9999 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 888844.275905
iter 10 value 573524.741778
final value 572802.916150
converged
# weights: 15 (8 variable)
initial value 888844.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.
More information about the R-help
mailing list