discrimR: Replicated Thurstonian Model for discrimination analysis

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/discrimR.R

Description

The model is a synthesis of a mixture and a mixed effect model. The random effect distribution for the cluster term (often individuals) is a point mass for delta = 0 and a continuous distribution for delta > 0.

The function fits the model and computes d-prime for an average subject, 2) the variance among subjects, 3) the "posterior" probability of a subject being a discriminator (with delta > 0), 4) the "posterior" expectation on the random effect (ie. the subject-specific delta) and 5) the probability that a randomly chosen individual is a discriminator (ie. the probability mass at delta = 0 in the random effects distribution)

Warning: This function is preliminary; see the details for further information.

Usage

1
2
3
4
discrimR(formula, data, weights, cluster, start, subset, na.action,
           contrasts = NULL, hess = FALSE, ranef = FALSE, zi = FALSE,
           method = c("duotrio", "probit", "threeAFC", "triangle",
             "twoAFC"), ...)

Arguments

formula

A formula where the lhs is the binomial response. An indicator vector or a matrix with two column; successes and failures like in a call to glm with a binomial family. The rhs should be 1; no other predictors are currently allowed, but extending this is ongoing work.

data

The data.frame in which to look for variables.

weights

Possible weights

cluster

The clustering variable; should be a factor.

start

Optional starting values; recommended in the current implementation

subset

...

na.action

...

contrasts

...

hess

Should the hessian of the parameters be computed?

ranef

Should the random effect estimates be computed?

zi

Should the posterior probabilities of a subject being a discriminator be computed?

method

Should correspond to the actual test applied.

...

Additional arguments to optim. control=list(trace=TRUE, REPORT=1) is recommended, so the reduction in deviance and convergence can be followed.

Details

This function is preliminary and improving it is ongoing work. The computational methods are expected to change completely. This will hopefully facilitate methods for more general rhs-formulae with additional predictors.

Currently no methods or extractor functions have been written, so the user will have to select the relevant elements from the fitted object (see below). Implementation of methods and extractor functions will occur in due course.

Value

A list with the following elements:

fpar

The fixed effect parameter, ie. delta (for an average individual)

rpar

A vector with two elements: The first element is the variance component (standard deviation) on the log-scale, where optimization is performed. The second element is the variance component (standard deviation) on the original scale.

deviance

Deviance for the model

se

standard errors for 1) the fixed effect parameter and 2) the variance component on the log-scale

convergence

Convergence message from optim

lli

Log-likelihood contributions from each of the observations.

ranef

The random effect estimates for the levels of the clustering factor (often individual)

zi

posterior probabilities of a subject being a discriminator

p

The probability that a randomly chosen individual is a discriminator (ie. the probability mass for delta > 0 in the random effects distribution)

fitted

Fitted values

Y

The scaled response vector on which optimization is performed.

call

the matched call

Author(s)

Rune Haubo B Christensen

See Also

triangle, twoAFC, threeAFC, duotrio, discrimPwr, discrimSim, discrimSS, samediff, AnotA, findcr

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
## Not run: 
freq <- c(10,8,10,9,8,9,9,1,10,10,8,2,6,7,6,7,6,4,5,5,3,3,9,9,5,5,8,8,9,9)
tmp <- data.frame(id = factor(1:30), n = rep(10, 30), freq = freq)
head(tmp)
str(tmp)

fm <- discrimR(cbind(freq, n - freq) ~ 1, tmp, cluster = id,
                    start = c(.5, .5), method = "twoAFC",
                    ranef = TRUE, zi = TRUE, hess = TRUE, 
                    control=list(trace=TRUE, REPORT=1))

names(fm)
fm[1:4]

## End(Not run)

Example output

  id  n freq
1  1 10   10
2  2 10    8
3  3 10   10
4  4 10    9
5  5 10    8
6  6 10    9
'data.frame':	30 obs. of  3 variables:
 $ id  : Factor w/ 30 levels "1","2","3","4",..: 1 2 3 4 5 6 7 8 9 10 ...
 $ n   : num  10 10 10 10 10 10 10 10 10 10 ...
 $ freq: num  10 8 10 9 8 9 9 1 10 10 ...
initial  value 354.310895 
iter   2 value 354.235417
iter   3 value 353.536148
iter   4 value 346.241395
iter   5 value 344.052705
iter   6 value 343.411973
iter   7 value 342.524277
iter   8 value 342.422180
iter   9 value 342.400170
iter  10 value 342.400137
iter  10 value 342.400136
iter  10 value 342.400136
final  value 342.400136 
converged
 [1] "fpar"        "rpar"        "deviance"    "se"          "convergence"
 [6] "lli"         "ranef"       "zi"          "p"           "fitted"     
[11] "Y"           "call"       
$fpar
[1] 0.7803387

$rpar
[1] 0.175969 1.192401

$deviance
[1] 342.4001

$se
[1] 0.2047432 0.2248295

sensR documentation built on Feb. 11, 2020, 1:10 a.m.