mylm: mylm

Description Usage Arguments Value Examples

View source: R/mylinear.R

Description

fit a linear model with basic model diagnose

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
mylm(
  dat,
  response,
  covariates,
  inter = c(),
  category = c(),
  cat_method = "reference",
  ref = c(),
  model.diag = T,
  intercept = T,
  cutoff = 0.05
)

Arguments

dat

input data frame with no NAs, should include all the data that will be used

response

name string for response

covariates

string vector of the chosen variables in the input data frame

inter

specify the pairwise interaction in regression , e.g.:c('Age*Sex', 'Age*R_E')

category

specify the categorical variables by input the names vector

cat_method

choose the coding method for categorical variables, should be 'reference' or 'cellmeans'

ref

specify the reference level for each categorical variable

model.diag

default is True, activate the model diagnose function

intercept

default is True, make the model with an intercept

cutoff

specify the level of significance for the test

Value

similar output table as summary(lm), residuals,R.square, R.square.adj, SSE

Examples

1
2
3
4
5
6
data(mydata)
covar2 = c('Fatalism', 'Sex', 'R_E', 'Age_4Cat', 'NIHSS_4Cat')
covar3 = c('Fatalism', 'Sex', 'R_E', 'Age_4Cat')
t4 = mylm(mydata, 'Depression', covar2, category = c('Age_4Cat', 'NIHSS_4Cat'), ref = c(1,1))
t5 = mylm(mydata, 'Depression', covar3, category = c('Age_4Cat'),
cat_method = 'cellmeans', intercept = FALSE)

cyclopenta/mylinear documentation built on Dec. 19, 2021, 7:07 p.m.