p_r.cat: p-value from tetrachoric/polychoric or polyserial

View source: R/p_r.cat.R

p_r.catR Documentation

p-value from tetrachoric/polychoric or polyserial

Description

Generates correlated X-Y data and returns a p-value to assess the null of no correlation in the population. The X-Y data are generated assuming a multivariate normal distribution and subsequently discretized for one or both of the variables.

Usage

p_r.cat(
  n,
  r,
  tauX,
  rho = 0,
  tauY = NULL,
  ML = TRUE,
  two.tailed = TRUE,
  score = FALSE,
  gen_fun = gen_r,
  ...
)

Arguments

n

sample size

r

correlation prior to the discretization (recovered via the polyserial/polychoric estimates)

tauX

intercept parameters used for discretizing the X variable

rho

population coefficient to test against

tauY

intercept parameters used for discretizing the Y variable. If missing a polyserial correlation will be estimated, otherwise a tetrachoric/polychoric correlation will be estimated

ML

logical; use maximum-likelihood estimation?

two.tailed

logical; should a two-tailed or one-tailed test be used?

score

logical; should the SE be based at the null hypothesis (score test) or the ML estimate (Wald test)? The former is the canonical form for a priori power analyses though requires twice as many computations as the Wald test approach

gen_fun

function used to generate the required continuous bivariate data (prior to truncation). Object returned must be a matrix with two columns. Default uses gen_r to generate conditionally dependent data from a bivariate normal distribution. User defined version of this function must include the argument ...

...

additional arguments to be passed to gen_fun. Not used unless a customized gen_fun is defined

Value

a single p-value

Author(s)

Phil Chalmers rphilip.chalmers@gmail.com

See Also

gen_r

Examples


# 100 observations, .5 correlation, tetrachoric estimate
p_r.cat(100, r=.5, tauX=0, tauY=1)

# Wald test
p_r.cat(100, r=.5, tauX=0, tauY=1, score=FALSE)

# polyserial estimate (Y continuous)
p_r.cat(50, r=.5, tauX=0)


Spower documentation built on April 4, 2025, 5:11 a.m.