Package 'Keng'

Title: Keng's Axe and Firewood
Description: Miscellaneous functions and data used in Qingyao's psychological research and teaching.
Authors: Qingyao Zhang [aut, cre]
Maintainer: Qingyao Zhang <[email protected]>
License: CC BY 4.0
Version: 2024.10.16
Built: 2024-10-18 12:30:47 UTC
Source: CRAN

Help Index


Cut-off values of r given the sample size n.

Description

Cut-off values of r given the sample size n.

Usage

cut_r(n)

Arguments

n

Sample size of the r.

Details

Given n and p, t and then r could be determined. The formula used could be found in test_r()'s documentation.

Value

A data.frame including the cut-off values of r at the significance levels of p = 0.1, 0.05, 0.01, 0.001. r with the absolute value larger than the cut-off value is significant at the corresponding significance level.

Examples

cut_r(193)

Compute PRE and test it using the F-test.

Description

Compute PRE and test it using the F-test.

Usage

test_PRE(
  fitC = NULL,
  fitA = NULL,
  n = NULL,
  PC = NULL,
  PA = NULL,
  SSEC = NULL,
  SSEA = NULL
)

Arguments

fitC

The result of lm() of the Compact model (Model C).

fitA

The result of lm() of the Augmented model (Model A).

n

Sample size of the Model C or Model A. Model C and Model A must use the same sample, and hence have the same sample size.

PC

The number of parameters in Model C.

PA

The number of parameters in Model A. PA must be larger than PC.

SSEC

The Sum of Squared Errors of Model C.

SSEA

The Sum of Squared Errors of Model A.

Details

test_PRE() tests the PRE (Proportional Reduction in Error) of Model A compared with Model C. There are two ways of using test_PRE(). The first is giving test_PRE() fitC and fitA. The second is giving n, PC, PA, SSEC, and SSEA. The first way is more convenient, and it minimizes precision loss by omitting copying and pasting SSEC and SSEA. Please refer to Judd et al. (2017) for more details about PRE.

Value

A data.frame including SSEC, SSEA, PRE, F, df1, df2, and p.

References

Judd, C. M., McClelland, G. H., & Ryan, C. S. (2017). Data analysis: A model comparison approach to regression, ANOVA, and beyond. Routledge.

Examples

x <- rnorm(193)
y <- 0.3 + 0.2*x + rnorm(193)
dat <- data.frame(y, x)
fitC <- lm(y ~ 1, dat)
fitA <- lm(y ~ x, dat)
test_PRE(fitC, fitA)

Test r using the t-test given r and n.

Description

Test r using the t-test given r and n.

Usage

test_r(r, n)

Arguments

r

Pearson correlation.

n

Sample size of r.

Details

To test the significance of the r using one-sample t-test, the SE of the r is determined by the following formula: SE = sqrt((1 - r^2)/(n - 2)).

Value

A data.frame including r, se of r, t, and p.

Examples

test_r(0.2, 193)