Plot.SpdModleTest function Unable to display positive and negative area
Closed this issue · 10 comments
Using the SPD model to analyze the carbon 14 data, the bbty parameter is “f” in the plot function is used to draw the positive and negative area, but the area cannot be displayed. However, the summary function can find the significant area.
library(openxlsx) data<-read.xlsx(file.choose()) caldates <- calibrate(x=data$BP, errors=data$SD, normalised=FALSE) bins <- binPrep(sites=data$SiteName, ages=data$BP, h=50) nsim=200 #Number of simulations expnull <- modelTest(caldates, errors=data$SD, bins=bins, nsim=nsim, runm=50,ncores = 3, timeRange=c(8000,1000), model="exponential", datenormalised=FALSE) #plot(expnull, xlim=c(8000,1000)) #round(expnull$pval,4) #p-value summary(expnull) plot( expnull, calendar = "BP", type = "spd", ylim = c(0,0.2), xlim = c(8000,1000), col.obs = "black", col.env = rgb(0, 0, 0, 0.2), lwd.obs = 0.5, xaxs = "i", yaxs = "i", bbty = "f", bbtyRet = TRUE, drawaxes = TRUE )
the result figure:
the summary result:
Hi, I tested the code with another dateset and I am failing to reproduce the problem. I'm afraid that in order to help I would need have access to the data so I can reproduce the error. A couple of questions:
- Which version of rcarbon are you using?
- Does the problem arises when you simply run
plot(expnull)
? - The argument
col.env
is actually available only for results of thepermTest
and not for the resultsmodelTest
. You should have received a warning message? - Notice that
bbtyRet = TRUE
would work only whenbbty = "b"
.
Thank you for your reply.
Q1: The version 1.4.2
Q2: Actually, I got a warning message:"In modelTest(caldates, errors = data$SD, bins = bins, nsim = nsim, :
edgeSize reduced", but not irun plot function. It is at modelTest processing.
Q3: Actually, the first origin script is not including col.env. I do not receive a warning message.
Q4: I test change bbtyRet = FALSE, the problem still can not fix.
my data :
henan.xlsx
my code:
library(openxlsx)
data<-read.xlsx(file.choose())
caldates <- calibrate(x=data$BP, errors=data$SD, normalised=FALSE)
bins <- binPrep(sites=data$SiteName, ages=data$BP, h=50)
nsim=200 #Number of simulations
expnull <- modelTest(caldates, errors=data$SD, bins=bins, nsim=nsim, runm=50,ncores = 3,
timeRange=c(8000,1000), model="exponential", datenormalised=FALSE)
#plot(expnull, xlim=c(8000,1000))
plot(expnull)
#round(expnull$pval,4) #p-value
summary(expnull)
That is very strange... I used your code and regions outside the simulation envelope are highlighted correctly... (see below)
After the plot(expnull)
, could you try running the following code?
polygon(x = c(7000,6000,6000,7000),y=c(0.1,0.1,0.15,0.15),col=rgb(0.7,0,0,0.2),border=NA)
and see if it draws a square rectangle? And if it doesn't could you try with this:
polygon(x = c(7000,6000,6000,7000),y=c(0.1,0.1,0.15,0.15),col=1,border=NA)
Very strange... I was hoping it was something to do with with alpha transparency but the fact that you can display the first rectangle means that this is not the case... Does this happen with other datasets? Could you try the following and see what happens ?
data(emedyd)
emedyd <- subset(emedyd,Region=='1')
caldates <- calibrate(x=emedyd$CRA, errors=emedyd$Error, normalised=FALSE)
bins <- binPrep(sites=emedyd$SiteName, ages=emedyd$CRA, h=50)
set.seed(123)
expnull <- modelTest(caldates, errors=emedyd$Error,nsim=100,ncores=3, runm=50,timeRange=c(16000,9000), model="exponential", datenormalised=FALSE)
plot(expnull)
Also could you show me the results of your sessionInfo()
Not really a solution but could you try the following:
bb<-plot(expnull,bbty = 'b')
boomBlocks <- bb$booms
bustBlocks <- bb$busts
for (i in 1:length(boomBlocks)){
polygon(c(boomBlocks[[i]][[2]],rev(boomBlocks[[i]][[2]])),c(rep(+100,length(boomBlocks[[i]][[1]])),rep(-100,length(boomBlocks[[i]][[1]]))),col=rgb(0.7,0,0,0.2),border=NA)
}
for (i in 1:length(bustBlocks)){
polygon(c(bustBlocks[[i]][[2]],rev(bustBlocks[[i]][[2]])),c(rep(+100,length(bustBlocks[[i]][[1]])),rep(-100,length(bustBlocks[[i]][[1]]))),col=rgb(0,0,0.7,0.2),border=NA)
}
Glad to see that is working now! :) I'll close the issue