BIFIE.logistreg.Rd
Computes logistic regression. Explained variance \(R^2\) is computed by the approach of McKelvey and Zavoina.
Object of class BIFIEdata
String for the dependent variable in the regression model
Vector of predictor variables. If the intercept should be included,
then use the variable one
for specifying it (see Examples).
An R formula object which can be applied instead of
providing dep
and pre
. Note that there is
additional computation time needed for model matrix creation.
Optional grouping variable(s)
Optional vector of grouping values. This can be omitted and grouping values will be determined automatically.
Optional logical indicating whether statistical inference based on replication should be employed.
Convergence criterion for parameters
Maximum number of iterations
Object of class BIFIE.logistreg
Number of digits for rounding output
Further arguments to be passed
A list with following entries
Data frame with regression coefficients
Extensive output with all replicated statistics
More values
survey::svyglm
,
stats::glm
For linear regressions see BIFIE.linreg
.
#############################################################################
# EXAMPLE 1: TIMSS dataset | Logistic regression
#############################################################################
data(data.timss2)
data(data.timssrep)
# create BIFIE.dat object
bdat <- BIFIEsurvey::BIFIE.data( data.list=data.timss2, wgt=data.timss2[[1]]$TOTWGT,
wgtrep=data.timssrep[, -1 ] )
#**** Model 1: Logistic regression - prediction of migrational background
res1 <- BIFIEsurvey::BIFIE.logistreg( BIFIEobj=bdat, dep="migrant",
pre=c("one","books","lang"), group="female", se=FALSE )
summary(res1)
if (FALSE) {
# same model, but with formula specification and standard errors
res1a <- BIFIEsurvey::BIFIE.logistreg( BIFIEobj=bdat,
formula=migrant ~ books + lang, group="female" )
summary(res1a)
#############################################################################
# SIMULATED EXAMPLE 2: Comparison of stats::glm and BIFIEsurvey::BIFIE.logistreg
#############################################################################
#*** (1) simulate data
set.seed(987)
N <- 300
x1 <- stats::rnorm(N)
x2 <- stats::runif(N)
ypred <- -0.75+.2*x1 + 3*x2
y <- 1*( stats::plogis(ypred) > stats::runif(N) )
data <- data.frame( "y"=y, "x1"=x1, "x2"=x2 )
#*** (2) estimation logistic regression using glm
mod1 <- stats::glm( y ~ x1 + x2, family="binomial")
#*** (3) estimation logistic regression using BIFIEdata
# create BIFIEdata object by defining 30 Jackknife zones
bifiedata <- BIFIEsurvey::BIFIE.data.jack( data, jktype="JK_RANDOM", ngr=30 )
summary(bifiedata)
# estimate logistic regression
mod2 <- BIFIEsurvey::BIFIE.logistreg( bifiedata, formula=y ~ x1+x2 )
#*** (4) compare results
summary(mod2) # BIFIE.logistreg
summary(mod1) # glm
}