locglmfit: Local polynomial estimator of a psychometric function

View source: R/locglmfit.R

locglmfitR Documentation

Local polynomial estimator of a psychometric function

Description

Local polynomial estimator for the psychometric function and eta function (psychometric function transformed by link) for binomial data; also returns the hat matrix H.

Usage

locglmfit( xfit, r, m, x, h, returnH = FALSE, link = "logit",
               guessing = 0, lapsing = 0, K = 2, p = 1,
               ker = "dnorm", maxiter = 50, tol = 1e-6 )

Arguments

xfit

points at which to calculate the estimate pfit

r

number of successes at points x

m

number of trials at points x

x

stimulus levels

h

bandwidth(s)

returnH

(optional) logical, if TRUE then hat matrix is calculated; default is FALSE

link

(optional) name of the link function; default is 'logit'

guessing

(optional) guessing rate; default is 0

lapsing

(optional) lapsing rate; default is 0

K

(optional) power parameter for Weibull and reverse Weibull link; default is 2

p

(optional) degree of the polynomial; default is 1

ker

(optional) kernel function for weights; default is 'dnorm'

maxiter

(optional) maximum number of iterations in Fisher scoring; default is 50

tol

(optional) tolerance level at which to stop Fisher scoring; default is 1e-6

Value

⁠pfit ⁠ value of the local polynomial estimate at points xfit

⁠etafit ⁠ estimate of eta (link of pfit)

⁠H ⁠ hat matrix (OPTIONAL)

Examples

data("Miranda_Henson")
x = Miranda_Henson$x
r = Miranda_Henson$r
m = Miranda_Henson$m
numxfit <- 199; # Number of new points to be generated minus 1
xfit <- (max(x)-min(x)) * (0:numxfit) / numxfit + min(x)
# Find a plug-in bandwidth
bwd <- bandwidth_plugin( r, m, x)
pfit <- locglmfit( xfit, r, m, x, bwd )$pfit
# Plot the fitted curve
plot( x, r / m, xlim = c( 0.1, 1.302 ), ylim = c( 0.0165, 0.965 ), type = "p", pch="*" )
lines(xfit, pfit )


modelfree documentation built on May 31, 2023, 7:17 p.m.