chisq: Extract chi-square for writing from LRT and other techniques

Description Usage Arguments Details Value Author(s) Examples

View source: R/functions.R

Description

Extract chi-square and writes it in APA style

Usage

1
chisq(amod,pos=1)

Arguments

amod

a object of class lm, glm, glmer, anova, or "htest" from chisq.test

pos

the row of the object amod referring to the position of the test to be extracted. Default pos=2 so it is the first effect in objects referring to variables effects, or the comparison of two model for anova like objects.

Details

Returns the chi-square value with degrees of freedom and p-value. It extracts the values in different ways depending on the object passed as input. When the model is of class lm, glm, or glmer, anova(x,test="Chisq") is computed and the chisq, df, and p-value are extracted. When the object is of the class anova the object is tested for the presence of "deviance", which means that the anova has been ran with the test="Chisq" option. Then the values are extracted. If the object is of class "htest" the chisq is extracted from "statistic" field of the object. If "pos" is specified, the values in row=pos of the object are extracted, otherwise pos=2 is used, so it is the first effect in objects referring to variables effects, or the comparison of two model for anova like objects. .

Value

a string with Chisq, df, p.value and valid N is returned

Author(s)

Marcello Gallucci

Examples

1
2
3
4
5
dat<-as.data.frame(cbind(y=rbinom(100,1,.5),x=rnorm(100,0,1),id=rep(1:20)))
mod0<-glmer(y~(1|id),dat,family=binomial())
mod1<-glmer(y~(1|id)+x,dat,family=binomial())
res<-anova(mod1,mod0)
chisq(res) 

mcfanda/StatWriter documentation built on May 22, 2019, 3:01 p.m.