Research Project for Bimodal Outcomes

The main purpose of this study is to investigate if there exist intervention effects

Intervention conditions: 1=control, 3=providing choice, 4=free choice; the data were collected at 2 time points (before interevention and after intervention)

More specifically, our research question is if the intervention had impact on high school students' behaviours during PE lessons (MVPA or sedentary behaviour) Note. Students' age are 13-14.

Our second research question is how other covariates (i.e., ) mediate the effects of the intervention

At the same time, we want to control for some covariates (teachers' and students' gender, coeducation conditions) that are not of our interest

Import data

setwd("C:/yan/UBC/projects/Mark/Chris/analysis/Oct2013_Bayesian")
auto<-read.csv("auto_Oct20.csv",head=T)
head(auto)
##   tchid stdid MVPA1 MVPA2 MVPA1r MVPA2r SED1 SED2 TrialArm x1 x2 ch1.1
## 1     6     1    82    70      1      1    4   11        3  1  0     2
## 2     6     2    60    63      1      1   12   14        3  1  0     0
## 3     8     3    48    43      0      0   21   31        1  0  0     2
## 4     8     4    58    60      1      1   18   16        1  0  0     6
## 5     8     5    57    57      1      1   16   17        1  0  0     2
## 6     6     6    44    41      0      0   36   38        3  1  0     0
##   ch2.1 ch3.1 ch4.1 ch1.2 ch2.2 ch3.2 ch4.2 vol1.1 vol2.1 vol3.1 vol1.2
## 1     5     6     6     1     3     5     6      6      6      6      6
## 2     0     6     6     6     6     6     6      6      6      6      6
## 3     6     6     6     6     6     6     6      6      6      6      6
## 4     6     6     6     5     6     6     6      6      6      6      6
## 5     4     6     6     5     5     5     6      6      6      6      6
## 6     0     0     6     6     6     6     6      6      6      6      6
##   vol2.2 vol3.2 ploc1.1 ploc2.1 ploc3.1 ploc1.2 ploc2.2 ploc3.2 tsex coedu
## 1      5      6       6       6       6       6       6       6    0     2
## 2      6      6       6       6       6       6       6       6    0     2
## 3      6      6       1       3       6       6       6       6    1     2
## 4      5      6       6       6       6       6       6       6    1     2
## 5      6      6       5       5       6       6       6       6    1     2
## 6      6      6       6       6       6       6       6       6    0     2
##   coedu1 coedu2 sex chtot_1 chtot_2 vol_tot1 vol_tot2 ploc_tot1 ploc_tot2
## 1      0      1   1      13       9       18       17        18        18
## 2      0      1   1       6      18       18       18        18        18
## 3      0      1   1      14      18       18       18        10        18
## 4      0      1   1      18      17       18       17        18        18
## 5      0      1   1      12      15       18       18        16        18
## 6      0      1   1       0      18       18       18        18        18
str(auto)
## 'data.frame':    228 obs. of  42 variables:
##  $ tchid    : int  6 6 8 8 8 6 8 10 1 3 ...
##  $ stdid    : int  1 2 3 4 5 6 7 8 9 10 ...
##  $ MVPA1    : int  82 60 48 58 57 44 73 22 23 27 ...
##  $ MVPA2    : int  70 63 43 60 57 41 68 27 20 27 ...
##  $ MVPA1r   : int  1 1 0 1 1 0 1 0 0 0 ...
##  $ MVPA2r   : int  1 1 0 1 1 0 1 0 0 0 ...
##  $ SED1     : int  4 12 21 18 16 36 11 65 50 55 ...
##  $ SED2     : int  11 14 31 16 17 38 14 50 62 52 ...
##  $ TrialArm : int  3 3 1 1 1 3 1 3 1 3 ...
##  $ x1       : int  1 1 0 0 0 1 0 1 0 1 ...
##  $ x2       : int  0 0 0 0 0 0 0 0 0 0 ...
##  $ ch1.1    : int  2 0 2 6 2 0 2 0 6 4 ...
##  $ ch2.1    : int  5 0 6 6 4 0 6 5 4 2 ...
##  $ ch3.1    : int  6 6 6 6 6 0 6 5 5 2 ...
##  $ ch4.1    : int  6 6 6 6 6 6 6 6 4 2 ...
##  $ ch1.2    : int  1 6 6 5 5 6 4 3 3 6 ...
##  $ ch2.2    : int  3 6 6 6 5 6 5 5 2 6 ...
##  $ ch3.2    : int  5 6 6 6 5 6 6 4 4 5 ...
##  $ ch4.2    : int  6 6 6 6 6 6 6 4 3 5 ...
##  $ vol1.1   : int  6 6 6 6 6 6 6 6 6 6 ...
##  $ vol2.1   : int  6 6 6 6 6 6 6 6 6 6 ...
##  $ vol3.1   : int  6 6 6 6 6 6 6 6 6 5 ...
##  $ vol1.2   : int  6 6 6 6 6 6 6 6 6 6 ...
##  $ vol2.2   : int  5 6 6 5 6 6 6 6 6 6 ...
##  $ vol3.2   : int  6 6 6 6 6 6 6 6 6 6 ...
##  $ ploc1.1  : int  6 6 1 6 5 6 6 5 4 2 ...
##  $ ploc2.1  : int  6 6 3 6 5 6 6 6 6 1 ...
##  $ ploc3.1  : int  6 6 6 6 6 6 6 6 6 5 ...
##  $ ploc1.2  : int  6 6 6 6 6 6 6 4 6 2 ...
##  $ ploc2.2  : int  6 6 6 6 6 6 6 5 6 6 ...
##  $ ploc3.2  : int  6 6 6 6 6 6 6 6 6 5 ...
##  $ tsex     : int  0 0 1 1 1 0 1 0 0 1 ...
##  $ coedu    : int  2 2 2 2 2 2 2 1 0 0 ...
##  $ coedu1   : int  0 0 0 0 0 0 0 1 0 0 ...
##  $ coedu2   : int  1 1 1 1 1 1 1 0 0 0 ...
##  $ sex      : int  1 1 1 1 1 1 1 0 1 1 ...
##  $ chtot_1  : int  13 6 14 18 12 0 14 10 15 8 ...
##  $ chtot_2  : int  9 18 18 17 15 18 15 12 9 17 ...
##  $ vol_tot1 : int  18 18 18 18 18 18 18 18 18 17 ...
##  $ vol_tot2 : int  17 18 18 17 18 18 18 18 18 18 ...
##  $ ploc_tot1: int  18 18 10 18 16 18 18 17 16 8 ...
##  $ ploc_tot2: int  18 18 18 18 18 18 18 15 18 13 ...
#rm(list=ls())
# redefine the characteristic of some variables
intervention<-rep(0,nrow(auto))

auto$tchidr<-as.factor(auto$tchid)
auto$TrialArmr<-as.factor(auto$TrialArm)
auto$x1r<-as.factor(auto$x1)
auto$x2r<-as.factor(auto$x2)
auto$tsexr<-as.factor(auto$tsex)
auto$coedur<-as.factor(auto$coedu)
auto$coedu1r<-as.factor(auto$coedu1)
auto$coedu2r<-as.factor(auto$coedu2)
auto$sexr<-as.factor(auto$sex)

auto_new<-cbind(auto,auto$tchidr,auto$TrialArmr,auto$x1r,auto$x2r,auto$tsexr,auto$coedur,auto$coedu1r,auto$coedu2r,auto$sexr,intervention)
auto_new$intervention[auto$TrialArm==1]<-"control"
auto_new$intervention[auto$TrialArm==3]<-"prdchoice"
auto_new$intervention[auto$TrialArm==4]<-"freechoice"
auto1<-as.data.frame(auto_new)
#str(auto.new)
#write.table(auto_new,file="auto_new.csv", sep=",")
#auto1<-read.csv("auto_new.csv", header=T)
#str(auto1)

Load the graphics and table packages:

library(ggplot2)
library(lattice)
library(plyr)
library(xtable)

define a function for converting and printing to HTML table

htmlPrint <- function(x, ...,
                      digits = 0, include.rownames = FALSE) {
  print(xtable(x, digits = digits, ...), type = 'html',
        include.rownames = include.rownames, ...)
}

Descriptive Statistics: Two outcome variables over two time points: MVPA1, MVPA2, SED1, SED2 Primary independent variable: treatment condition–TrialArm (1=control, 3=providing choice, 4=free choice)


y1<-ddply(auto1, ~ intervention, summarize,
             min = min(MVPA1), max = max(MVPA1),mean=round(mean(MVPA1),2),
             sd=round(sd(MVPA1),2), median=round(median(MVPA1),2))
y2<-ddply(auto1, ~ intervention, summarize,
             min = min(MVPA1), max = max(MVPA1),mean=round(mean(MVPA2),2),
             sd=round(sd(MVPA2),2), median=round(median(MVPA2),2))
y3<-ddply(auto1, ~ intervention, summarize,
             min = min(SED1), max = max(SED1),mean=round(mean(SED1),2),
             sd=round(sd(SED1),2), median=round(median(SED1),2))
y4<-ddply(auto1, ~ intervention, summarize,
             min = min(SED2), max = max(SED1),mean=round(mean(SED2),2),
             sd=round(sd(SED2),2), median=round(median(SED2),2)) 

y1 <- as.data.frame(y1)
y2 <- as.data.frame(y2)
y3 <- as.data.frame(y3)
y4 <- as.data.frame(y4)
htmlPrint(y1)
intervention min max mean sd median
control 6 80 31 18 26
freechoice 6 68 33 18 24
prdchoice 6 82 29 19 22
htmlPrint(y2)
intervention min max mean sd median
control 6 80 31 17 28
freechoice 6 68 39 23 41
prdchoice 6 82 31 18 26
htmlPrint(y3)
intervention min max mean sd median
control 7 78 48 19 54
freechoice 13 79 47 20 51
prdchoice 4 84 53 22 59
htmlPrint(y4)
intervention min max mean sd median
control 14 78 46 19 47
freechoice 0 79 37 24 33
prdchoice 0 84 49 20 53

Univariate plots: density distributions of outcome variables

#install.packages("gridExtra")
library(gridExtra)                                                
## Loading required package: grid
# par(mfrow=c(2,2)) # only work for basis graph, so need to use grid.arrange()
# Outcome density distribution
y1<-densityplot(auto1$MVPA1)
y2<-densityplot(auto1$MVPA2)
y3<-densityplot(auto1$SED1)
y4<-densityplot(auto1$SED2)
grid.arrange(y1,y2,y3,y4)

plot of chunk unnamed-chunk-6


# Outcome density distribution by intervention (control,free choice, providing choice)
y1g<-densityplot(~MVPA1|intervention, data=auto1,plot.opoints=F, ref=T, layout=c(3,1))
y2g<-densityplot(~MVPA2|intervention, data=auto1,plot.opoints=F, ref=T, layout=c(3,1))
grid.arrange(y1g,y2g)

plot of chunk unnamed-chunk-6


y3g<-densityplot(~SED1|intervention, data=auto1,plot.opoints=F, ref=T, layout=c(3,1))
y4g<-densityplot(~SED2|intervention, data=auto1,plot.opoints=F, ref=T, layout=c(3,1))
grid.arrange(y3g,y4g)

plot of chunk unnamed-chunk-6

Explore if outcome variables are related to other covariates i.e., student sex and coeducation conditions Tables may not be efficient when we have more covariates

# examine gender differences
y1sex<-ddply(auto1, .(intervention,sex), summarize,
             min = min(MVPA1), max = max(MVPA1),mean=round(mean(MVPA1),2),
             sd=round(sd(MVPA1),2), median=round(median(MVPA1),2))
y2sex<-ddply(auto1, .(intervention,sex), summarize,
             min = min(MVPA1), max = max(MVPA1),mean=round(mean(MVPA2),2),
             sd=round(sd(MVPA2),2), median=round(median(MVPA2),2))
y3sex<-ddply(auto1, .(intervention,sex), summarize,
             min = min(SED1), max = max(SED1),mean=round(mean(SED1),2),
             sd=round(sd(SED1),2), median=round(median(SED1),2))
y4sex<-ddply(auto1, .(intervention,sex), summarize,
             min = min(SED2), max = max(SED1),mean=round(mean(SED2),2),
             sd=round(sd(SED2),2), median=round(median(SED2),2))  

# examine coeducation differences
y1coed<-ddply(auto1, .(intervention,coedu), summarize,
             min = min(MVPA1), max = max(MVPA1),mean=round(mean(MVPA1),2),
             sd=round(sd(MVPA1),2), median=round(median(MVPA1),2))
y2coed<-ddply(auto1, .(intervention,coedu), summarize,
             min = min(MVPA1), max = max(MVPA1),mean=round(mean(MVPA2),2),
             sd=round(sd(MVPA2),2), median=round(median(MVPA2),2))
y3coed<-ddply(auto1, .(intervention,coedu), summarize,
             min = min(SED1), max = max(SED1),mean=round(mean(SED1),2),
             sd=round(sd(SED1),2), median=round(median(SED1),2))
y4coed<-ddply(auto1, .(intervention,coedu), summarize,
             min = min(SED2), max = max(SED1),mean=round(mean(SED2),2),
             sd=round(sd(SED2),2), median=round(median(SED2),2))  
htmlPrint(y1sex)
intervention sex min max mean sd median
control 0 10 39 24 6 24
control 1 6 80 39 22 40
freechoice 0 10 40 27 8 28
freechoice 1 6 68 36 22 24
prdchoice 0 6 71 21 11 17
prdchoice 1 8 82 37 22 26
htmlPrint(y2sex)
intervention sex min max mean sd median
control 0 10 39 29 11 28
control 1 6 80 35 21 31
freechoice 0 10 40 29 19 22
freechoice 1 6 68 44 24 53
prdchoice 0 6 71 22 11 22
prdchoice 1 8 82 39 20 38
htmlPrint(y3sex)
intervention sex min max mean sd median
control 0 38 77 57 8 56
control 1 7 78 39 23 35
freechoice 0 35 73 52 13 51
freechoice 1 13 79 44 22 52
prdchoice 0 9 84 63 13 67
prdchoice 1 4 81 43 24 52
htmlPrint(y4sex)
intervention sex min max mean sd median
control 0 23 77 51 14 52
control 1 14 78 41 21 44
freechoice 0 11 73 46 23 50
freechoice 1 0 79 32 23 21
prdchoice 0 11 84 59 13 60
prdchoice 1 0 81 39 21 42
htmlPrint(y1coed)
intervention coedu min max mean sd median
control 0 6 38 22 8 23
control 1 14 39 24 6 24
control 2 41 80 59 11 58
freechoice 0 6 48 19 7 19
freechoice 1 28 40 34 4 34
freechoice 2 45 68 60 6 60
prdchoice 0 6 35 19 6 18
prdchoice 1 10 37 22 8 22
prdchoice 2 44 82 62 11 62
htmlPrint(y2coed)
intervention coedu min max mean sd median
control 0 6 38 19 9 18
control 1 14 39 38 7 38
control 2 41 80 52 13 52
freechoice 0 6 48 27 21 16
freechoice 1 28 40 41 12 38
freechoice 2 45 68 62 13 61
prdchoice 0 6 35 23 12 19
prdchoice 1 10 37 25 8 25
prdchoice 2 44 82 58 13 59
htmlPrint(y3coed)
intervention coedu min max mean sd median
control 0 41 78 59 9 59
control 1 38 66 54 7 55
control 2 7 28 17 5 17
freechoice 0 28 79 62 10 64
freechoice 1 35 56 41 6 40
freechoice 2 13 29 20 4 19
prdchoice 0 37 84 63 10 62
prdchoice 1 48 80 64 10 66
prdchoice 2 4 36 16 8 15
htmlPrint(y4coed)
intervention coedu min max mean sd median
control 0 38 78 61 10 62
control 1 23 66 38 6 37
control 2 14 28 23 9 19
freechoice 0 11 79 50 23 57
freechoice 1 13 56 30 12 32
freechoice 2 0 29 16 10 15
prdchoice 0 21 84 57 13 60
prdchoice 1 31 80 57 10 58
prdchoice 2 0 36 18 12 16

check if there are cluster effects, i.e., teacher effect check gender and coeducation effect

MeanMVPA <- ddply(auto1, .(intervention, tchidr), summarize, 
    meanAVPA1=round(mean(MVPA1, trim=0.05),2), meanAVPA2= round(mean(MVPA2, trim = 0.05), 2))


MeanSED <- ddply(auto1, .(intervention, tchidr), summarize, 
    meanAVPA1=round(mean(SED1,trim = 0.05), 2), meanSED2 = round(mean(SED2,trim = 0.05), 2))

htmlPrint(MeanMVPA)
intervention tchidr meanAVPA1 meanAVPA2
control 1 28 26
control 7 24 38
control 8 59 52
control 9 15 12
freechoice 5 20 43
freechoice 12 60 62
freechoice 14 18 14
freechoice 15 34 41
prdchoice 3 16 17
prdchoice 6 62 58
prdchoice 10 21 25
prdchoice 16 21 27
htmlPrint(MeanSED)                          
intervention tchidr meanAVPA1 meanSED2
control 1 54 57
control 7 54 38
control 8 17 23
control 9 65 65
freechoice 5 62 33
freechoice 12 20 16
freechoice 14 62 63
freechoice 15 41 30
prdchoice 3 66 62
prdchoice 6 16 18
prdchoice 10 65 58
prdchoice 16 61 55

## check outcome variable: MVPA2
jFun <- function(x) {
    estCoefs <- coef(lm(MVPA2 ~ intervention + MVPA1, x))
    names(estCoefs) <- c("intercept", "slopex1","slopex2","slopeMVPA1")
    return(estCoefs)
}

## work well for variables: coeducation and student sex
jFun(auto1) 

intercept slopex1 slopex2 slopeMVPA1 5.4145 5.6860 1.4478 0.8403

coed1 <- ddply(auto1, ~coedu, jFun) 
sex1<-ddply(auto1, ~sex, jFun)

htmlPrint(coed1,digits = 2)
coedu intercept slopex1 slopex2 slopeMVPA1
0 -3.90 10.15 7.03 1.06
1 27.15 -1.83 -12.09 0.46
2 -3.35 8.38 2.61 0.95
htmlPrint(sex1,digits = 2)
sex intercept slopex1 slopex2 slopeMVPA1
0 7.50 -1.61 -3.49 0.89
1 2.18 11.65 6.72 0.83
##Try if 
coef<-xtable(coed1)
htmlprint(coef,digits = 2)
## Error: could not find function "htmlprint"
## "teach id"" and "teach sex" don't work using the above function though they are the same type

auto1$tchid<-as.factor(auto1$tchid)
levels(auto1$tchid)

[1] “1” “3” “5” “6” “7” “8” “9” “10” “12” “14” “15” “16”


auto1$tsexr<-as.factor(auto1$tsexr)
levels(auto1$tsexr)

[1] “0” “1”

class(auto1$tchidr)

[1] “factor”

class(auto1$tsexr)

[1] “factor”


ddply(auto1, ~tchid, jFun) 
## Error: contrasts can be applied only to factors with 2 or more levels
ddply(auto1, ~tsex, jFun)                                                
## Error: 'names' attribute [4] must be the same length as the vector [3]

## check outcome variable SED2
jFun2 <- function(x) {
    estCoefs <- coef(lm(SED2 ~ intervention + SED1, x))
    names(estCoefs) <- c("intercept", "slopex1","slopex2","slopeSED1")
    return(estCoefs)
}
jFun2(auto1) 

intercept slopex1 slopex2 slopeSED1 7.4367 -7.9592 -1.4106 0.8077

coed2 <- ddply(auto1, ~coedu, jFun2) 
sex2<-ddply(auto1, ~sex, jFun2)
htmlPrint(coed1,digits = 2)
coedu intercept slopex1 slopex2 slopeMVPA1
0 -3.90 10.15 7.03 1.06
1 27.15 -1.83 -12.09 0.46
2 -3.35 8.38 2.61 0.95
htmlPrint(sex1,digits = 2)
sex intercept slopex1 slopex2 slopeMVPA1
0 7.50 -1.61 -3.49 0.89
1 2.18 11.65 6.72 0.83

## still don't work
ddply(auto1, ~tchidr, jFun2) 
## Error: contrasts can be applied only to factors with 2 or more levels
ddply(auto1, ~tsex, jFun2) 
## Error: 'names' attribute [4] must be the same length as the vector [3]

str(auto1) perception of autonomy: choice, volition, and IPLOC (internal perceived locus of causality) is supposed to mediate the effects of outcome variables Test the firstmediation model: add choice

med1<-lm(chtot_2 ~ intervention + chtot_1 + sex + coedu1+coedu2, auto1)

fitMVPA1<-lm(MVPA2 ~ intervention + MVPA1 + chtot_2, auto1)
fitMVPA2<-lm(MVPA2 ~ intervention + MVPA1 + chtot_2 + sex + coedu1+coedu2, auto1)

fitSED1<-lm(SED2 ~ intervention + SED1 + chtot_2, auto1)
fitSED2<-lm(SED2 ~ intervention + SED1 + chtot_2 + sex + coedu1+coedu2, auto1)

summary(med1)
## 
## Call:
## lm(formula = chtot_2 ~ intervention + chtot_1 + sex + coedu1 + 
##     coedu2, data = auto1)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
##  -9.20  -2.97  -0.42   2.91  11.03 
## 
## Coefficients:
##                        Estimate Std. Error t value Pr(>|t|)    
## (Intercept)              4.9697     0.7607    6.53  4.4e-10 ***
## interventionfreechoice   2.7809     0.7099    3.92  0.00012 ***
## interventionprdchoice    2.3563     0.6898    3.42  0.00076 ***
## chtot_1                  0.1381     0.0723    1.91  0.05752 .  
## sex                     -0.4980     0.7780   -0.64  0.52279    
## coedu1                   1.9029     0.8400    2.27  0.02445 *  
## coedu2                   3.4728     0.7902    4.40  1.7e-05 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 4.3 on 221 degrees of freedom
## Multiple R-squared:  0.188,  Adjusted R-squared:  0.166 
## F-statistic: 8.51 on 6 and 221 DF,  p-value: 2.55e-08
summary(fitMVPA1)
## 
## Call:
## lm(formula = MVPA2 ~ intervention + MVPA1 + chtot_2, data = auto1)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -29.27  -7.72  -1.18   5.88  40.80 
## 
## Coefficients:
##                        Estimate Std. Error t value Pr(>|t|)    
## (Intercept)              3.4968     1.9781    1.77    0.078 .  
## interventionfreechoice   4.5301     1.9332    2.34    0.020 *  
## interventionprdchoice    0.4191     1.8836    0.22    0.824    
## MVPA1                    0.8091     0.0433   18.70   <2e-16 ***
## chtot_2                  0.4266     0.1755    2.43    0.016 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 11.5 on 223 degrees of freedom
## Multiple R-squared:  0.663,  Adjusted R-squared:  0.657 
## F-statistic:  110 on 4 and 223 DF,  p-value: <2e-16
summary(fitMVPA2)
## 
## Call:
## lm(formula = MVPA2 ~ intervention + MVPA1 + chtot_2 + sex + coedu1 + 
##     coedu2, data = auto1)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -29.86  -7.91  -0.90   5.37  46.05 
## 
## Coefficients:
##                        Estimate Std. Error t value Pr(>|t|)    
## (Intercept)             -3.0060     2.7253   -1.10  0.27124    
## interventionfreechoice   4.3558     1.8713    2.33  0.02084 *  
## interventionprdchoice    0.1011     1.8071    0.06  0.95543    
## MVPA1                    0.8983     0.0922    9.74  < 2e-16 ***
## chtot_2                  0.3760     0.1704    2.21  0.02835 *  
## sex                      6.8625     1.9866    3.45  0.00066 ***
## coedu1                   9.3854     2.2074    4.25  3.1e-05 ***
## coedu2                  -5.9345     4.2755   -1.39  0.16654    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 11 on 220 degrees of freedom
## Multiple R-squared:  0.696,  Adjusted R-squared:  0.686 
## F-statistic:   72 on 7 and 220 DF,  p-value: <2e-16
summary(fitSED1)
## 
## Call:
## lm(formula = SED2 ~ intervention + SED1 + chtot_2, data = auto1)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -38.11  -7.29   0.45   8.32  42.15 
## 
## Coefficients:
##                        Estimate Std. Error t value Pr(>|t|)    
## (Intercept)             11.2891     3.1718    3.56  0.00045 ***
## interventionfreechoice  -6.9090     2.1564   -3.20  0.00155 ** 
## interventionprdchoice   -0.4199     2.1157   -0.20  0.84285    
## SED1                     0.7813     0.0441   17.70  < 2e-16 ***
## chtot_2                 -0.3819     0.1963   -1.95  0.05293 .  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 12.8 on 223 degrees of freedom
## Multiple R-squared:  0.645,  Adjusted R-squared:  0.639 
## F-statistic:  101 on 4 and 223 DF,  p-value: <2e-16
summary(fitSED2)
## 
## Call:
## lm(formula = SED2 ~ intervention + SED1 + chtot_2 + sex + coedu1 + 
##     coedu2, data = auto1)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -43.41  -6.78   0.57   6.66  34.18 
## 
## Coefficients:
##                        Estimate Std. Error t value Pr(>|t|)    
## (Intercept)             20.3240     5.6265    3.61  0.00038 ***
## interventionfreechoice  -6.7620     2.0406   -3.31  0.00108 ** 
## interventionprdchoice    0.2981     2.0039    0.15  0.88189    
## SED1                     0.7399     0.0856    8.65  1.1e-15 ***
## chtot_2                 -0.2954     0.1863   -1.59  0.11426    
## sex                     -9.3822     2.1626   -4.34  2.2e-05 ***
## coedu1                 -13.3899     2.4083   -5.56  7.8e-08 ***
## coedu2                   0.0428     4.3082    0.01  0.99209    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 12 on 220 degrees of freedom
## Multiple R-squared:  0.693,  Adjusted R-squared:  0.684 
## F-statistic: 71.1 on 7 and 220 DF,  p-value: <2e-16