R: Automated model selection process for the Consumer data
consmixed
R Documentation
Automated model selection process for the Consumer data
Description
Constructs the biggest possible model and reduces it to the best by principle of parcimony. First elimination of random effects is performed following by elimination of fixed effects.
The LRT test is used for testing random terms, F-type hypothesis test is used for testing fixed terms. The post-hoc and plots are provided
vector with names of the variables associated with products
Cons_effects
vector with names of the effects associated with consumers
Cons
name of the column in the data that represents consumers
data
data frame (data from consumer studies)
structure
one of the values in c(1,2,3). 1:Analysis of main effects, Random consumer effect AND interaction between consumer and the main effects(Automized reduction in random part, NO reduction in fixed part). 2: Main effects AND all 2-factor interactions. Random consumer effect AND interaction between consumer and all fixed effects (both main and interaction ones). (Automized reduction in random part, NO reduction in fixed part). 3: Full factorial model with ALL possible fixed and random effects. (Automized reduction in random part, AND automized reduction in fixed part).
alpha.random
significance level for elimination of the random part (for LRT test)
alpha.fixed
significance level for elimination of the fixed part (for F test)
...
other potential arguments.
Value
rand.table
table with value of Chi square test, p-values e t.c. for the random effects
anova.table
table which tests whether the model fixed terms are significant (Analysis of Variance)
model
Final model - object of class lmer or gls (after all the required reduction has been performed)
Author(s)
Alexandra Kuznetsova, Per Bruun Brockhoff, Rune Haubo Bojesen Christensen
Examples
library(SensMixed)
#convert some variables to factors in Tham
ham <- convertToFactors(ham, c("Consumer", "Product", "Information", "Gender"))
consmixed(response="Liking",
Prod_effects= c("Product","Information"),
Cons_effects=c("Gender","Age"), Cons = "Consumer", data =ham, structure=1)
Results
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(SensMixed)
Loading required package: lmerTest
Loading required package: Matrix
Loading required package: lme4
Attaching package: 'lmerTest'
The following object is masked from 'package:lme4':
lmer
The following object is masked from 'package:stats':
step
Attaching package: 'SensMixed'
The following object is masked from 'package:lmerTest':
ham
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/SensMixed/consmixed.Rd_%03d_medium.png", width=480, height=480)
> ### Name: consmixed
> ### Title: Automated model selection process for the Consumer data
> ### Aliases: consmixed
>
> ### ** Examples
>
> library(SensMixed)
>
> #convert some variables to factors in Tham
> ham <- convertToFactors(ham, c("Consumer", "Product", "Information", "Gender"))
>
>
> consmixed(response="Liking",
+ Prod_effects= c("Product","Information"),
+ Cons_effects=c("Gender","Age"), Cons = "Consumer", data =ham, structure=1)
Random effects:
Chi.sq Chi.DF elim.num p.value
Information:Consumer 1.25 1 1 0.2626
Product:Consumer 163.50 1 kept <1e-07
Consumer 3.42 1 kept 0.0645
Fixed effects:
Sum Sq Mean Sq NumDF DenDF F.value Pr(>F)
Product 19.3466 6.4489 3 240 3.8291 0.0105
Information 6.5201 6.5201 1 323 3.8714 0.0500
Gender 1.4781 1.4781 1 78 0.8777 0.3517
Age 0.0254 0.0254 1 78 0.0151 0.9026
Least squares means:
Product Information Gender Estimate Standard Error DF t-value
Product 1 1 NA NA 5.807 0.233 309 24.9
Product 2 2 NA NA 5.103 0.233 309 21.9
Product 3 3 NA NA 6.091 0.233 309 26.2
Product 4 4 NA NA 5.924 0.233 309 25.4
Information 1 NA 1 NA 5.631 0.141 103 40.0
Information 2 NA 2 NA 5.832 0.141 103 41.5
Gender 1 NA NA 1 5.857 0.186 78 31.4
Gender 2 NA NA 2 5.606 0.189 78 29.7
Lower CI Upper CI p-value
Product 1 5.35 6.27 <2e-16 ***
Product 2 4.65 5.56 <2e-16 ***
Product 3 5.63 6.55 <2e-16 ***
Product 4 5.47 6.38 <2e-16 ***
Information 1 5.35 5.91 <2e-16 ***
Information 2 5.55 6.11 <2e-16 ***
Gender 1 5.49 6.23 <2e-16 ***
Gender 2 5.23 5.98 <2e-16 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Differences of LSMEANS:
Estimate Standard Error DF t-value Lower CI Upper CI
Product 1 - 2 0.7 0.314 240.0 2.24 0.0849 1.323
Product 1 - 3 -0.3 0.314 240.0 -0.90 -0.9027 0.335
Product 1 - 4 -0.1 0.314 240.0 -0.37 -0.7361 0.501
Product 2 - 3 -1.0 0.314 240.0 -3.14 -1.6064 -0.369
Product 2 - 4 -0.8 0.314 240.0 -2.61 -1.4398 -0.202
Product 3 - 4 0.2 0.314 240.0 0.53 -0.4521 0.785
Information 1 - 2 -0.2 0.102 323.0 -1.97 -0.4012 0.000
Gender 1 - 2 0.3 0.268 78.0 0.94 -0.2825 0.785
p-value
Product 1 - 2 0.026 *
Product 1 - 3 0.367
Product 1 - 4 0.709
Product 2 - 3 0.002 **
Product 2 - 4 0.009 **
Product 3 - 4 0.596
Information 1 - 2 0.050 *
Gender 1 - 2 0.352
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Final model:
lme4::lmer(formula = Liking ~ Product + (1 | Product:Consumer) +
Information + Gender + Age + (1 | Consumer), data = data,
contrasts = list(Product = "contr.SAS", Information = "contr.SAS",
Gender = "contr.SAS"))
>
>
>
>
>
>
> dev.off()
null device
1
>