Format ChiSqTest from data.

# S3 method for data.frame
wrapChiSqTest(
  x,
  predictionColumnName,
  yColumnName,
  ...,
  yTarget = TRUE,
  nParameters = 1,
  meany = mean(x[[yColumnName]] == yTarget),
  na.rm = FALSE
)

Arguments

x

data frame containing columns to compare

predictionColumnName

character name of prediction column

yColumnName

character name of column containing dependent variable

...

extra arguments (not used)

yTarget

y value to consider positive

nParameters

number of variables in model

meany

(optional) mean of y

na.rm

logical, if TRUE remove NA values

Value

wrapped test

Examples

d <- data.frame(x=c(1,2,3,4,5,6,7,7), y=c(TRUE,FALSE,FALSE,FALSE,TRUE,TRUE,TRUE,FALSE)) model <- glm(y~x, data=d, family=binomial) summary(model)
#> #> Call: #> glm(formula = y ~ x, family = binomial, data = d) #> #> Deviance Residuals: #> Min 1Q Median 3Q Max #> -1.37180 -1.09714 -0.00811 1.08024 1.42939 #> #> Coefficients: #> Estimate Std. Error z value Pr(>|z|) #> (Intercept) -0.7455 1.6672 -0.447 0.655 #> x 0.1702 0.3429 0.496 0.620 #> #> (Dispersion parameter for binomial family taken to be 1) #> #> Null deviance: 11.090 on 7 degrees of freedom #> Residual deviance: 10.837 on 6 degrees of freedom #> AIC: 14.837 #> #> Number of Fisher Scoring iterations: 4 #>
d$pred <- predict(model,type='response',newdata=d) render(wrapChiSqTest(d,'pred','y'),pLargeCutoff=1)
#> [1] "Chi-Square Test summary: pseudo-R2=0.02282 (X2(1,N=8)=0.2531, p=0.6149)."