Hi folks,
I am using Maxent in R to model species distribution for Ethiopian sheep. I encountered the following error during the VariableSelection() step:
Error in system(command, as.integer(flag), f, stdout, stderr, timeout, :
character string expected as the first argument
Here’s my setup:
Operating System: Windows 10
Maxent Version: 3.4.1
R Version: 4.3.1
Java Version: 1.8.0_291
Relevant Packages: dismo
My R script:
maxent <- "D:/ENM_Analysis/maxent/maxent/maxent.jar"
gridfolder <- dir(path="D:/ENM_Analysis/maxent/maxent", pattern='asc', full.names=TRUE)
outdir <- "D:/ENM_Analysis/maxent/maxent/outdir"
occurrencelocations <- "D:/ENM_Analysis/maxent/maxent/VariablesAtOccurrencelocations.csv"
backgroundlocations <- "D:/ENM_Analysis/maxent/maxent/VariablesAtBackgroundlocations.csv"
additionalargs <- "nolinear noquadratic noproduct nothreshold noautofeature"
betamultiplier <- seq(0.5, 15, 0.2)
VariableSelection(
maxent,
outdir,
gridfolder,
occurrencelocations,
backgroundlocations,
additionalargs,
contributionthreshold = 5,
correlationthreshold = 0.9,
betamultiplier
)
I’ve verified the paths and that the .asc files exist in the maxent/maxent folder. What might be causing this error, and how can I resolve it?
Thanks in advance for your help!
Best regards,
Wondossen
--
You received this message because you are subscribed to the Google Groups "Maxent" group.
To unsubscribe from this group and stop receiving emails from it, send an email to maxent+un...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/maxent/33ef86cd-0016-4e51-9a41-73475ba1e4d3n%40googlegroups.com.
Dear Akos and all,
Thank you for your valuable suggestions.
I am encountering an error despite following your suggestion. Here is the error message:
maxent <- "D:/ENM_Analysis/maxent/maxent/maxent.jar"
> occurrencelocations<- ("D:/ENM_Analysis/maxent/maxent/VariablesAtOccurrencelocationsEthiopianCattle.csv")
> backgroundlocations<- ("D:/ENM_Analysis/maxent/maxent/VariablesAtBackgroundlocationsEthiopianCattle.csv")
> gridfolder <- ("D:/ENM_Analysis/maxent/maxent")
> outdir<- ("D:/ENM_Analysis/maxent/maxent/outdir")
> additionalargs="nolinear noquadratic noproduct nothreshold noautofeature"
> #we set the threshold to 5%, which means that all variables will be excluded when they
> #contribute less than 5% to the model:
> contributionthreshold<- 5
> #Correlated variables should be removed Of the correlated
> #variables, only the variable with the highest contribution score will be kept
> correlationthreshold <- 0.9
> #This argument sets the values of beta multipliers (regularization multipliers) for which variable selection shall
> #be performed. The smaller this value, the more closely will the projected distribution fit to the training data
> #set. Models that are overfitted to the occurrence data are poorly transferable to novel environments and, thus,
> #not appropriate to project distribution changes under environmental change. Performance will be compared
> #between models created with the beta values given in this betamultiplier vector. Thus, providing a range
> #of beta values from 1 (the default in Maxent) to 15 or so, will help you to spot the optimal beta multiplier
> #for your specific model.
> #Here, we are testing betamultipliers from 2 to 6 with steps of 0.5 with the following setting:
> betamultiplier=seq(0.5,15,0.2)
> VariableSelection(maxent,
+ outdir,
+ gridfolder,
+ occurrencelocations,
+ backgroundlocations,
+ additionalargs,
+ contributionthreshold,
+ correlationthreshold,
+ betamultiplier)
-----------------------
Choosing betamultiplier 0.5
Number of remaining variables 35
Testing variable contributions...
Calculating average AUC values from 10 maxent models...
Error in file(file, "rt") : cannot open the connection
In addition: Warning messages:
1: In system(paste("java -jar", maxent, "-o", outdir, "-j", gridfolder, :
running command 'java -jar D:/ENM_Analysis/maxent/maxent/maxent.jar -o D:/ENM_Analysis/maxent/maxent/outdir -j D:/ENM_Analysis/maxent/maxent -s D:/ENM_Analysis/maxent/maxent/outdir/VariablesAtOccurrencelocationsEthiopianCattle.csv_VariableSubset.csv -e D:/ENM_Analysis/maxent/maxent/outdir/VariablesAtBackgroundlocationsEthiopianCattle.csv_VariableSubset.csv plots=false writeplotdata=false visible=false autorun=true randomseed=true writebackgroundpredictions=false replicates=10 replicatetype=subsample randomtestpoints=50 redoifexists writemess=false writeclampgrid=false askoverwrite=false pictures=false outputgrids=false -b 0.5 nolinear noquadratic noproduct nothreshold noautofeature' had status 1
2: In file(file, "rt") :
cannot open file 'D:/ENM_Analysis/maxent/maxent/outdir/maxentResults.csv': No such file or directory
Thank you once again for your unwavering support.
Regrds,
Wondossen