regression: Regression for data, including fixed linear model, mixed...

Description Usage Arguments Examples

View source: R/linear-fit.R

Description

Regression for data, including fixed linear model, mixed linear model and generalized mixed linear model

Usage

1
2
regression(data, response, predict, random = NULL, family = "gaussian",
  stepwise = NULL)

Arguments

data

A data frame

response

Response variables

predict

A list of predict variables

random

A string of random effects,Random-effects terms are distinguished by vertical bars (|) separating expressions for design matrices from grouping factors. Two vertical bars (||) can be used to specify multiple uncorrelated random effects for the same grouping variable. (Because of the way it is implemented, the ||-syntax works only for design matrices containing numeric (continuous) predictors; to fit models with independent categorical effects, see dummy or the lmer_alt function from the afex package.)

family

a GLM family, see glm and family

stepwise

Select a formula-based model by AIC, can be one of "both", "backward", or "forward"

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
   counts <- c(18,17,15,20,10,20,25,13,12)
   outcome <- gl(3,1,9)
   treatment <- gl(3,3)
   print(d.AD <- data.frame(treatment, outcome, counts))
   regression(data =d.AD,response= c("counts"), predict = c("outcome","treatment"))
   regression(data =d.AD,response= c("counts"), predict = c("outcome","treatment"),stepwise="backward")
   ## Dobson (1990) Page 93: Randomized Controlled Trial :
   ct <- c(18,17,15,20,10,20,25,13,12)
   out <- rnorm(9,1,9)
   treat <- rnorm(9,3,3)
   print(d <- data.frame(treat, out, ct))
   regression(data =d,response= c("ct"), predict = c("out","treat"))
   counts <- c(18,17,15,20,10,20,25,13,12)
   outcome <- gl(3,1,9)
   treatment <- gl(3,3)
   regression(data =d.AD,response= c("counts"), predict = c("outcome","treatment"),family = "poisson")
   a<- regression(data =d.AD,response= c("counts"),   predict= c("outcome","treatment"))
   library(HSAUR2)
   regression(response= c("outcome"), predict = c("treatment","visit"),
          family = "binomial",
          data= toenail,random = ("1|patientID"))

ShouyeLiu/metaboliteUtility documentation built on May 6, 2019, 9:07 a.m.