Learn R Programming

psyphy (version 0.3)

glm.lambda: mafc Probit Fit to Psychometric Function Profiled on Upper Asymptote

Description

A wrapper for glm in which the deviance for the model with binomial family and link probit.lambda is profiled as a function of lambda, the upper asymptote of the psychometric function.

Usage

glm.lambda(formula, data, NumAlt = 2, lambda = seq(0, 0.1, len = 40), 
	plot.it = FALSE, ...)

Value

returns an object of class ‘lambda’ which inherits from classes ‘glm’ and ‘lm’. It only differs from an object of class ‘glm’ in including two additional components, lambda, giving the estimated minimum of the profile by fitting a quadratic to the profile and a data frame containing the profiled deviance values for each value of lambda tested. The degrees of freedom are reduced by 1 to take into account the estimation of lambda.

Arguments

formula

a symbolic description of the model to be fit

data

an optional data frame, list or environment (or object coercible by as.data.frame to a data frame) containing the variables in the model. If not found in data, the variables are taken from environment(formula), typically the environment from which glm is called.

NumAlt

the number of alternatives, m in the mafc experiment from which the data arise

lambda

a sequence of values to profile for the upper asymptote of the psychometric function

plot.it

logical indicating whether to plot the profile of the deviances as a function of lambda

...

further arguments passed to glm

Author

Ken Knoblauch

Details

The psychometric function fit to the data is described by $$P(x) = 1/m + (1 - 1/m - \lambda) \Phi(x)$$ where \(m\) is the number of alternatives and the lower asymptote, \(1 - \lambda\) is the upper asymptote and \(\Phi\) is the cumulative normal function.

References

Wichmann, F. A. and Hill, N. J. (2001) The psychometric function: I.Fitting, sampling, and goodness of fit. Percept Psychophys., 63(8), 1293--1313.

Yssaad-Fesselier, R. and Knoblauch, K. (2006) Modeling psychometric functions in R. Behav Res Methods., 38(1), 28--41. (for examples with gnlr).

See Also

mafc, glm, probit.lambda, family

Examples

Run this code
b <- 3.5
g <- 1/3
d <- 0.025
a <- 0.04
p <- c(a, b, g, d)
num.tr <- 160
cnt <- 10^seq(-2, -1, length = 6) # contrast levels

#simulated Weibull-Quick observer responses
set.seed(12161952)
truep <- g + (1 - g - d) * pweibull(cnt, b, a)
ny <- rbinom(length(cnt), num.tr, truep)
nn <- num.tr - ny
phat <- ny/(ny + nn)
resp.mat <- matrix(c(ny, nn), ncol = 2)

## First with upper asymptote at 1
dd.glm <- glm(resp.mat ~ cnt, family = binomial(mafc.probit(3)))
summary(dd.glm)
dd.lam <- glm.lambda(resp.mat ~ cnt, NumAlt = 3, lambda = seq(0, 0.03, 
	len = 100), plot.it = TRUE)
summary(dd.lam)
## can refine interval, but doesn't change result much
dd.lam2 <- glm.lambda(resp.mat ~ cnt, NumAlt = 3, 
	lambda = seq(dd.lam$lambda/sqrt(2), dd.lam$lambda*sqrt(2), 
	len = 100), plot.it = TRUE)
summary(dd.lam2)
## Compare fits w/ and w/out lambda
anova(dd.glm, dd.lam2, test = "Chisq")

plot(cnt, phat, log = "x", cex = 1.5, ylim = c(0, 1))
pcnt <- seq(0.01, 0.1, len = 100)
lines(pcnt, predict(dd.glm, data.frame(cnt = pcnt),
                    type = "response"), lwd = 2)
lines(pcnt, predict(dd.lam, data.frame(cnt = pcnt),
                    type = "response"), lwd = 2, lty = 2)

Run the code above in your browser using DataLab