We are going to analize the data set qpdat, which is included in quickpsy. It has a tidy form: each column corresponds to a variable and each row to an observation.

To fit the psychometric functions (the default shape is the cumulative normal function), we use the main function of quickpsy, which has the name of the package. We introduce the data, the name of the explanatory variable, the name of the response variable and the name of the grouping variables.

library(quickpsy)

fit <- quickpsy(qpdat, phase, resp, grouping = c("participant", "cond")) 
#> Using only 100 bootstrap samples. Use the B argument, to modify it.

quickpsy creates a object of class quickpsy with a list of data frames with all the results. We can use names to see the names of the output data frames

names(fit)
#>  [1] "averages"            "limits"              "psych_fun"          
#>  [4] "nll_fun"             "nll_fun_saturated"   "parini"             
#>  [7] "par"                 "ypred"               "x_seq"              
#> [10] "curves"              "logliks"             "loglikssaturated"   
#> [13] "aic"                 "deviance"            "thresholds"         
#> [16] "avbootstrap"         "avbootstrap"         "parbootstrap"       
#> [19] "ypredbootstrap"      "curvesbootstrap"     "thresholdsbootstrap"
#> [22] "x_str"               "log"                 "guess"              
#> [25] "lapses"              "grouping"

To obtain the thresholds, for example, we can do

fit$thresholds
#> # A tibble: 6 x 6
#> # Groups:   participant, cond [6]
#>   participant  cond   prob   thre threinf thresup
#>   <chr>        <chr> <dbl>  <dbl>   <dbl>   <dbl>
#> 1 Participant1 cond1   0.5  -70.2   -85.1   -59.2
#> 2 Participant1 cond2   0.5 -121.   -133.   -111. 
#> 3 Participant2 cond1   0.5  -92.5  -109.    -77.0
#> 4 Participant2 cond2   0.5 -130.   -146.   -112. 
#> 5 Participant3 cond1   0.5  -81.4   -98.9   -65.4
#> 6 Participant3 cond2   0.5 -125.   -144.   -103.

and to obtain the parameters

fit$par
#> # A tibble: 12 x 6
#> # Groups:   participant, cond [6]
#>    participant  cond  parn     par parinf parsup
#>    <chr>        <chr> <chr>  <dbl>  <dbl>  <dbl>
#>  1 Participant1 cond1 p1     -70.2  -85.1  -59.2
#>  2 Participant1 cond1 p2      78.5   63.1   92.2
#>  3 Participant1 cond2 p1    -121.  -133.  -111. 
#>  4 Participant1 cond2 p2      61.7   48.5   72.9
#>  5 Participant2 cond1 p1     -92.5 -109.   -77.0
#>  6 Participant2 cond1 p2      67.2   45.8   84.4
#>  7 Participant2 cond2 p1    -130.  -146.  -112. 
#>  8 Participant2 cond2 p2      66.1   50.1   85.1
#>  9 Participant3 cond1 p1     -81.4  -98.9  -65.4
#> 10 Participant3 cond1 p2      69.2   53.1   86.2
#> 11 Participant3 cond2 p1    -125.  -144.  -103. 
#> 12 Participant3 cond2 p2      78.9   59.0  102.

We can use plot to plot the psychometric curves

plot(fit)

or if we want to used different colors for the different conditions

plot(fit, color = cond)

The output plot is a ggplot and we can modify it accordingly. For example

library(ggplot2)

plot(fit, color = cond) +
  labs(y = "Proportion") +
  theme_minimal()

Of course, we can also use the output data frames to create the plot ourselves

 ggplot() +
  facet_wrap(~ participant) +
  geom_line(data = fit$curvesbootstrap, 
            aes(x = x, y = y, color = cond, 
                group=paste(sample, cond)), lwd = .2, alpha = .4) +
  geom_line(data = fit$curves, aes(x = x, y = y, group = cond)) +
  geom_point(data = fit$averages, aes(x = phase, y = prob), size = 2) +
  geom_point(data = fit$averages, aes(x = phase, y = prob, color = cond))