svyloglin | R Documentation |

Fit and compare hierarchical loglinear models for complex survey data.

```
svyloglin(formula, design, ...)
## S3 method for class 'svyloglin'
update(object,formula,...)
## S3 method for class 'svyloglin'
anova(object,object1,...,integrate=FALSE)
## S3 method for class 'anova.svyloglin'
print(x,pval=c("F","saddlepoint","lincom","chisq"),...)
## S3 method for class 'svyloglin'
coef(object,...,intercept=FALSE)
```

`formula` |
Model formula |

`design` |
survey design object |

`object` , `object1` |
loglinear model from |

`pval` |
p-value approximation: see Details |

`integrate` |
Compute the exact asymptotic p-value (slow)? |

`...` |
not used |

`intercept` |
Report the intercept? |

`x` |
anova object |

The loglinear model is fitted to a multiway table with probabilities
estimated by `svymean`

and with the sample size equal to the
observed sample size, treating the resulting table as if it came from iid
multinomial sampling, as described by Rao and Scott. The
variance-covariance matrix does not include the intercept term, and so
by default neither does the `coef`

method. A Newton-Raphson
algorithm is used, rather than iterative proportional fitting, so
starting values are not needed.

The `anova`

method computes the quantities that would be the score
(Pearson) and likelihood ratio chi-squared statistics if the data were
an iid sample. It computes four p-values for each of these, based on the
exact asymptotic distribution (see `pchisqsum`

), a
saddlepoint approximateion to this distribution, a scaled
chi-squared distribution, and a scaled F-distribution. When testing the
two-way interaction model against the main-effects model in a two-way
table the score statistic and p-values match the Rao-Scott tests
computed by `svychisq`

.

The `anova`

method can only compare two models if they are for
exactly the same multiway table (same variables and same order). The
`update`

method will help with this. It is also much faster to use
`update`

than `svyloglin`

for a large data set: its time
complexity depends only on the size of the model, not on the size of the
data set.

It is not possible to fit a model using a variable created inline, eg
`I(x<10)`

, since the multiway table is based on all variables used
in the formula.

Object of class `"svyloglin"`

Rao, JNK, Scott, AJ (1984) "On Chi-squared Tests For Multiway Contingency Tables with Proportions Estimated From Survey Data" Annals of Statistics 12:46-60.

`svychisq`

, `svyglm`

,`pchisqsum`

```
data(api)
dclus1<-svydesign(id=~dnum, weights=~pw, data=apiclus1, fpc=~fpc)
a<-svyloglin(~stype+comp.imp,dclus1)
b<-update(a,~.^2)
an<-anova(a,b)
an
print(an, pval="saddlepoint")
## Wald test
regTermTest(b, ~stype:comp.imp)
## linear-by-linear association
d<-update(a,~.+as.numeric(stype):as.numeric(comp.imp))
an1<-anova(a,d)
an1
```

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.