Skip to content

Commit

Permalink
Merge pull request #183 from LCBC-UiO/dev
Browse files Browse the repository at this point in the history
Small fixes
  • Loading branch information
osorensen authored Apr 4, 2024
2 parents 8a2dc5d + 82e581a commit 5be856c
Show file tree
Hide file tree
Showing 17 changed files with 22 additions and 63 deletions.
1 change: 1 addition & 0 deletions R/data.R
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@
#' \item{domain}{Cognitive domain being measured. One of \code{"epmem"} for
#' episodic memory, \code{"wmem"} for working memory and \code{"execfun"} for
#' executive function/speed.}
#' \item{timepoint}{Integer indicating the timepoint number.}
#' \item{age}{Age of participant at the timepoint.}
#' \item{test}{The particular test at this observation.}
#' \item{y}{Response. For \code{"epmem"} and \code{"wmem"} this is the number
Expand Down
5 changes: 3 additions & 2 deletions R/gamm4-functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -425,8 +425,9 @@ gamm4.wrapup <- function(gobj, ret, final_model) {
}

object$fitted.values <- fitted(ret)
object$linear.predictors <- vapply(object$family_mapping, function(i) {
object$family[[i]]$linkfun(object$fitted.values[[i]])
object$linear.predictors <- vapply(seq_along(object$family_mapping), function(i) {
family_index <- object$family_mapping[[i]]
object$family[[family_index]]$linkfun(object$fitted.values[[i]])
}, numeric(1))

object$residuals <- residuals(ret$mer)
Expand Down
5 changes: 3 additions & 2 deletions data-raw/lifespan.R
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,11 @@ lifespan <- tibble(
y = case_when(
domain == "execfun" ~ -(y - mean(y)) / sd(y),
TRUE ~ y
)
),
id = factor(id)
) %>%
ungroup() %>%
select(-nu, -timepoint) %>%
select(-nu) %>%
as.data.frame()

mm <- model.matrix(~ 0 + domain, data = lifespan)
Expand Down
Binary file modified data/lifespan.rda
Binary file not shown.
1 change: 1 addition & 0 deletions man/lifespan.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 1 addition & 6 deletions vignettes/glmm_factor.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -347,11 +347,6 @@ In this case we can confirm that the `galamm` function is correctly implemented
```r
library(lme4)
#> Loading required package: Matrix
#>
#> Attaching package: 'lme4'
#> The following object is masked from 'package:galamm':
#>
#> llikAIC
count_mod_lme4 <- glmer(
formula = y ~ lbas * treat + lage + v4 + (1 | subj),
data = epilep,
Expand Down Expand Up @@ -395,7 +390,7 @@ summary(count_mod_lme4)
#> (Intercept) 1.7937 0.1045 17.165 < 2e-16 ***
#> lbas 0.8844 0.1308 6.764 1.34e-11 ***
#> treat -0.3349 0.1474 -2.272 0.02311 *
#> lage 0.4845 0.3458 1.401 0.16121
#> lage 0.4845 0.3458 1.401 0.16122
#> v4 -0.1611 0.0543 -2.966 0.00301 **
#> lbas:treat 0.3382 0.2025 1.671 0.09479 .
#> ---
Expand Down
Binary file modified vignettes/glmm_factor_poisson_diagnostic_lme4-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 0 additions & 20 deletions vignettes/mixed_response.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,6 @@ summary(mixed_resp)
#> AIC BIC logLik deviance df.resid
#> 9248.7 9280.2 -4619.3 3633.1 3995
#>
#> Scaled residuals:
#> Min 1Q Median 3Q Max
#> -3.5360 -0.7078 0.2156 0.6456 2.5978
#>
#> Lambda:
#> level SE
#> lambda1 1.000 .
Expand Down Expand Up @@ -179,10 +175,6 @@ summary(mod)
#> AIC BIC logLik deviance df.resid
#> 12356.9 12388.3 -6173.4 31426.4 3995
#>
#> Scaled residuals:
#> Min 1Q Median 3Q Max
#> -15.2275 -0.4025 0.1262 0.6757 16.0284
#>
#> Random effects:
#> Groups Name Variance Std.Dev.
#> id (Intercept) 0 0
Expand Down Expand Up @@ -353,10 +345,6 @@ summary(mod)
#> AIC BIC logLik deviance df.resid
#> 2837.6 2892.9 -1406.8 12529.3 730
#>
#> Scaled residuals:
#> Min 1Q Median 3Q Max
#> -10.1375 -0.4389 -0.3522 0.2743 27.3350
#>
#> Lambda:
#> loading SE
#> lambda1 1.000 .
Expand Down Expand Up @@ -472,10 +460,6 @@ summary(mod)
#> AIC BIC logLik deviance df.resid
#> 2768.3 2823.6 -1372.2 2002.9 730
#>
#> Scaled residuals:
#> Min 1Q Median 3Q Max
#> -258547 -1 0 0 66
#>
#> Lambda:
#> loading SE
#> lambda1 1.0000 .
Expand Down Expand Up @@ -567,10 +551,6 @@ summary(mod0)
#> AIC BIC logLik deviance df.resid
#> 2764.0 2805.5 -1373.0 2007.9 733
#>
#> Scaled residuals:
#> Min 1Q Median 3Q Max
#> -280306 -1 0 0 66
#>
#> Lambda:
#> loading SE
#> lambda1 1.000 .
Expand Down
36 changes: 10 additions & 26 deletions vignettes/optimization.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,6 @@ summary(mod)
#> AIC BIC logLik deviance df.resid
#> 2837.6 2892.9 -1406.8 12529.3 730
#>
#> Scaled residuals:
#> Min 1Q Median 3Q Max
#> -10.1375 -0.4389 -0.3522 0.2743 27.3350
#>
#> Lambda:
#> loading SE
#> lambda1 1.000 .
Expand Down Expand Up @@ -213,10 +209,6 @@ summary(mod)
#> AIC BIC logLik deviance df.resid
#> 2837.6 2892.9 -1406.8 12529.3 730
#>
#> Scaled residuals:
#> Min 1Q Median 3Q Max
#> -10.1374 -0.4390 -0.3523 0.2743 27.3347
#>
#> Lambda:
#> loading SE
#> lambda1 1.000 .
Expand Down Expand Up @@ -292,10 +284,6 @@ summary(mod)
#> AIC BIC logLik deviance df.resid
#> 2768.3 2823.6 -1372.2 2002.9 730
#>
#> Scaled residuals:
#> Min 1Q Median 3Q Max
#> -258522 -1 0 0 66
#>
#> Lambda:
#> loading SE
#> lambda1 1.0000 .
Expand Down Expand Up @@ -391,10 +379,6 @@ summary(mod_nm)
#> AIC BIC logLik deviance df.resid
#> 2768.3 2823.6 -1372.2 2002.9 730
#>
#> Scaled residuals:
#> Min 1Q Median 3Q Max
#> -258524 -1 0 0 66
#>
#> Lambda:
#> loading SE
#> lambda1 1.0000 .
Expand All @@ -407,16 +391,16 @@ summary(mod_nm)
#> Number of obs: 742, groups: id, 333
#>
#> Fixed effects:
#> Estimate Std. Error z value Pr(>|z|)
#> chd -1.91525 0.27229 -7.03373 2.011e-12
#> fiber 17.94851 0.48686 36.86604 1.618e-297
#> fiber2 0.22398 0.41783 0.53604 5.919e-01
#> chd:age 0.06614 0.05931 1.11527 2.647e-01
#> chd:bus -0.02893 0.34355 -0.08421 9.329e-01
#> fiber:age -0.21203 0.10090 -2.10130 3.561e-02
#> fiber:bus -1.68305 0.63721 -2.64126 8.260e-03
#> chd:age:bus -0.04998 0.06507 -0.76815 4.424e-01
#> fiber:age:bus 0.16817 0.11223 1.49847 1.340e-01
#> Estimate Std. Error z value Pr(>|z|)
#> chd -1.91525 0.27229 -7.0337 2.011e-12
#> fiber 17.94851 0.48686 36.8660 1.618e-297
#> fiber2 0.22398 0.41783 0.5360 5.919e-01
#> chd:age 0.06614 0.05931 1.1153 2.647e-01
#> chd:bus -0.02893 0.34355 -0.0842 9.329e-01
#> fiber:age -0.21203 0.10090 -2.1013 3.561e-02
#> fiber:bus -1.68305 0.63721 -2.6413 8.260e-03
#> chd:age:bus -0.04998 0.06507 -0.7682 4.424e-01
#> fiber:age:bus 0.16817 0.11223 1.4985 1.340e-01
```


Expand Down
Binary file modified vignettes/scaling-glmm-plot-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified vignettes/scaling-hsced-plot-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified vignettes/scaling-lmm-plot-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified vignettes/scaling-semiparametric-binomial-plot-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified vignettes/scaling-semiparametric-gaussian-plot-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified vignettes/semiparametric-mixed-by-factor1-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified vignettes/semiparametric-mixed-by-factor2-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 3 additions & 7 deletions vignettes/semiparametric.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -779,10 +779,6 @@ summary(mod_byvar_mixed)
#> AIC BIC logLik deviance df.resid
#> 9476.1 9566.9 -4725.0 98981.3 7987
#>
#> Scaled residuals:
#> Min 1Q Median 3Q Max
#> -13.543 0.426 1.987 6.127 18.637
#>
#> Lambda:
#> ability1 SE ability2 SE
#> lambda1 1.0000 . . .
Expand All @@ -807,9 +803,9 @@ summary(mod_byvar_mixed)
#> s(x):domain2:ability2Fx1 2.10045 0.47649 4.4082 1.042e-05
#>
#> Approximate significance of smooth terms:
#> edf Ref.df F p-value
#> s(x):domain1:ability1 7.865 7.865 880 <2e-16
#> s(x):domain2:ability2 6.442 6.442 8007 <2e-16
#> edf Ref.df F p-value
#> s(x):domain1:ability1 7.865 7.865 880 <2e-16
#> s(x):domain2:ability2 3.036 3.036 285 <2e-16
```

We can plot the estimated smooth terms:
Expand Down

0 comments on commit 5be856c

Please sign in to comment.