cond.inf: Conditional inference

View source: R/function.R

cond.infR Documentation

Conditional inference

Description

Conditional inference for lm and glm models

Usage

cond.inf(
  object,
  cond.data = NULL,
  param = NULL,
  alg = "loess",
  random.seed = NULL,
  other.params = NULL,
  folds = NULL,
  verbose = TRUE
)

Arguments

object

An lm() or glm() object

cond.data

Optional, a dataframe for the conditioning set; set as all covariates in the lm() or glm() object formula if not provided

param

Optional, a vector of coefficients to conduct conditional inference; fit all coefficients if not provided; can be a mixture of string name and index

alg

Optinal, a string for name of algorithm, current options are 'loess' and 'grf'

random.seed

Optional, random seed for sample splitting

other.params

Optional, other parameters for the regression algorithm; can include span and degree for loess

folds

Optional, a list of two folds of indices for sample splitting; can be useful to control sample splitting

verbose

Optional, whether or not to print summary of inference; TRUE by default

Value

Standard error for conditional parameter, super-population parameter, fitted empirical parameter, confidence interval for conditional parameter

Examples

X = matrix(rnorm(1000*10), nrow=1000)
Y = X %*% matrix(c(1,2,3,rep(0,10-3)), ncol=1) + rnorm(1000) * 0.1
Z = data.frame(X[,1:2])
lm.mdl = lm(Y~., data = data.frame(X))
cond.inf(lm.mdl, Z, c("X2",2)) 

X = matrix(rnorm(1000*10), nrow=1000)
logit.x = X %*% matrix(c(1,2,3,rep(0,10-3)), ncol=1) + X[,1]**2 + rnorm(1000) * 0.1
Y = rbinom(n, 1, exp(logit.x)/(1+exp(logit.x)))
Z = data.frame(X[,1:2])
glm.mdl = glm(Y~., data = data.frame(X), family='binomial')
cond.inf(glm.mdl, cond.data=Z)
cond.inf(glm.mdl, cond.data=Z, c(1, "X1", "X2"), alg='grf')


ying531/condinf documentation built on July 29, 2022, 6:55 p.m.