samedi 11 mai 2019

Error in solve.default(t(x2) %*% x2) : system is computationally singular: reciprocal condition number = 2.86159e-18

I perform the PSY analysis via the PSY package. However, the following error occurs Error in solve.default(t(x2) %*% x2) : system is computationally singular: reciprocal condition number = 2.86159e-18

I don't understand what this error means. Also when I plot the closing prices, the dates are not given on the x-axis. Even though I defined the first collum as dates.

Can someone help me solving this error?

I tried to create a new data frame intending that R connects the date and the closing pices. But this is not shown in the plot either. I tried to detect negative sqrt but the sqrt is taken from the observations and can't be negative.

The closing prices are downloaded for Bitcoin from CoinMarketCap.com

    mydata<- read.csv("C:path/BTC.csv", header=TRUE,
                      sep=",",stringsAsFactors = FALSE, as.is = TRUE)

The class of the provided data is checked.

    str(mydata)
    class(mydata$Date)

Date is exhibited in the German format in the csv file. It is converted to the english format, which is standard in R.

    newdate<-as.POSIXct(mydata$Date,format="%d/%m/%Y")
    str(newdate)
    mydata$Date<- newdate
    mydata

Now the data frame is ready and the PSY tests can be performed otherwise for date formate

    b<-as.Date(mydata$Date, format = "%d/%m/%Y")
    b
    mydata$Date<- b

A plot of the time series gives a first intuition, but does not provide x axis dates plot(mydata$Close)

Therefore, I thought to create a new data frame

    BTCPR <- mydata$Close

    df <- data.frame(mydata$Date, BTCPR)
    plot(df)
    str(df)

The follwing variables are guidelines, that provided by the PSY model

    y        <- BTCPR
    obs      <- length(y)
    r0       <- 0.01 + 1.8/sqrt(obs)
    swindow0 <- floor(r0*obs)
    dim      <- obs - swindow0 + 1
    IC       <- 2
    adflag   <- 6
    yr       <- 2
    Tb       <- 12*yr + swindow0 - 1
    nboot    <- 99

The BSADF, that represents the backward supremum Augmented Dickey Fuller test. It is calculated in the next step

    bsadf <- PSY(y, swindow0, IC, adflag)

Here the error occurs. Error in solve.default(t(x2) %*% x2) : system is computationally singular: reciprocal condition number = #2.86159e 18

The number of cores is arbitrarily set to 2

    quantilesBsadf <- cvPSYwmboot(y, swindow0, IC, adflag, Tb, nboot, nCores 
    = 2)

Expected results are the dates of Bubble formation and termination, which is calculated by the bsadf (backward sup Augmented Dickey-Fuller-Test)

Aucun commentaire:

Enregistrer un commentaire