-
Notifications
You must be signed in to change notification settings - Fork 4
Description
Jason Roberts is fitting a gamma with covariates. Minimum reproducible example with the golf tees (below) causes a spurious error to be written to the console:
Code:
library(mrds)
data(book.tee.data)
region <- book.tee.data$book.tee.region
egdata <- book.tee.data$book.tee.dataframe
# reduce detections at small distances
reduced <- egdata[egdata$distance>0.3, ]
samples <- book.tee.data$book.tee.samples
obs <- book.tee.data$book.tee.obs
result <- ddf(dsmodel = ~mcds(key = "gamma", formula = ~sex),
data = reduced[reduced$observer==1, ], method = "ds",
meta.data = list(width = 4))
summary(result)
plot(result, main="Gamma with sex as covariate")
Message
** Error: When covariates are present, only the half-normal or hazard-rate keys may be specified. **
This appears to be coming from run.MCDS that writes a command file to send to MCDS. This command file is incorrect when the gamma is used
Browse[1]> log.file
[1] " This is mcds.exe version 7.4.0 "
[2] " OPTIONS; "
[3] " DISTANCE=PERP /UNITS='Meters' /WIDTH=4; "
[4] " TYPE=LINE; "
[5] " OBJECT=SINGLE; "
[6] " PRINT=SUMMARY; "
[7] " SELECTION=SPECIFY; "
[8] " END; "
[9] " DATA /STRUCTURE=FLAT; "
[10] " FIELDS=SMP_LABEL,SMP_EFFORT,DISTANCE,sex; "
[11] " INFILE=C:\\Users\\erexs\\AppData\\Local\\Temp\\RtmpITJx3q\\data54cc42d45de4.txt /NOECHO; "
[12] " Data will be input from file - [...]TMPITJX3Q\\DATA54CC42D45DE4.TXT"
[13] " END; "
[14] " Dataset has been stored."
[15] " ESTIMATE; "
[16] " DETECTION=ALL; "
[17] " ESTIMATOR /KEY=NEXPON /COVARIATES=sex; "
[18] " MONOTONE=NONE; "
[19] " DISTANCE /WIDTH=4 /LEFT=0; "
[20] " END; "
[21] "** Error: When covariates are present, only the half-normal or hazard-rate keys may be specified. **"
Note the negative exponential incorrectly gets specified and the error messages is appended to the log.file and subsequently printed to the console.
But the story continues:
I believe the code carries on (in ddf.ds) after failing to fit the model when using MCDS, to use the "R" optimiser, which succeeds in fitting the desired gamma-key model with a covariate.
Conclusion
A trap needs to be constructed such that MCDS is not called when trying to fit a gamma key with covariates