summary_c2c {cat2cat}R Documentation

Summary for data.frame with replicated rows

Description

transforming summary.lm object according to real number of d.f. The standard errors, t statistics and p values have to be adjusted because of replicated rows.

Usage

summary_c2c(x, df_old, df_new = x$df.residual)

Arguments

x

lm object

df_old

integer number of d.f in original dataset. For bigger datasets 'nrow' should be sufficient.

df_new

integer number of d.f in dataset with replicated rows, Default: x$df.residual

Details

The size of the correction is equal to sqrt(df_new / df_old). Where standard errors are multiplied and t statistics divided by it. In most cases the default df_new value should be used.

Value

data.frame with additional columns over a regular summary.lm output like correct and statistics adjusted by it.

Examples

data(occup_small)
data(trans)

occup_old <- occup_small[occup_small$year == 2008, ]
occup_new <- occup_small[occup_small$year == 2010, ]

occup_2 <- cat2cat(
  data = list(old = occup_old, new = occup_new, cat_var = "code", time_var = "year"),
  mappings = list(trans = trans, direction = "backward"),
  ml = list(
    method = "knn",
    features = c("age", "sex", "edu", "exp", "parttime", "salary"),
    args = list(k = 10)
  )
)

# Regression
# we have to adjust size of std as we artificialy enlarge degrees of freedom
lms <- lm(I(log(salary)) ~ age + sex + factor(edu) + parttime + exp, occup_2$old,
  weights = multiplier * wei_freq_c2c
)

summary_c2c(lms, df_old = nrow(occup_old))

[Package cat2cat version 0.2.1 Index]