pclass | R Documentation |

Fit a binary regression model for response probabilities and divide units into a specified number of classes.

pclass(formula, data, link="logit", numcl=5, type, design=NULL)

`formula` |
symbolic description of the binary regression model to be fitted as used in |

`data` |
an optional data frame; must be specified if |

`link` |
a specification for the model link function; allowable values are |

`numcl` |
number of classes into which units are split based on estimated propensities |

`type` |
whether an unweighted or weighted binary regression should be fit; allowable values are |

`design` |
sample design object; required if |

A typical `formula`

has the form `response ~ terms`

where response is a two-level variable coded as 0 or 1, or is a factor where the first level denotes nonresponse and the second level is response. If `type="unwtd"`

, `glm`

is used to fit an unweighted regression. If `type="wtd"`

, `svyglm`

in the `survey`

package is used to fit a survey-weighted regression.

A list with components:

`p.class` |
propensity class for each unit |

`propensities` |
estimated response probability for each unit |

Richard Valliant, Jill A. Dever, Frauke Kreuter

Valliant, R., Dever, J., Kreuter, F. (2018, chap. 13). *Practical Tools for Designing and Weighting Survey Samples, 2nd edition*. New York: Springer.

`NRadjClass`

# classes based on unweighted logistic regression require(PracTools) data(nhis) out <- pclass(formula = resp ~ age + as.factor(sex) + as.factor(hisp) + as.factor(race), data = nhis, type = "unwtd", link="logit", numcl=5) table(out$p.class, useNA="always") summary(out$propensities) # classes based on survey-weighted logistic regression require(survey) nhis.dsgn <- svydesign(ids = ~psu, strata = ~stratum, data = nhis, nest = TRUE, weights = ~svywt) out <- pclass(formula = resp ~ age + as.factor(sex) + as.factor(hisp) + as.factor(race), type = "wtd", design = nhis.dsgn, link="logit", numcl=5) table(out$p.class, useNA="always") summary(out$propensities)

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.