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

View source: R/glm.lambda.R

glm.lambdaR Documentation

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, ...)

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

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.

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.

Note

If the minimum occurs outside the interval examined, an error might occur. In any case, re-running the function with a new range of lambda that includes the minimum should work. if the plotted profile indicates that the fitted quadratic does not describe well the profile at the minimum, refitting with a more restricted range of lambda is recommended.

Author(s)

Ken Knoblauch

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

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)


psyphy documentation built on Aug. 19, 2023, 5:07 p.m.