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.
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: