Type: | Package |
Title: | Fits Psychometric Functions for Multiple Groups |
Version: | 0.1.5.1 |
URL: | http://dlinares.org/quickpsy.html |
Description: | Quickly fits and plots psychometric functions (normal, logistic, Weibull or any or any function defined by the user) for multiple groups. |
Depends: | R (≥ 3.1.2), DEoptim, dplyr, ggplot2 |
Imports: | MPDiR |
Encoding: | UTF-8 |
License: | MIT + file LICENSE |
LazyData: | true |
RoxygenNote: | 6.0.1 |
NeedsCompilation: | no |
Packaged: | 2019-10-02 15:47:49 UTC; hornik |
Author: | Linares Daniel [aut, cre], L<U+00F3>pez-Moliner Joan [aut] |
Maintainer: | Linares Daniel <danilinares@gmail.com> |
Repository: | CRAN |
Date/Publication: | 2019-10-02 15:54:02 UTC |
Calculates the AICs
Description
aic
calculates the AICs.
Usage
aic(qp)
Arguments
qp |
output from quickpsy |
Creates bootstrap samples
Description
avbootstrap
creates bootstrap samples
Usage
avbootstrap(qp, bootstrap = "parametric", B = 100)
Arguments
qp |
output from quickpsy |
bootstrap |
|
B |
number of bootstrap samples (default is 100 ONLY). |
Creates the full negative log-likelihood function
create_full_nll
Creates the full negative log-likelihood function
Description
Creates the full negative log-likelihood function
create_full_nll
Creates the full negative log-likelihood function
Usage
create_full_nll(d, x, k, n, psyfunguesslapses)
Creates the negative log-likelihood function
create_nll
Creates the negative log-likelihood function
Description
Creates the negative log-likelihood function
create_nll
Creates the negative log-likelihood function
Usage
create_nll(d, x, k, n, psyfunguesslapses)
Creates the full saturated negative log-likelihood function
create_nll
Creates the full saturated negative log-likelihood function
Description
Creates the full saturated negative log-likelihood function
create_nll
Creates the full saturated negative log-likelihood function
Usage
create_nllsaturated(d, x, k, n, psyfunguesslapses)
Creates the psychometric function
create_psy_fun
creates the psychometric function
Description
Creates the psychometric function
create_psy_fun
creates the psychometric function
Usage
create_psy_fun(psy_fun, guess, lapses)
Cumulative normal function
Description
Cumulative normal function.
Usage
cum_normal_fun(x, p)
Arguments
x |
Vector of values of the explanatory variable. |
p |
Vector of parameters |
Value
Probability at each x
.
See Also
Examples
xseq <- seq(0,4,.01)
yseq <- cum_normal_fun(xseq, c(2, .5))
curve <- data.frame(x = xseq, y = yseq)
ggplot(curve, aes(x = x, y = y)) + geom_line()
Creates the bootstrap curves
curvesbootstrap
creates the bootstrap curves
Description
Creates the bootstrap curves
curvesbootstrap
creates the bootstrap curves
Usage
curvesbootstrap(qp, xmin = NULL, xmax = NULL, log = F)
Calculates the deviances
Description
deviance
calculates the deviances.
Usage
deviance(qp)
Arguments
qp |
output from quickpsy |
Examples
library(MPDiR) # contains the Vernier data
fit <- quickpsy(Vernier, Phaseshift, NumUpward, N,
grouping = .(Direction, WaveForm, TempFreq), B = 20)
deviance(fit)
Calculates the bootsrap deviances
Description
deviance
calculates the bootstrap deviances.
Usage
devianceboot(qp)
Arguments
qp |
output from quickpsy |
Examples
library(MPDiR) # contains the Vernier data
fit <- quickpsy(Vernier, Phaseshift, NumUpward, N,
grouping = .(Direction, WaveForm, TempFreq), B = 20)
devianceboot(fit)
Calculates the probability of obtaining the deviance value or larger if the parametric model holds
deviancep
calculates the probability of obtaining the deviance value or larger if the parametric model holds.
Description
Calculates the probability of obtaining the deviance value or larger if the parametric model holds
deviancep
calculates the probability of obtaining the deviance value or larger if the parametric model holds.
Usage
deviancep(qp)
Fits the curve
fitpsy
fits de curve
Description
Fits the curve
fitpsy
fits de curve
Usage
fitpsy(d, x, k, n, random, within, between, grouping, xmin, xmax, log, funname,
parini, pariniset, guess, lapses, optimization)
Predefined functions
Description
getfunctions
lists the predefined functions in quickpsy
.
Usage
get_functions()
See Also
cum_normal_fun
,
logistic_fun
,
weibull_fun
Inverse cumulative normal function
Description
Inverse cumulative normal function
Usage
inv_cum_normal_fun(prob, p)
Arguments
prob |
Vector of probabilities. |
p |
Vector of parameters |
Value
x
at each probability.
#' @seealso cum_normal_fun
Examples
yseq <- seq(0, 1, .01)
xseq <- inv_cum_normal_fun(yseq, c(2, .5))
curve <- data.frame(x = xseq, y = yseq)
ggplot(curve, aes(x = x, y = y)) + geom_line()
Inverse logistic function
Description
Inverse logistic function
Usage
inv_logistic_fun(q, p)
Arguments
q |
Vector of probabilities. |
p |
Vector of parameters |
Value
x
at each probability.
See Also
Examples
yseq <- seq(0, 1, .01)
xseq <- inv_logistic_fun(yseq, c(2, 4))
curve <- data.frame(x = xseq, y = yseq)
ggplot(curve, aes(x = x, y = y)) + geom_line()
Inverse Weibull function
Description
Inverse Weibull function
Usage
inv_weibull_fun(q, p)
Arguments
q |
Vector of probabilities. |
p |
Vector of parameters p = c(alpha, beta). |
Value
x
at each probability.
See Also
Examples
yseq <- seq(0, 1, .01)
xseq <- inv_weibull_fun(yseq, c(2, 4))
curve <- data.frame(x = xseq, y = yseq)
ggplot(curve, aes(x = x, y = y)) + geom_line()
Creates the limits
limits
creates the limits
Description
Creates the limits
limits
creates the limits
Usage
limits(d, x, xmin, xmax, log)
Logistic function
Description
Logistic function of the form (1 + exp(-\beta * (x - \alpha)))^(-1)
Usage
logistic_fun(x, p)
Arguments
x |
Vector of values of the explanatory variable. |
p |
Vector of parameters |
Value
Probability at each x
.
See Also
Examples
xseq <- seq(0, 4, .01)
yseq <- logistic_fun(xseq, c(2, 4))
curve <- data.frame(x = xseq, y = yseq)
ggplot(curve, aes(x = x, y = y)) + geom_line()
Calculates the loglikelihoods
logliks
calculates the loglikelihoods.
Description
Calculates the loglikelihoods
logliks
calculates the loglikelihoods.
Usage
logliks(qp)
Arguments
qp |
output from quickpsy |
Calculates the bootstrap loglikelihoods
Description
logliksboot
calculates the bootstraploglikelihoods.
Usage
logliksboot(qp)
Arguments
qp |
output from quickpsy |
Examples
library(MPDiR) # contains the Vernier data
fit <- quickpsy(Vernier, Phaseshift, NumUpward, N,
grouping = .(Direction, WaveForm, TempFreq), B = 20)
logliksboot(fit)
Calculates the bootstrap loglikelihoods for the saturated model
Description
logliks
calculates the bootstrap loglikelihoods for the saturated model.
Usage
logliksbootsaturated(qp)
Arguments
qp |
output from quickpsy |
Examples
library(MPDiR) # contains the Vernier data
fit <- quickpsy(Vernier, Phaseshift, NumUpward, N,
grouping = .(Direction, WaveForm, TempFreq), B = 20)
logliksbootsaturated(fit)
Calculates the loglikelihoods of the saturated model
Description
loglikssaturated
calculates the loglikelihoods of the saturated model.
Usage
loglikssaturated(qp)
Arguments
qp |
output from quickpsy |
Examples
library(MPDiR) # contains the Vernier data
fit <- quickpsy(Vernier, Phaseshift, NumUpward, N,
grouping = .(Direction, WaveForm, TempFreq), B = 20)
loglikssaturated(fit)
Calculates the AIC for one condition
one_aic
creates the deviance for one condition
one_deviance
Description
Calculates the AIC for one condition
one_aic
creates the deviance for one condition
one_deviance
Usage
one_aic(d, groups, par)
Creates the curve for one condition
one_curve
Creates the curve for one condition
Description
Creates the curve for one condition
one_curve
Creates the curve for one condition
Usage
one_curve(d, xmin, xmax, log, groups, limits, psyfunguesslapses)
Creates the deviance for one condition
one_deviance
creates the deviance for one condition
one_deviance
Description
Creates the deviance for one condition
one_deviance
creates the deviance for one condition
one_deviance
Usage
one_deviance(d, groups, loglikssaturated)
Calculates the probability of obtaining the deviance value or larger if the
parametric model holds for one condition
one_deviancep
calculates the probability of obtaining the deviance value
or larger if the parametric model holds for one condition
Description
Calculates the probability of obtaining the deviance value or larger if the
parametric model holds for one condition
one_deviancep
calculates the probability of obtaining the deviance value
or larger if the parametric model holds for one condition
Usage
one_deviancep(d, groups, deviance)
Creates the limits for one condition
one_limit
creates the limits for one condition
Description
Creates the limits for one condition
one_limit
creates the limits for one condition
Usage
one_limit(d, x, xmin, xmax, log)
Creates the loglik for one condition
one_loglik
creates the loglik for one condition
one_loglik
Description
Creates the loglik for one condition
one_loglik
creates the loglik for one condition
one_loglik
Usage
one_loglik(d, x, k, n, psyfunguesslapses, groups, par)
Creates the loglik for the saturated model for one condition
one_logliksaturated
creates the loglik for the saturated model for one condition
one_loglik
Description
Creates the loglik for the saturated model for one condition
one_logliksaturated
creates the loglik for the saturated model for one condition
one_loglik
Usage
one_logliksaturated(d, x, k, n, psyfunguesslapses, groups, par)
Obtains the parameters for one condition
one_parameters
obtains the parameters for one condition
Description
Obtains the parameters for one condition
one_parameters
obtains the parameters for one condition
Usage
one_parameters(d, x, k, n, psyfunguesslapses, funname, parini, pariniset, guess,
lapses, optimization, groups)
Calculates the confidence intervals for one condition
one_parci
calculates the confidence intervals for one condition
Description
Calculates the confidence intervals for one condition
one_parci
calculates the confidence intervals for one condition
Usage
one_parci(d, ci)
Pair comparisons of the parameters using bootstrap (for each parameter)
one_parcomparisons
Calculates the bootstrap confidence intervals for the
difference in the parameters for two groups for all possible pairs
of groups (for each parameter)
Description
Pair comparisons of the parameters using bootstrap (for each parameter)
one_parcomparisons
Calculates the bootstrap confidence intervals for the
difference in the parameters for two groups for all possible pairs
of groups (for each parameter)
Usage
one_parcomparisons(d, para, groups, ci)
Calculates the sum of squared errors of prediction
one_sse
calculates the sum of squared errors of prediction for one
condition
Description
Calculates the sum of squared errors of prediction
one_sse
calculates the sum of squared errors of prediction for one
condition
Usage
one_sse(d, groups, averages)
Calculates the threshold for one condition
one_threshold
calculates the threshold for one condition
one_threshold
Description
Calculates the threshold for one condition
one_threshold
calculates the threshold for one condition
one_threshold
Usage
one_threshold(d, prob, log, groups, funname, guess, lapses, curves)
Pair comparisons of the thresholds using bootstrap
one_thresholdcomparisons
Calculates the bootstrap confidence intervals for the
difference in the thresholds for two groups for all possible pairs
of groups
Description
Pair comparisons of the thresholds using bootstrap
one_thresholdcomparisons
Calculates the bootstrap confidence intervals for the
difference in the thresholds for two groups for all possible pairs
of groups
Usage
one_thresholdcomparisons(d, thresholds, groups, ci)
Calculates the confidence intervals for the threshold of one condition
one_thresholdsci
calculates the confidence intervals for the threshold
of one condition
Description
Calculates the confidence intervals for the threshold of one condition
one_thresholdsci
calculates the confidence intervals for the threshold
of one condition
Usage
one_thresholdsci(d, ci, method)
Calculate the predictions of the response variable for one condition
one_ypred
calculate the predictions of the response variable for one
condition
Description
Calculate the predictions of the response variable for one condition
one_ypred
calculate the predictions of the response variable for one
condition
Usage
one_ypred(d, log, groups, averages, x, psyfunguesslapses)
Calculates the parameters
parameters
calculates the parameters
Description
Calculates the parameters
parameters
calculates the parameters
Usage
parameters(d, x, k, n, psyfunguesslapses, funname, parini, pariniset, guess,
lapses, optimization, groups)
Creates bootstrap samples of the parameters
Description
parbootstrap
creates bootstrap samples of the parameters.
Usage
parbootstrap(qp)
Arguments
qp |
output from quickpsy |
Calculates the confidence intervals for the parameters
parci
calculates the confidence intervals for the parameters
Description
Calculates the confidence intervals for the parameters
parci
calculates the confidence intervals for the parameters
Usage
parci(qp, ci = 0.95)
Pair comparisons of the parameters using bootstrap
parcomparisons
Calculates the bootstrap confidence intervals for the
difference in the parameters for two groups for all possible pairs
of groups
Description
Pair comparisons of the parameters using bootstrap
parcomparisons
Calculates the bootstrap confidence intervals for the
difference in the parameters for two groups for all possible pairs
of groups
Usage
parcomparisons(qp, ci = 0.95)
Calculates some initial parameters
parini
calculates some initial parameters
Description
Calculates some initial parameters
parini
calculates some initial parameters
Usage
parini(d, x, k, n, guess, lapses, psyfun)
Creates one bootstrap sample
one_bootstrapav
creates one bootstrap sample
Description
Creates one bootstrap sample
one_bootstrapav
creates one bootstrap sample
Usage
parn
Format
An object of class character
of length 1.
Plot the curves
Description
plotcurves
plot the curves.
Usage
plotcurves(qp, panel = NULL, xpanel = NULL, ypanel = NULL, color = NULL,
averages = T, curves = T, thresholds = T, ci = T)
Arguments
qp |
output from quickpsy |
panel |
Name of the variable to be split in panels. |
xpanel |
Name of the variable to be split in horizontal panels. |
ypanel |
Name of the variable to be split in vertical panels. |
color |
Name of the variable codded by color. |
averages |
If |
curves |
If |
thresholds |
If |
ci |
If |
See Also
Examples
library(MPDiR) # contains the Vernier data
fit <- quickpsy(Vernier, Phaseshift, NumUpward, N,
grouping = .(Direction, WaveForm, TempFreq), B = 5)
plotcurves(fit)
plotcurves(fit, xpanel = Direction)
plotcurves(fit, xpanel = Direction, color = WaveForm, ci = FALSE)
Plot the curves
Description
plotcurves_
is the standard evaluation SE function associated
to the non-standard evaluation NSE function plotcurves
.
SE functions can be more easily called from other functions.
In SE functions, you need to quote the names of the variables.
Usage
plotcurves_(qp, panel = NULL, xpanel = NULL, ypanel = NULL,
color = NULL, averages = TRUE, curves = TRUE, thresholds = TRUE,
ci = TRUE)
Arguments
qp |
output from quickpsy |
panel |
Name of the variable to be split in panels. |
xpanel |
Name of the variable to be split in horizontal panels. |
ypanel |
Name of the variable to be split in vertical panels. |
color |
Name of the variable codded by color. |
averages |
If |
curves |
If |
thresholds |
If |
ci |
If |
See Also
Examples
library(MPDiR) # contains the Vernier data
data(Vernier) # ?Venier for the reference
fit <- quickpsy(Vernier, Phaseshift, NumUpward, N,
grouping = .(Direction, WaveForm, TempFreq), B = 5)
plotcurves_(fit, xpanel = 'Direction')
plotcurves_(fit, color = 'Direction')
plotcurves_(fit, xpanel = 'Direction', color = 'WaveForm', ci = FALSE)
Plot the values of the parameters
Description
plotpar
plot the values of the parameters.
Usage
plotpar(qp, x = NULL, panel = NULL, xpanel = NULL, ypanel = NULL,
color = NULL, geom = "bar", ci = T)
Arguments
qp |
output from quickpsy. |
x |
Name of the variable to displayed in the x-axis. |
panel |
Name of the variable to be split in panels. |
xpanel |
Name of the variable to be split in horizontal panels. |
ypanel |
Name of the variable to be split in vertical panels. |
color |
Name of the variable codded by color. |
geom |
If |
ci |
If |
See Also
Examples
library(MPDiR) # contains the Vernier data
fit <- quickpsy(Vernier, Phaseshift, NumUpward, N,
grouping = .(Direction, WaveForm, TempFreq), B = 10)
plotpar(fit)
plotpar(fit, x = WaveForm)
plotpar(fit, xpanel = Direction)
plotpar(fit, color = Direction)
plotpar(fit, color = Direction, ypanel = WaveForm, geom = 'point')
Plot the values of the parameters
Description
plotpar_
is the standard evaluation SE function associated
to the non-standard evaluation NSE function plotpar
.
SE functions can be more easily called from other functions.
In SE functions, you need to quote the names of the variables.
Usage
plotpar_(qp, x = NULL, panel = NULL, xpanel = NULL, ypanel = NULL,
color = NULL, geom = "bar", ci = T)
Arguments
qp |
output from quickpsy. |
x |
Name of the variable to displayed in the x-axis. |
panel |
Name of the variable to be split in panels. |
xpanel |
Name of the variable to be split in horizontal panels. |
ypanel |
Name of the variable to be split in vertical panels. |
color |
Name of the variable codded by color. |
geom |
If |
ci |
If |
See Also
Examples
library(MPDiR) # contains the Vernier data
fit <- quickpsy(Vernier, Phaseshift, NumUpward, N,
grouping = .(Direction, WaveForm, TempFreq), bootstrap = 'none')
plotpar_(fit, x = 'WaveForm')
plotpar_(fit, xpanel = 'Direction')
plotpar_(fit, color = 'Direction')
plotpar_(fit, color = 'Direction', ypanel = 'WaveForm', geom = 'point')
Plot the thresholds
Description
plotthresholds
plot the thresholds.
Usage
plotthresholds(qp, x = NULL, panel = NULL, xpanel = NULL, ypanel = NULL,
color = NULL, geom = "bar", ci = T, sizeerrorbar = 0.5)
Arguments
qp |
output from quickpsy. |
x |
Name of the variable to displayed in the x-axis. |
panel |
Name of the variable to be split in panels. |
xpanel |
Name of the variable to be split in horizontal panels. |
ypanel |
Name of the variable to be split in vertical panels. |
color |
Name of the variable codded by color. |
geom |
If |
ci |
If |
sizeerrorbar |
Line width of the error bars.
If |
See Also
Examples
library(MPDiR) # contains the Vernier data
fit <- quickpsy(Vernier, Phaseshift, NumUpward, N,
grouping = .(Direction, WaveForm, TempFreq), B = 10)
plotthresholds(fit)
plotthresholds(fit, x = WaveForm)
plotthresholds(fit, xpanel = Direction)
plotthresholds(fit, color = Direction, ypanel = WaveForm, geom = 'point')
Plot the thresholds
Description
plotthresholds_
is the standard evaluation SE function associated
to the non-standard evaluation NSE function plotthresholds
.
SE functions can be more easily called from other functions.
In SE functions, you need to quote the names of the variables.
Usage
plotthresholds_(qp, x = NULL, panel = NULL, xpanel = NULL,
ypanel = NULL, color = NULL, geom = "bar", ci = T,
sizeerrorbar = 0.5)
Arguments
qp |
output from quickpsy. |
x |
Name of the variable to displayed in the x-axis. |
panel |
Name of the variable to be split in panels. |
xpanel |
Name of the variable to be split in horizontal panels. |
ypanel |
Name of the variable to be split in vertical panels. |
color |
Name of the variable codded by color. |
geom |
If |
ci |
If |
sizeerrorbar |
Line width of the error bars.
If |
See Also
Examples
library(MPDiR) # contains the Vernier data
fit <- quickpsy(Vernier, Phaseshift, NumUpward, N,
grouping = .(Direction, WaveForm, TempFreq), B = 10)
plotthresholds_(fit, x = 'WaveForm')
plotthresholds_(fit, xpanel = 'Direction')
plotthresholds_(fit, color = 'Direction')
plotthresholds_(fit, color = 'Direction', ypanel = 'WaveForm', geom = 'point')
Data set for demonstration
Description
It is part of the data associated with the paper 'Motion signal and the perceived positions of moving objects'.
Usage
qpdat
Format
An object of class grouped_df
(inherits from tbl_df
, tbl
, data.frame
) with 6240 rows and 8 columns.
References
Linares, D., López-Moliner, J., & Johnston, A. (2007). Motion signal and the perceived positions of moving objects. Journal of Vision, 7(7), 1.
Fits psychometric functions
Description
quickpsy
fits, by direct maximization of the likelihood
(Prins and Kingdom, 2010; Knoblauch and Maloney, 2012),
psychometric functions of the form
\psi(x) = \gamma + (1 - \gamma - \lambda) * fun(x)
where \gamma
is the guess rate, \lambda
is the lapse rate and
fun
is a sigmoidal-shape function with asymptotes at 0 and 1.
Usage
quickpsy(d, x = x, k = k, n = n, grouping, random, within, between,
xmin = NULL, xmax = NULL, log = FALSE, fun = cum_normal_fun,
parini = NULL, guess = 0, lapses = 0, prob = NULL, thresholds = T,
bootstrap = "parametric", B = 100, ci = 0.95, optimization = "optim")
Arguments
d |
Data frame with the results of a Yes-No experiment to fit. It should have a tidy form in which each column corresponds to a variable and each row is an observation. |
x |
Name of the explanatory variable. |
k |
Name of the response variable. The response variable could be the number of trials in which a yes-type response was given or a vector of 0s (or -1s; no-type response) and 1s (yes-type response) indicating the response on each trial. |
n |
Only necessary if |
grouping |
Name of the grouping variables. It should be specified as
|
random |
Name of the random variable. It should be specified as
|
within |
Name of the within variable. It should be specified as
|
between |
Name of the between variable. It should be specified as
|
xmin |
Minimum value of the explanatory variable for which the curves should be calculated (the default is the minimum value of the explanatory variable). |
xmax |
Maximum value of the explanatory variable for which the curves should be calculated (the default is the maximum value of the explanatory variable). |
log |
If |
fun |
Name of the shape of the curve to fit. It could be a predefined
shape ( |
parini |
Initial parameters. quickpsy calculates default
initial parameters using probit analysis, but it is also possible to
specify a vector of initial parameters or a list of the form
|
guess |
Value indicating the guess rate |
lapses |
Value indicating the lapse rate |
prob |
Probability to calculate the threshold (default is
|
thresholds |
If |
bootstrap |
|
B |
number of bootstrap samples (default is 100 ONLY). |
ci |
Confidence intervals level based on percentiles (default is .95). |
optimization |
Method used for optimization. The default is 'optim' which uses
the |
Value
A list containing the following components:
-
x, k, n
-
groups
The grouping variables. -
funname
String with the name of the shape of the curve. -
psyfunguesslapses
Curve including guess and lapses. -
limits
Limits of the curves. -
parini
Initial parameters. -
optimization
Method to optimize. -
pariniset
FALSE
if initial parameters are not given. -
ypred
Predicted probabilities at the values of the explanatory variable. -
curves
Curves. -
par
Fitted parameters and its confidence intervals. -
curvesbootstrap
Bootstrap curves. -
thresholds
Thresholds. -
thresholdsci
Confidence intervals for the thresholds. -
logliks
Log-likelihoods of the model. -
loglikssaturated
Log-likelihoods of the saturated model. -
deviance
Deviance of the model and the p-value calculated by bootstraping. -
aic
AIC of the model defined as- 2 * loglik + 2 *k
where k is the number of parameters of the model.
References
Burnham, K. P., & Anderson, D. R. (2003). Model selection and multimodel inference: a practical information-theoretic approach. Springer Science & Business Media.
Knoblauch, K., & Maloney, L. T. (2012). Modeling Psychophysical Data in R. New York: Springer.
Prins, N., & Kingdom, F. A. A. (2016). Psychophysics: a practical introduction. London: Academic Press.
See Also
Examples
# make sure that all the requires packages are installed
# and loaded; instructions at https://github.com/danilinares/quickpsy
library(MPDiR) # contains the Vernier data; use ?Vernier for the reference
fit <- quickpsy(Vernier, Phaseshift, NumUpward, N,
grouping = .(Direction, WaveForm, TempFreq), B = 10)
plotcurves(fit)
plotpar(fit)
plotthresholds(fit, geom = 'point')
Fits psychometric functions
Description
quickpsy_
is the standard evaluation SE function associated
to the non-standard evaluation NSE function quickpsy
.
SE functions can be more easily called from other functions.
In SE functions, you need to quote the names of the variables.
Usage
quickpsy_(d, x = "x", k = "k", n = "n", grouping, random, within, between,
xmin = NULL, xmax = NULL, log = FALSE, fun = "cum_normal_fun",
parini = NULL, guess = 0, lapses = 0, prob = NULL, thresholds = T,
bootstrap = "parametric", B = 100, ci = 0.95, optimization = "optim")
Arguments
d |
Data frame with the results of a Yes-No experiment to fit. It should have a tidy form in which each column corresponds to a variable and each row is an observation. |
x |
Name of the explanatory variable. |
k |
Name of the response variable. The response variable could be the number of trials in which a yes-type response was given or a vector of 0s (or -1s; no-type response) and 1s (yes-type response) indicating the response on each trial. |
n |
Only necessary if |
grouping |
Name of the grouping variables. It should be specified as
|
random |
Name of the random variable. It should be specified as
|
within |
Name of the within variable. It should be specified as
|
between |
Name of the between variable. It should be specified as
|
xmin |
Minimum value of the explanatory variable for which the curves should be calculated (the default is the minimum value of the explanatory variable). |
xmax |
Maximum value of the explanatory variable for which the curves should be calculated (the default is the maximum value of the explanatory variable). |
log |
If |
fun |
Name of the shape of the curve to fit. It could be a predefined
shape ( |
parini |
Initial parameters. quickpsy calculates default
initial parameters using probit analysis, but it is also possible to
specify a vector of initial parameters or a list of the form
|
guess |
Value indicating the guess rate |
lapses |
Value indicating the lapse rate |
prob |
Probability to calculate the threshold (default is
|
thresholds |
If |
bootstrap |
|
B |
number of bootstrap samples (default is 100 ONLY). |
ci |
Confidence intervals level based on percentiles (default is .95). |
optimization |
Method used for optimizization. The default is 'optim' which uses
the |
See Also
Reads several files
Description
quickreadfiles
builts a data frame from several txt files. It
assumes that in each file, the first row has the names of the variables.
Usage
quickreadfiles(path = getwd(), extension = "txt", ...)
Arguments
path |
Path of the file (default is the working directory). |
extension |
Specify whether the file extension is 'txt' or 'csv'. |
... |
arguments of the form name_var = c('value1', 'value2',..). A new column with variable name name_var is addes to the data frame. |
Examples
# download the 3 files in
# https://github.com/danilinares/quickpsy/tree/master/inst/extdata/example1
# and add them to your working directory
# dat <- quickreadfiles(subject = c('aa', 'bb', 'cc'), session = c('1', '2'))
# fit <- quickpsy(dat, phase, resp, grouping=.(subject), lapses = T, guess = T)
# plotcurves(fit)
Sum of squared errors of prediction
Description
ypred
calculates the sum of squared errors of prediction
Usage
sse(qp)
Arguments
qp |
output from quickpsy |
Plot the parameters and its confidence intervals
summary
Plot the parameters and its confidence intervals
Description
Plot the parameters and its confidence intervals
summary
Plot the parameters and its confidence intervals
Usage
## S3 method for class 'quickpsy'
summary(object, ...)
Arguments
object |
An object for which a summary is desired. |
... |
Additional arguments affecting the summary produced. |
Pair comparisons of the parameters using bootstrap
thresholdcomparisons
Calculates the bootstrap confidence intervals for the
difference in the parameters for two groups for all possible pairs
of groups
Description
Pair comparisons of the parameters using bootstrap
thresholdcomparisons
Calculates the bootstrap confidence intervals for the
difference in the parameters for two groups for all possible pairs
of groups
Usage
thresholdcomparisons(qp, ci = 0.95)
Calculates the thresholds
Description
Calculates the thresholds
Usage
thresholds(qp, prob = NULL, log = FALSE)
Arguments
qp |
output from quickpsy |
prob |
Probability to calculate the threshold. |
log |
Use |
Calculates bootstrap thresholds
thresholdsbootstrap
calculates bootstrap thresholds
Description
Calculates bootstrap thresholds
thresholdsbootstrap
calculates bootstrap thresholds
Usage
thresholdsbootstrap(qp, prob = NULL, log = F)
Calculates the confidence intervals for the thresholds
thresholdsci
calculates the confidence intervals for the thresholds
Description
Calculates the confidence intervals for the thresholds
thresholdsci
calculates the confidence intervals for the thresholds
Usage
thresholdsci(qp, ci = 0.95, method = "percent")
Weibull function
Description
Weibull function of the form (1 - exp(-(x/\alpha)^\beta)
Usage
weibull_fun(x, p)
Arguments
x |
Vector of values of the explanatory variable. |
p |
Vector of parameters |
Value
Probability at each x
.
Examples
xseq <- seq(0, 4, .01)
yseq <- weibull_fun(xseq, c(2, 4))
curve <- data.frame(x = xseq, y = yseq)
ggplot(curve, aes(x = x, y = y)) + geom_line()
Predicted probabilities
Description
ypred
calculates the predicted probabilities at the values of the
explanatory variable.
Usage
ypred(qp)
Arguments
qp |
output from quickpsy |
Examples
library(MPDiR) # contains the Vernier data
data(Vernier) # ?Venier for the reference
fit <- quickpsy(Vernier, Phaseshift, NumUpward, N,
grouping = .(Direction, WaveForm, TempFreq), B = 20)
ypred(fit)