ahb108/rcarbon

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:
image
the summary result:
image

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:

  1. Which version of rcarbon are you using?
  2. Does the problem arises when you simply run plot(expnull)?
  3. The argument col.env is actually available only for results of the permTest and not for the results modelTest. You should have received a warning message?
  4. Notice that bbtyRet = TRUE would work only when bbty = "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)

Screenshot_2021-11-01_13-49-55

Yep...I try my code again and the picture as usual... But the rectangle could be draw by those code... I Confuse it....
image
image
may some issues about dependent package version? may be other?

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()

Yes, i try. But the area seem disappear.. I really hope may be some environmental problem, AND i will pick other computer try do the math.
image
image

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)
}

I seem like i find the reason... Maybe the environment of computer have some issues, maybe the windows10 update....
I really appreciate it for your help!
image

Glad to see that is working now! :) I'll close the issue