Enjoyment and PC in three classroom contexts

Author

N Foldnes

Missing

knitr::opts_chunk$set(echo=FALSE, message=FALSE, warning=FALSE
)
suppressPackageStartupMessages(library(tidyverse, quietly=T)); library(haven); library(knitr)
mydata <-  read_sav("Datasett Rebekka 2.sav")
mydata[!complete.cases(mydata),]
# A tibble: 7 × 5
  ID    gender    context            PC Enjoyment
  <chr> <dbl+lbl> <dbl+lbl>       <dbl>     <dbl>
1 3     0 [Jente] 3 [friluftsliv] NA           NA
2 7     0 [Jente] 3 [friluftsliv] NA           NA
3 17    0 [Jente] 3 [friluftsliv] NA           NA
4 25    0 [Jente] 1 [basketball]  NA           NA
5 29    0 [Jente] 3 [friluftsliv] NA           NA
6 16    1 [Gutt]  2 [dans]        NA           NA
7 36    1 [Gutt]  3 [friluftsliv]  4.75        NA
mydata$context <- factor(mydata$context, labels=c("basket", "dance", "free"))
mydata$context <- relevel(mydata$context, "free")
naniar::vis_miss(mydata)

Mean levels of PC and Enjoyment across contexts and gender

Mean score plot

Independent Regressions

Mixed modeling

Our data contains three measurement contexts/conditions, so we can try to model this as a 2-level model he

  • Level 2: Students
  • Level 1: Measurement context

Fixed effects: direct effect of context and of PC, and their interaction

Random effect:

Linear mixed model fit by REML ['lmerMod']
Formula: Enjoyment ~ context * PC + (PC | ID)
   Data: mydata

REML criterion at convergence: 179.2

Scaled residuals: 
     Min       1Q   Median       3Q      Max 
-2.35530 -0.48461  0.06902  0.49766  2.46933 

Random effects:
 Groups   Name        Variance Std.Dev. Corr
 ID       (Intercept) 0.00000  0.0000       
          PC          0.01407  0.1186    NaN
 Residual             0.17849  0.4225       
Number of obs: 104, groups:  ID, 37

Fixed effects:
                 Estimate Std. Error t value
(Intercept)       2.11411    0.71348   2.963
contextbasket     0.15591    0.83557   0.187
contextdance     -0.37004    0.78765  -0.470
PC                0.41347    0.17367   2.381
contextbasket:PC -0.02756    0.20686  -0.133
contextdance:PC   0.09394    0.19709   0.477

Correlation of Fixed Effects:
            (Intr) cntxtb cntxtd PC     cntxtb:PC
contextbskt -0.786                               
contextdanc -0.886  0.703                        
PC          -0.988  0.776  0.876                 
cntxtbsk:PC  0.759 -0.991 -0.679 -0.759          
cntxtdnc:PC  0.849 -0.674 -0.989 -0.850  0.660   
optimizer (nloptwrap) convergence code: 0 (OK)
boundary (singular) fit: see help('isSingular')

For reference: The crude method of just ignoring nestin


Call:
lm(formula = Enjoyment ~ context * PC, data = mydata)

Residuals:
     Min       1Q   Median       3Q      Max 
-2.25438 -0.36914  0.04142  0.41459  1.36069 

Coefficients:
                  Estimate Std. Error t value Pr(>|t|)   
(Intercept)       2.359564   0.888510   2.656  0.00924 **
contextbasket     0.071745   1.111378   0.065  0.94866   
contextdance     -1.016778   1.014859  -1.002  0.31886   
PC                0.354964   0.213265   1.664  0.09922 . 
contextbasket:PC -0.005934   0.273372  -0.022  0.98273   
contextdance:PC   0.268829   0.252436   1.065  0.28952   
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 0.6353 on 98 degrees of freedom
  (7 observations deleted due to missingness)
Multiple R-squared:  0.2455,    Adjusted R-squared:  0.207 
F-statistic: 6.379 on 5 and 98 DF,  p-value: 3.604e-05