author: Michael A. Erickson date: 28 August 2014 autosize: true
## Loading required package: grid
## Loading required package: lattice
## Loading required package: survival
## Loading required package: splines
## Loading required package: Formula
##
## Attaching package: 'Hmisc'
##
## The following objects are masked from 'package:base':
##
## format.pval, round.POSIXt, trunc.POSIXt, units
##
## Loading required package: MASS
## Loading required namespace: car
##
## Attaching package: 'memisc'
##
## The following object is masked from 'package:Hmisc':
##
## %nin%
##
## The following objects are masked from 'package:stats':
##
## contr.sum, contr.treatment, contrasts
##
## The following object is masked from 'package:base':
##
## as.array
##
## Loading required package: Matrix
Katherine wrote:
The DVs are positive, negative and success (ignore positive2)
The subject level variable should be “shirt color” The group level variable should be “group” or “manipulation”
I am having a hard time getting SPSS to find a solution and give me parameter estimates I feel confident about.
Any help would be appreciated.
## read.spss() is from the foreign library -- note the errors
## rto.raw <- read.spss("../TRAUMA_FEB_25_2014_final merge_Edman_WATSON.sav", to.data.frame=TRUE, use.value.labels=TRUE)
## rm(rto.raw)
## spss.system.file() is from the memisc library
stu.dat <- spss.system.file('student data2.sav')
stu.dat.ds <- as.data.set(stu.dat)
stu.dat.df <- as.data.frame(stu.dat.ds)
## description(rto.ds) # does not work with knitr because of unicode values
These are the data Aumer said to consider —
sort(names(stu.dat.df))
## [1] "AGE" "Alike_bi" "Alike_blue" "Alike_red" "art"
## [6] "art1" "art2" "BI_ALIT" "BI_ALOT" "Bi_Att"
## [11] "Bi_fri" "Bi_Good" "Bi_Hard" "Bi_help" "Bi_Nice"
## [16] "BI_NON" "Bi_Smart" "Bias_Hap" "BILIKE" "BiPositive"
## [21] "BLUE_ALI" "BLUE_ALO" "Blue_att" "Blue_fri" "Blue_Good"
## [26] "Blue_hard" "Blue_help" "Blue_Nice" "BLUE_NON" "Blue_smart"
## [31] "BluePositive" "Cat" "Change" "CHOICE" "CONF1"
## [36] "CONF10" "CONF11" "CONF12" "CONF13" "CONF2"
## [41] "CONF3" "CONF4" "CONF5" "CONF6" "CONF7"
## [46] "CONF8" "CONF9" "Conformity" "Consent" "Copy_manip"
## [51] "copy_scolor" "Copy_SE1" "Copy_SE2" "copy_team" "f_name7"
## [56] "filter_." "Group" "Heuristic" "Homework" "Homework1"
## [61] "KEEP_CH" "L_name7" "LAST_6" "LastName" "LastName_3"
## [66] "LastName_4" "LastName_5" "LastName2" "math" "math1"
## [71] "math2" "memory" "memory1" "memory2" "N"
## [76] "N_bi" "N_blue" "N_president" "N_Red" "Name"
## [81] "Name_3" "Name_4" "Name_5" "NAME_6" "Name2"
## [86] "Negative" "New_kid" "pattern" "pattern1" "pattern2"
## [91] "Peers_1" "Peers_2" "Peers_3" "Positive" "positive2"
## [96] "President" "RED_ALIT" "RED_ALOT" "Red_Att" "Red_fri"
## [101] "Red_Good" "Red_hard" "Red_help" "Red_Nice" "RED_NON"
## [106] "Red_Smart" "RedPositive" "rotation" "rotation1" "rotation2"
## [111] "SE_1" "SE_2" "SE_CHA2" "SE_Change" "SE1_1"
## [116] "SE1_10" "SE1_11" "SE1_12" "SE1_13" "SE1_14"
## [121] "SE1_15" "SE1_16" "SE1_2" "SE1_3" "SE1_4"
## [126] "SE1_5" "SE1_6" "SE1_7" "SE1_8" "SE1_9"
## [131] "SE2_1" "SE2_10" "SE2_11" "SE2_12" "SE2_13"
## [136] "SE2_14" "SE2_15" "SE2_16" "SE2_2" "SE2_3"
## [141] "SE2_4" "SE2_5" "SE2_6" "SE2_7" "SE2_8"
## [146] "SE2_9" "ShirtColor" "Spell" "spell1" "spell2"
## [151] "Success" "Success1" "Team" "team_2" "Timeouts"
## [156] "Timeouts1" "VAR00001" "VAR00002"
st.d <- subset(stu.dat.df, select=c(Positive, Negative, Success, ShirtColor, Group))
describe(st.d)
## st.d
##
## 5 Variables 142 Observations
## ------------------------------------------------------------------------------------------
## Positive
## n missing unique Mean .05 .10 .25 .50 .75 .90 .95
## 79 63 13 0.1034 -0.8500 -0.5000 -0.3333 0.0000 0.5000 1.0000 1.0000
##
## -1 (4, 5%), -0.833333333333333 (1, 1%), -0.666666666666667 (2, 3%)
## -0.5 (4, 5%), -0.333333333333333 (13, 16%), -0.166666666666667 (5, 6%)
## 0 (15, 19%), 0.166666666666667 (7, 9%), 0.333333333333333 (7, 9%)
## 0.5 (3, 4%), 0.666666666666667 (4, 5%), 0.833333333333333 (1, 1%)
## 1 (13, 16%)
## ------------------------------------------------------------------------------------------
## Negative
## n missing unique Mean
## 78 64 5 -0.5641
##
## -1 -0.5 0 0.5 1
## Frequency 45 6 21 4 2
## % 58 8 27 5 3
## ------------------------------------------------------------------------------------------
## Success
## n missing unique
## 84 58 7
##
## Red Blue Bicolor Red/Blue Red/Bicolor Blue/Bicolor Three way tie
## Frequency 15 20 21 2 2 1 23
## % 18 24 25 2 2 1 27
## ------------------------------------------------------------------------------------------
## ShirtColor
## n missing unique
## 126 16 3
##
## Red (43, 34%), Blue (39, 31%), Bicolor (44, 35%)
## ------------------------------------------------------------------------------------------
## Group
## n missing unique
## 142 0 3
##
## Control (41, 29%), Non-Verified (50, 35%), Verified (51, 36%)
## ------------------------------------------------------------------------------------------
I’m not sure what I am looking at here.
summary(Positive ~ ShirtColor:Group, st.d, method="cross", fun=smean.sd)
##
## smean.sd by ShirtColor, Group
##
## +-------+
## |N |
## |Missing|
## |Mean |
## |SD |
## +-------+
## +----------+--------+------------+--------+--------+
## |ShirtColor| Control|Non-Verified|Verified| ALL |
## +----------+--------+------------+--------+--------+
## | Red | 8 | 7 | 9 |24 |
## | | 4 | 9 | 6 |19 |
## | | 0.02083| 0.19048 |-0.09259| 0.02778|
## | |0.7686 | 0.4947 |0.3017 |0.5376 |
## +----------+--------+------------+--------+--------+
## | Blue | 4 | 10 |11 |25 |
## | | 4 | 6 | 4 |14 |
## | | 0.04167| -0.11667 | 0.30303| 0.09333|
## | |0.3436 | 0.1933 |0.5100 |0.4197 |
## +----------+--------+------------+--------+--------+
## | Bicolor |10 | 9 |11 |30 |
## | | 4 | 4 | 6 |14 |
## | | 0.11667| 0.18519 | 0.21212| 0.17222|
## | |0.6576 | 0.7238 |0.7230 |0.6787 |
## +----------+--------+------------+--------+--------+
## | NA | 0 | 0 | 0 | 0 |
## | | 7 | 5 | 4 |16 |
## | | | | | |
## +----------+--------+------------+--------+--------+
## | ALL |22 | 26 |31 |79 |
## | |19 | 24 |20 |63 |
## | | 0.06818| 0.07051 | 0.15591| 0.10338|
## | |0.6334 | 0.5125 |0.5593 |0.5606 |
## +----------+--------+------------+--------+--------+
summary(Negative ~ ShirtColor:Group, st.d, method="cross", fun=smean.sd)
##
## smean.sd by ShirtColor, Group
##
## +-------+
## |N |
## |Missing|
## |Mean |
## |SD |
## +-------+
## +----------+-------+------------+--------+-------+
## |ShirtColor|Control|Non-Verified|Verified| ALL |
## +----------+-------+------------+--------+-------+
## | Red | 8 | 7 | 9 |24 |
## | | 4 | 9 | 6 |19 |
## | |-0.1875| -0.7143 | -0.6667|-0.5208|
## | |0.7530 | 0.4880 | 0.4330 |0.5985 |
## +----------+-------+------------+--------+-------+
## | Blue | 4 | 10 | 11 |25 |
## | | 4 | 6 | 4 |14 |
## | |-0.2500| -0.6500 | -0.6364|-0.5800|
## | |0.5000 | 0.5798 | 0.4523 |0.5140 |
## +----------+-------+------------+--------+-------+
## | Bicolor | 9 | 9 | 11 |29 |
## | | 5 | 4 | 6 |15 |
## | |-0.6111| -0.7778 | -0.4091|-0.5862|
## | |0.6009 | 0.4410 | 0.7006 |0.5986 |
## +----------+-------+------------+--------+-------+
## | NA | 0 | 0 | 0 | 0 |
## | | 7 | 5 | 4 |16 |
## | | | | | |
## +----------+-------+------------+--------+-------+
## | ALL |21 | 26 | 31 |78 |
## | |20 | 24 | 20 |64 |
## | |-0.3810| -0.7115 | -0.5645|-0.5641|
## | |0.6501 | 0.4934 | 0.5438 |0.5661 |
## +----------+-------+------------+--------+-------+
So, I’m not clear about the models, either. Are these in the right ballpark? When I use lmerTest, it says that the models are not identifiable. I am having a hard time thinking about these models, so I am acting like and undergrad and just plugging and chugging. I probably plugged wrong.
Can you describe the model you are looking for a little more? This one allow the effect of group to be different for each ShirtColor, I believe.
Also, I didn’t try Success as a DV since it looks nominal. I must have missed something.
(p.lm <- lmer(Positive ~ Group + (Group | ShirtColor), st.d))
## Linear mixed model fit by REML ['lmerMod']
## Formula: Positive ~ Group + (Group | ShirtColor)
## Data: st.d
## REML criterion at convergence: 138.6
## Random effects:
## Groups Name Std.Dev. Corr
## ShirtColor (Intercept) 1.23e-13
## GroupNon-Verified 1.13e-01 0.62
## GroupVerified 1.29e-01 -0.62 -1.00
## Residual 5.60e-01
## Number of obs: 79, groups: ShirtColor, 3
## Fixed Effects:
## (Intercept) GroupNon-Verified GroupVerified
## 0.0682 0.0112 0.0822
summary(p.lm)
## Linear mixed model fit by REML ['lmerMod']
## Formula: Positive ~ Group + (Group | ShirtColor)
## Data: st.d
##
## REML criterion at convergence: 138.6
##
## Random effects:
## Groups Name Variance Std.Dev. Corr
## ShirtColor (Intercept) 1.51e-26 1.23e-13
## GroupNon-Verified 1.27e-02 1.13e-01 0.62
## GroupVerified 1.66e-02 1.29e-01 -0.62 -1.00
## Residual 3.13e-01 5.60e-01
## Number of obs: 79, groups: ShirtColor, 3
##
## Fixed effects:
## Estimate Std. Error t value
## (Intercept) 0.0682 0.1194 0.57
## GroupNon-Verified 0.0112 0.1749 0.06
## GroupVerified 0.0822 0.1730 0.48
##
## Correlation of Fixed Effects:
## (Intr) GrpN-V
## GropNn-Vrfd -0.683
## GroupVerifd -0.690 0.310
(n.lm <- lmer(Negative ~ Group + (Group | ShirtColor), st.d))
## Linear mixed model fit by REML ['lmerMod']
## Formula: Negative ~ Group + (Group | ShirtColor)
## Data: st.d
## REML criterion at convergence: 135.3
## Random effects:
## Groups Name Std.Dev. Corr
## ShirtColor (Intercept) 0.00e+00
## GroupNon-Verified 3.31e-06 NaN
## GroupVerified 1.01e-05 NaN -0.16
## Residual 5.59e-01
## Number of obs: 78, groups: ShirtColor, 3
## Fixed Effects:
## (Intercept) GroupNon-Verified GroupVerified
## -0.381 -0.331 -0.184
summary(n.lm)
## Linear mixed model fit by REML ['lmerMod']
## Formula: Negative ~ Group + (Group | ShirtColor)
## Data: st.d
##
## REML criterion at convergence: 135.3
##
## Random effects:
## Groups Name Variance Std.Dev. Corr
## ShirtColor (Intercept) 0.00e+00 0.00e+00
## GroupNon-Verified 1.10e-11 3.31e-06 NaN
## GroupVerified 1.03e-10 1.01e-05 NaN -0.16
## Residual 3.12e-01 5.59e-01
## Number of obs: 78, groups: ShirtColor, 3
##
## Fixed effects:
## Estimate Std. Error t value
## (Intercept) -0.381 0.122 -3.12
## GroupNon-Verified -0.331 0.164 -2.02
## GroupVerified -0.184 0.158 -1.16
##
## Correlation of Fixed Effects:
## (Intr) GrpN-V
## GropNn-Vrfd -0.744
## GroupVerifd -0.772 0.574