Learn R Programming

BIFIEsurvey (version 1.5-0)

BIFIE.linreg: Linear Regression

Description

Computes linear regression.

Usage

BIFIE.linreg(BIFIEobj, dep=NULL , pre=NULL, formula=NULL , 
    group = NULL, group_values = NULL, se=TRUE)

## S3 method for class 'BIFIE.linreg':
summary(object,digits=4,...)

## S3 method for class 'BIFIE.linreg':
coef(object,...)

## S3 method for class 'BIFIE.linreg':
vcov(object,...)

Arguments

BIFIEobj
Object of class BIFIEdata
dep
String for the dependent variable in the regression model
pre
Vector of predictor variables. If the intercept should be included, then use the variable one for specifying it (see Examples).
formula
An Rformula object which can be applied instead of providing dep and pre. Note that there is additional computation time needed for model matrix creation.
group
Optional grouping variable(s)
group_values
Optional vector of grouping values. This can be omitted and grouping values will be determined automatically.
se
Optional logical indicating whether statistical inference based on replication should be employed.
object
Object of class BIFIE.linreg
digits
Number of digits for rounding output
...
Further arguments to be passed

Value

  • A list with following entries
  • statData frame with unstandardized and standardized regression coefficients, residual standard deviation and $R^2$
  • outputExtensive output with all replicated statistics
  • ...More values

See Also

survey::svyglm, intsvy::timss.reg, intsvy::timss.reg.pv, stats::lm

Examples

Run this code
#############################################################################
# EXAMPLE 1: Imputed TIMSS dataset
#############################################################################

data(data.timss1)
data(data.timssrep)

# create BIFIE.dat object
bdat <- BIFIE.data( data.list=data.timss1 , wgt=  data.timss1[[1]]$TOTWGT ,
             wgtrep=data.timssrep[, -1 ] )

#**** Model 1: Linear regression for mathematics score
mod1 <- BIFIE.linreg( bdat , dep= "ASMMAT" , pre=c("one","books","migrant") ,
              group= "female" )
summary(mod1)

# same model but specified with R formulas 
mod1a <- BIFIE.linreg( bdat , formula = ASMMAT ~ books + migrant ,
               group= "female" , group_values = 0:1 )
summary(mod1a)

# compare result with lm function and first imputed dataset
dat1 <- data.timss1[[1]]
mod1b <- lm( ASMMAT ~ 0+as.factor(female)+as.factor(female):books+as.factor(female):migrant , 
                data= dat1 ,  weights=dat1$TOTWGT )
summary(mod1b)

#**** Model 2: Like Model 1, but books is now treated as a factor 
mod2 <- BIFIE.linreg( bdat , formula = ASMMAT ~ as.factor(books) + migrant  )
summary(mod2)

Run the code above in your browser using DataLab