Mutate using multiple argument in function sn libry psn fuction

279 views Asked by At

I am trying to get an array of with the first column being an x value and the second column to bee the probability of a sweked t-normal using the sn library function called "psn".

My x-value (finfl_new2) and parameter(par) to be used as with the function psn are stored in df1. Each row in my data set has for each element (x-value) a different set of parameters. My data looks like this.

I have the following:

myp <- function(par,value){
  par0 <- unlist(par)
  data.frame(x=value,prob=sn::psn(x=value,
                       xi=par0[1],
                       omega=par0[2], 
                       alpha=par0[3],
                       nu=par0[4]))
}

df1_bfgs <- filter(df1, par!="error") %>% mutate(prob=map(list(par,value=finfl_new2),myp))

I go the following error:

Error: Problem with mutate() column prob. i prob = map(list(par, value = finfl_new2), myp). x argument "value" is missing, with no default Run rlang::last_error() to see where the error occurred.

I appreciate all your help!

0

There are 0 answers