GALMj version ≥ 2.4.0

# Introduction

GAMLj module can be installed and used in R as a standard R packages. Please check the R help for details. Here we provide some appliactions of the package in R.

# Installation

At the moment, GAMLj is not in CRAN yet, so you need to install it via devtools

devtools::install_github("gamlj/gamlj")

## General Linear Model

### Description

General Linear Model. Estimates models using ‘lm()’ function and provides options to facilitate estimation of
interactions, simple slopes, simple effects, post-hoc tests, contrast analysis, effect size indexes and visualization of the results.

### Usage


gamljGlm(
data,
formula,
dep = NULL,
factors = NULL,
covs = NULL,
modelTerms = NULL,
fixedIntercept = TRUE,
showParamsCI = TRUE,
paramCIWidth = 95,
contrasts = NULL,
showRealNames = TRUE,
showContrastCode = FALSE,
plotHAxis = NULL,
plotSepLines = NULL,
plotSepPlots = NULL,
plotRaw = FALSE,
plotDvScale = FALSE,
plotError = "none",
ciWidth = 95,
postHoc = NULL,
eDesc = FALSE,
eCovs = FALSE,
simpleVariable = NULL,
simpleModerator = NULL,
simple3way = NULL,
simpleScale = "mean_sd",
cvalue = 1,
percvalue = 25,
simpleScaleLabels = "labels",
postHocCorr = list("bonf"),
scaling = NULL,
effectSize = list("beta", "partEta"),
homoTest = FALSE,
qq = FALSE,
normTest = FALSE,
normPlot = FALSE,
residPlot = FALSE,
interceptInfo = FALSE,
effectSizeInfo = FALSE,
dep_scale = "none"
)


### Arguments

 data the data as a data frame formula (optional) an object of class formula (or one that can be coerced to that class): a symbolic description of the model to be fitted. dep a string naming the dependent variable; the variable must be numeric. Not needed if formula is used. factors a vector of strings naming the fixed factors. Not needed if formula is used. covs a vector of strings naming the covariates (continuous variables). Not needed if formula is used. modelTerms a list of character vectors describing fixed effects terms. Not needed if formula is used. fixedIntercept TRUE (default) or FALSE, estimates fixed intercept. Not needed if formula is used. showParamsCI TRUE (default) or FALSE , parameters CI in tables paramCIWidth a number between 50 and 99.9 (default: 95) specifying the confidence interval width for the parameter estimates contrasts a named vector of the form c(var1=‘type’, var2=‘type2’) specifying the type of contrast to use, one of ‘deviation’, ‘simple’, ‘dummy’, ‘difference’, ‘helmert’, ‘repeated’ or ‘polynomial’. If NULL, ‘simple’ is used. Can also be passed as a list of list of the form list(list(var=‘var1’,type=‘type1’)). showRealNames TRUE or FALSE (default), shows raw names of the contrasts variables showContrastCode TRUE or FALSE (default), shows contrast coefficients tables plotHAxis a string naming the variable placed on the horizontal axis of the plot plotSepLines a string naming the variable represented as separate lines in the plot plotSepPlots a string naming the variable defining the levels for multiple plots plotRaw TRUE or FALSE (default), plot raw data along the predicted values plotDvScale TRUE or FALSE (default), set the Y-axis range equal to the range of the observed values. plotError ‘none’ (default), ‘ci’, or ‘se’. Use no error bars, use confidence intervals, or use standard errors on the plots, respectively. ciWidth a number between 50 and 99.9 (default: 95) specifying the confidence interval width for the plots. postHoc a rhs formula with the terms specifying the table to apply the comparisons (of the form ‘~x+x:z’ eDesc TRUE or FALSE (default), provide lsmeans statistics eCovs TRUE or FALSE (default), provide lsmeans statistics conditioned to different values of the continuous variables in the model. Which levels of the continuous variable should be used is set by the simpleScale option. simpleVariable The variable for which the simple effects (slopes) are computed simpleModerator the variable that provides the levels at which the simple effects are computed simple3way a moderator of the two-way interaction which is probed simpleScale ‘mean_sd’ (default), ‘custom’ , or ‘percent’. Use to condition the covariates (if any) cvalue how many st.deviations around the means used to condition simple effects and plots. Used if simpleScale=‘mean_sd’ percvalue offsett (number of percentiles) around the median used to condition simple effects and plots. Used if simpleScale=‘percent’ simpleScaleLabels how the levels of a continuous moderator should appear in tables and plots: labels, values and values_labels. postHocCorr one or more of ‘none’, ‘bonf’, or ‘holm’; provide no, Bonferroni, and Holm Post Hoc corrections respectively. scaling a named vector of the form c(var1=‘type1’,var2=‘type2’). Types are ‘centered’ to the mean, ‘standardized’, log-transformed ‘log’ or ‘none’. ‘none’ leaves the variable as it is. It can also be passed as a list of lists. effectSize a list of effect sizes to print out. They can be: ‘eta’ for eta-squared, ‘partEta’ for partial eta-squared, ‘omega’ for partial omega-squared, ‘epsilon’ for partial epsilon-squared, and ‘beta’ for standardized coefficients (betas). Default is beta and partEta. homoTest TRUE or FALSE (default), perform homogeneity tests qq TRUE or FALSE (default), provide a Q-Q plot of residuals normTest TRUE or FALSE (default), provide a test for normality of residuals normPlot TRUE or FALSE (default), provide a histogram of residuals superimposed by a normal distribution residPlot TRUE or FALSE (default), provide a scatterplot of the residuals against predicted interceptInfo TRUE or FALSE (default), provide ìnformation about the intercept (F test, effect size indexes) effectSizeInfo TRUE or FALSE (default), provide ìnformation about the effect size indexes dep_scale Re-scale the dependent variable. It can be ‘centered’ to the mean, ‘standardized’, log-transformed ‘log’ or ‘none’. ‘none’ (default) leaves the variable as it is.

### Examples


data('ToothGrowth')
gamlj::gamljGlm(formula = len ~ supp,  data = ToothGrowth)


## Generalized Mixed Models

### Description

Generalized Mixed Linear Model. Estimates models using ‘lme4::glmer()’ function and provides options to facilitate estimation of
interactions, simple slopes, simple effects, post-hoc tests, contrast analysis, effect size indexes and visualization of the results.

### Usage


gamljGlmMixed(
data,
formula = NULL,
dep = NULL,
factors = NULL,
covs = NULL,
modelTerms = NULL,
fixedIntercept = TRUE,
showParamsCI = FALSE,
showExpbCI = TRUE,
paramCIWidth = 95,
contrasts = NULL,
showRealNames = TRUE,
showContrastCode = FALSE,
plotHAxis = NULL,
plotSepLines = NULL,
plotSepPlots = NULL,
plotRaw = FALSE,
plotDvScale = FALSE,
plotError = "none",
ciWidth = 95,
postHoc = NULL,
eDesc = FALSE,
eCovs = FALSE,
simpleVariable = NULL,
simpleModerator = NULL,
simple3way = NULL,
simpleScale = "mean_sd",
cvalue = 1,
percvalue = 25,
simpleScaleLabels = "labels",
postHocCorr = list("bonf"),
scaling = NULL,
cluster = NULL,
randomTerms = list(list()),
correlatedEffects = "corr",
plotRandomEffects = FALSE,
plotLinearPred = FALSE,
nAGQ = 1,
effectSize = list("expb"),
modelSelection = "logistic",
custom_family = "gaussian",
custom_link = "identity",
cimethod = "wald"
)


### Arguments

 data the data as a data frame formula (optional) the formula to use. The syntax is the same used in [lme4::lmer()]. See the examples dep a string naming the dependent variable from data, variable must be numeric factors a vector of strings naming the fixed factors from data covs a vector of strings naming the covariates from data modelTerms a list of character vectors describing fixed effects terms fixedIntercept TRUE (default) or FALSE, estimates fixed intercept showParamsCI TRUE (default) or FALSE , parameters CI in table showExpbCI TRUE (default) or FALSE , exp(B) CI in table paramCIWidth a number between 50 and 99.9 (default: 95) specifying the confidence interval width for the parameter estimates contrasts a named vector of the form c(var1=‘type’, var2=‘type2’) specifying the type of contrast to use, one of ‘deviation’, ‘simple’, ‘dummy’, ‘difference’, ‘helmert’, ‘repeated’ or ‘polynomial’. If NULL, ‘simple’ is used. Can also be passed as a list of list of the form list(list(var=‘var1’,type=‘type1’)). showRealNames TRUE or FALSE (default), provide raw names of the contrasts variables showContrastCode TRUE or FALSE (default), provide contrast coefficients tables plotHAxis a string naming the variable placed on the horizontal axis of the plot plotSepLines a string naming the variable represented as separate lines on the plot plotSepPlots the variable for whose levels multiple plots are computed plotRaw TRUE or FALSE (default), provide descriptive statistics plotDvScale TRUE or FALSE (default), scale the plot Y-Axis to the max and the min of the dependent variable observed scores. plotError ‘none’, ‘ci’ (default), or ‘se’. Use no error bars, use confidence intervals, or use standard errors on the plots, respectively ciWidth a number between 50 and 99.9 (default: 95) specifying the confidence interval width postHoc a list of terms to perform post-hoc tests on eDesc TRUE or FALSE (default), provide lsmeans statistics eCovs TRUE or FALSE (default), provide lsmeans statistics simpleVariable The variable for which the simple effects (slopes) are computed simpleModerator the variable that provides the levels at which the simple effects computed simple3way a moderator of the two-way interaction which is probed simpleScale ‘mean_sd’ (default), ‘custom’ , or ‘custom_percent’. Use to condition the covariates (if any) cvalue offset value for conditioning percvalue offset value for conditioning simpleScaleLabels decide the labeling of simple effects in tables and plots. labels indicates that only labels are used, such as Mean and Mean + 1 SD. values uses the actual values as labels. values_labels uses both. postHocCorr one or more of ‘none’, ‘bonf’, or ‘holm’; provide no, Bonferroni, and Holm Post Hoc corrections respectively scaling a named vector of the form c(var1=‘type1’,var2=‘type2’). Types are ‘centered’ to the mean, ‘clusterbasedcentered’ to the mean of each cluster, ‘standardized’, ‘clusterbasedstandardized’ standardized within each cluster, log-transformed ‘log’, or ‘none’. ‘none’ leaves the variable as it is. It can also be passed as a list of lists. cluster a vector of strings naming the clustering variables from data randomTerms a list of lists specifying the models random effects. correlatedEffects ‘nocorr’, ‘corr’ (default), or ‘block’. When random effects are passed as list of length 1, it decides whether the effects should be correlated, non correlated. If ‘randomTerms’ is a list of lists of length > 1, the option is automatially set to ‘block’. The option is ignored if the model is passed using formula. plotRandomEffects TRUE or FALSE (default), add random effects predicted values in the plot plotLinearPred TRUE or FALSE (default), plot the predicted values in the linear predictor scale. If set, plotRaw and plotDvScale are ignored. nAGQ for the adaptive Gauss-Hermite log-likelihood approximation, nAGQ argument controls the number of nodes in the quadrature formula. A positive integer effectSize . modelSelection Select the generalized linear model: linear,poisson,logistic,nb, the latest being Negative Binomial custom_family Distribution family for the custom model, accepts gaussian, binomial, gamma and inverse_gaussian . custom_link Distribution family for the custom model, accepts identity, log and inverse, onemu2 (for 1/mu^2). cimethod .

### Examples


data(subjects_by_stimuli)
gamlj::gamljMixed(
formula = y ~ 1 + cond+( 1|subj ),
data = subjects_by_stimuli)
gamlj::gamljMixed(
data = subjects_by_stimuli,
dep = "y",
factors = "cond",
modelTerms = "cond",
cluster = "subj",
randomTerms=list(list(c("cond","subj"))))



## Generalized Linear Models

### Description

Generalized Linear Models. Estimates models using ‘glm()’ function and similar functions. It provides options to facilitate estimation of
interactions, simple slopes, simple effects, post-hoc tests, contrast analysis, effect size indexes and visualization of the results.

### Usage


gamljGzlm(
data,
dep,
factors = NULL,
covs = NULL,
modelTerms = NULL,
fixedIntercept = TRUE,
showParamsCI = FALSE,
showExpbCI = TRUE,
paramCIWidth = 95,
contrasts = NULL,
showRealNames = TRUE,
showContrastCode = FALSE,
plotHAxis = NULL,
plotSepLines = NULL,
plotSepPlots = NULL,
plotRaw = FALSE,
plotDvScale = FALSE,
plotError = "none",
ciWidth = 95,
postHoc = NULL,
eDesc = FALSE,
eCovs = FALSE,
simpleVariable = NULL,
simpleModerator = NULL,
simple3way = NULL,
simpleScale = "mean_sd",
cvalue = 1,
percvalue = 25,
simpleScaleLabels = "labels",
postHocCorr = list("bonf"),
scaling = NULL,
effectSize = list("expb"),
modelSelection = "linear",
custom_family = "gaussian",
custom_link = "identity",
formula
)


### Arguments

 data the data as a data frame dep a string naming the dependent variable from data, variable can be numeric or factor factors a vector of strings naming the fixed factors from data covs a vector of strings naming the covariates from data modelTerms a list of character vectors describing fixed effects terms fixedIntercept TRUE (default) or FALSE, estimates fixed intercept showParamsCI TRUE or FALSE (default), parameters CI in table showExpbCI TRUE (default) or FALSE , exp(B) CI in table paramCIWidth a number between 50 and 99.9 (default: 95) specifying the confidence interval width for the parameter estimates contrasts a named vector of the form c(var1=‘type’, var2=‘type2’) specifying the type of contrast to use, one of ‘deviation’, ‘simple’, ‘dummy’, ‘difference’, ‘helmert’, ‘repeated’ or ‘polynomial’. If NULL, ‘simple’ is used. Can also be passed as a list of list of the form list(list(var=‘var1’,type=‘type1’)). showRealNames TRUE or FALSE (default), provide raw names of the contrasts variables showContrastCode TRUE or FALSE (default), provide contrast coefficients tables plotHAxis a string naming the variable placed on the horizontal axis of the plot plotSepLines a string naming the variable represented as separate lines on the plot plotSepPlots a string naming the variable to separate over to form multiple plots plotRaw TRUE or FALSE (default), provide descriptive statistics plotDvScale . plotError ‘none’, ‘ci’ (default), or ‘se’. Use no error bars, use confidence intervals, or use standard errors on the plots, respectively ciWidth a number between 50 and 99.9 (default: 95) specifying the confidence interval width postHoc a list of terms to perform post-hoc tests on eDesc TRUE or FALSE (default), provide lsmeans statistics eCovs TRUE or FALSE (default), provide lsmeans statistics simpleVariable The variable for which the simple effects (slopes) are computed simpleModerator the variable that provides the levels at which the simple effects computed simple3way a moderator of the two-way interaction which is probed simpleScale ‘mean_sd’ (default), ‘custom’ , or ‘custom_percent’. Use to condition the covariates (if any) cvalue offset value for conditioning percvalue offset value for conditioning simpleScaleLabels style for presenting condition values of a moderator. It can be ‘labels’ (default), ‘values’ or ‘labels_values’ for both. postHocCorr one or more of ‘none’, ‘bonf’, or ‘holm’; provide no, Bonferroni, and Holm Post Hoc corrections respectively scaling a named vector of the form c(var1=‘type1’,var2=‘type2’). Types are ‘centered’ to the mean, ‘standardized’, log-transformed ‘log’ or ‘none’. ‘none’ leaves the variable as it is. It can also be passed as a list of lists. effectSize . modelSelection Select the generalized linear model: linear,poisson,logistic,multinomial custom_family Distribution family for the custom model, accepts gaussian, binomial, gamma and inverse_gaussian . custom_link Distribution family for the custom model, accepts identity, log and inverse, onemu2 (for 1/mu^2). formula (optional) the formula to use, see the examples

### Examples


data<-emmeans::neuralgia
gamlj::gamljGzlm(
formula = Pain ~ Duration,
data = data,
modelSelection = "logistic")


## Mixed Model

### Description

Mixed Linear Model. Estimates models using ‘me4::lmer()’ function and provides options to facilitate estimation of
interactions, simple slopes, simple effects, post-hoc tests, contrast analysis, effect size indexes and visualization of the results.

### Usage


gamljMixed(
data,
dep = NULL,
factors = NULL,
covs = NULL,
modelTerms = NULL,
fixedIntercept = TRUE,
showParamsCI = TRUE,
paramCIWidth = 95,
ciRE = FALSE,
contrasts = NULL,
showRealNames = TRUE,
showContrastCode = FALSE,
plotHAxis = NULL,
plotSepLines = NULL,
plotSepPlots = NULL,
plotRaw = FALSE,
plotDvScale = FALSE,
plotError = "none",
ciWidth = 95,
postHoc = NULL,
eDesc = FALSE,
eCovs = FALSE,
simpleVariable = NULL,
simpleModerator = NULL,
simple3way = NULL,
simpleScale = "mean_sd",
cvalue = 1,
percvalue = 25,
simpleScaleLabels = "labels",
postHocCorr = list("bonf"),
scaling = NULL,
dep_scale = "none",
cluster = NULL,
randomTerms = list(list()),
correlatedEffects = "corr",
reml = TRUE,
lrtRandomEffects = FALSE,
plotRandomEffects = FALSE,
cimethod = "wald",
dfmethod = "Satterthwaite",
qq = FALSE,
normTest = FALSE,
normPlot = FALSE,
residPlot = FALSE,
clusterBoxplot = FALSE,
randHist = FALSE,
formula
)


### Arguments

 data the data as a data frame dep a string naming the dependent variable from data, variable must be numeric factors a vector of strings naming the fixed factors from data covs a vector of strings naming the covariates from data modelTerms a list of character vectors describing fixed effects terms fixedIntercept TRUE (default) or FALSE, estimates fixed intercept showParamsCI TRUE (default) or FALSE , parameters CI in table paramCIWidth a number between 50 and 99.9 (default: 95) specifying the confidence interval width for the parameter estimates ciRE TRUE or FALSE (default), produce random effects confidence intervals based on profile method contrasts a named vector of the form c(var1=‘type’, var2=‘type2’) specifying the type of contrast to use, one of ‘deviation’, ‘simple’, ‘dummy’, ‘difference’, ‘helmert’, ‘repeated’ or ‘polynomial’. If NULL, ‘simple’ is used. Can also be passed as a list of list of the form list(list(var=‘var1’,type=‘type1’)). showRealNames TRUE or FALSE (default), provide raw names of the contrasts variables showContrastCode TRUE or FALSE (default), provide contrast coefficients tables plotHAxis a string naming the variable placed on the horizontal axis of the plot plotSepLines a string naming the variable represented as separate lines on the plot plotSepPlots the variable for whose levels multiple plots are computed plotRaw TRUE or FALSE (default), provide descriptive statistics plotDvScale TRUE or FALSE (default), scale the plot Y-Axis to the max and the min of the dependent variable observed scores. plotError ‘none’, ‘ci’ (default), or ‘se’. Use no error bars, use confidence intervals, or use standard errors on the plots, respectively ciWidth a number between 50 and 99.9 (default: 95) specifying the confidence interval width postHoc a list of terms to perform post-hoc tests on eDesc TRUE or FALSE (default), provide lsmeans statistics eCovs TRUE or FALSE (default), provide lsmeans statistics simpleVariable The variable for which the simple effects (slopes) are computed simpleModerator the variable that provides the levels at which the simple effects computed simple3way a moderator of the two-way interaction which is probed simpleScale ‘mean_sd’ (default), ‘custom’ , or ‘custom_percent’. Use to condition the covariates (if any) cvalue offset value for conditioning percvalue offset value for conditioning simpleScaleLabels decide the labeling of simple effects in tables and plots. labels indicates that only labels are used, such as Mean and Mean + 1 SD. values uses the actual values as labels. values_labels uses both. postHocCorr one or more of ‘none’, ‘bonf’, or ‘holm’; provide no, Bonferroni, and Holm Post Hoc corrections respectively scaling a named vector of the form c(var1=‘type1’,var2=‘type2’). Types are ‘centered’ to the mean, ‘clusterbasedcentered’ to the mean of each cluster, ‘standardized’, ‘clusterbasedstandardized’ standardized within each cluster, log-transformed ‘log’, or ‘none’. ‘none’ leaves the variable as it is. It can also be passed as a list of lists. dep_scale Re-scale the dependent variable. It could be ‘centered’ to the mean, ‘clusterbasedcentered’ to the mean of each cluster, ‘standardized’, ‘clusterbasedstandardized’ standardized within each cluster, log-transformed ‘log’, or ‘none’ (default). cluster a vector of strings naming the clustering variables from data randomTerms a list of lists specifying the models random effects. correlatedEffects ‘nocorr’, ‘corr’ (default), or ‘block’. When random effects are passed as list of length 1, it decides whether the effects should be correlated, non correlated. If ‘randomTerms’ is a list of lists of length > 1, the option is automatially set to ‘block’. The option is ignored if the model is passed using formula. reml TRUE (default) or FALSE, should the Restricted ML be used rather than ML lrtRandomEffects TRUE or FALSE (default), LRT for the random effects plotRandomEffects TRUE or FALSE (default), add random effects predicted values in the plot cimethod . dfmethod . qq TRUE or FALSE (default), provide a Q-Q plot of residuals normTest TRUE or FALSE (default), provide a test for normality of residuals normPlot TRUE or FALSE (default), provide a histogram of residuals superimposed by a normal distribution residPlot TRUE or FALSE (default), provide a scatterplot of the residuals against predicted clusterBoxplot TRUE or FALSE (default), provide a boxplot of random effects by the first defined clustering variable randHist TRUE or FALSE (default), provide histogram of random Coefficients formula (optional) the formula to use, see the examples#’

### Examples


data(subjects_by_stimuli)
gamlj::gamljMixed(
formula = y ~ 1 + cond+( 1|subj ),
data = subjects_by_stimuli)
gamlj::gamljMixed(
data = subjects_by_stimuli,
dep = "y",
factors = "cond",
modelTerms = "cond",
cluster = "subj",
randomTerms=list(list(c("cond","subj"))))



## Assumptions checking plots

### Description

This function returns a list of plots as a ggplot objects produced by the assumptions checking options, such as ‘residPlot’, ‘normPlot’ (for continuous dependent variable models), ‘randHist’ and ‘clusterBoxplot’ (for mixed models).

### Usage


gamlj_assumptionsPlots(object)


### Arguments

 object a gamlj results object of the class ’gamlj*Results“

### Author(s)

Marcello Gallucci

## Extract data

### Description

This function returns a dataset with the variables in the GAMLj model
transformed according to GAMLj options. It is usefull to run additional
models with other R packages with the same setup used by GAMLj

### Usage


gamlj_data(object)


### Arguments

 object a gamlj results object of the class ’gamlj*Results’

### Author(s)

Marcello Gallucci

### Examples


data('qsport')
gmod<-gamlj::gamljGlm(formula = performance ~ hours,
data = qsport,
scaling = c(hours='standardized'))
gdata<-gamlj_data(gmod)
lm(performance ~ hours,data=gdata)


## Extract the R model

### Description

Return the estimated model object of the class lm, lmer, glm depending on the model.

### Usage


gamlj_model(object)


### Arguments

 object a gamlj results object of the class ’gamlj*Results’

### Author(s)

Marcello Gallucci

### Examples


data('qsport')
obj<-gamlj::gamljGlm(
formula = performance ~ hours,
data = qsport)
model<-gamlj_model(obj)



## Predicted values from GAMLj models

### Description

Deprecated. Please use ‘predict()’

### Usage


gamlj_predict(gobj, re.form = NULL, type = "response")


### Arguments

 gobj a gamlj results object of the class ’gamlj*Results’ re.form if not NULL, specifies the random effect to be included in the computation of the predicted values. Used only for the mixed models. type the type of prediction required. The default is on the scale of the response variables (‘response’); Thus for binomial models the default is to compute the predicted probabilities. ‘link’ gives the scale of the linear predictors; is on the scale of the linear predictors; The ‘terms’ option returns a matrix giving the fitted values of each term in the model formula on the linear predictor scale. Cf. stats::predict(), stats::predict.lm()

### Author(s)

Marcello Gallucci

### Examples


data('qsport')
gmod<-gamlj::gamljGlm(
formula = performance ~ hours,
data = qsport)
preds<-gamlj_predict(gmod)



## Residuals values of a GAMLj model

### Description

Deprecated. Please use ‘residuals()’

### Usage


gamlj_residuals(gobj, type = "response")


### Arguments

 gobj a gamlj results object of the class ’gamlj*Results’ type the type of the residuals for generalized models. The alternatives are: ‘deviance’ (default), ‘pearson’, ‘working’, ‘response’, and ‘partial’. Can be abbreviated., cf. stats::residuals.lm()

### Details

stats::predict(), stats::residuals.lm(), stats::residuals.glm()

### Author(s)

Marcello Gallucci

### Examples


data('qsport')
gmod<-gamlj::gamljGlm(
formula = performance ~ hours,
data = qsport)
preds<-gamlj_residuals(gmod)



## Deprecated simple effects

### Description

Deprecated, please use ‘simpleffects’ #’

### Usage


gamlj_simpleEffects(
object,
variable = NULL,
moderator = NULL,
threeway = NULL,
...
)


### Arguments

 object a gamlj results object of the class ’gamlj*Results’ variable the independent variable name moderator the moderator variable name threeway the name of the additional moderator for three way interactions … any other options accepted by the gamlj_* function

### Author(s)

Marcello Gallucci

## GAMLj plot

### Description

This function re-estimates a GAMLj model adding a new plot. If no options is passed, extracts the
plots present in the ’gamlj*Results’ object. If one plot is present, it is returned as a ggplot2 object, if more than one is present, a list of plots is returned. FALSE is returned if no plot is present or defined.

### Usage


## S3 method for class 'gamlj'
plot(x, formula = NULL, ...)


### Arguments

 x a gamlj results object of the class ‘gamlj’ formula a right hand side formula specifying the effect to plot, of the form ‘~x’, ’~x*z’ or ‘~xzw’. It has prevalence on other options defining a plot. … all options accepted by a gamlj model function. Relevant for new plots are ‘plotHAxis’, ‘plotSepLines’ and ‘plotSepPlots’

### Author(s)

Marcello Gallucci

### Examples


data(qsport)
gmod<-gamlj::gamljGlm(
formula = performance ~ hours,
data = qsport)
plot(gmod,plotHAxis = 'hours')
plot(gmod,formula=~hours)


## Post-hoc test on GAMLj results

### Description

This is a convenience function to re-estimates a GAMLj model adding posthoc tests. If no options is passed, extracts the
post-hoc tests tables already in the model results (if any). If new post-hoc are defined, the post-hoc tests tables
are returned.

### Usage


posthoc(object, ...)
## S3 method for class 'gamlj'
posthoc(object, formula = NULL, ...)


### Arguments

 object a gamlj results object of the class ‘gamlj’ … all options accepted by a gamlj model function. Relevant for new tests are ‘postHoc’ (a list of list of terms), ‘postHocCorr’, a list of correction to apply: one or more of ‘none’, ‘bonf’, or ‘holm’; provide no, Bonferroni, and Holm Post Hoc corrections respectively. formula a right hand side formula specifying the factors or factors combinations to test, of the form ‘~x+z’, ‘~x:z’ or ’~x*z’. It has prevalence on other options defining a post-hoc test via character options.

### Author(s)

Marcello Gallucci

### Examples


data(fivegroups)
fivegroups$Group<-factor(fivegroups$Group)
gmod<-gamlj::gamljGlm(
formula = Score ~Group,
data = fivegroups)
posthoc(gmod,formula =~Group)


## Predicted values from GAMLj models

### Description

Returns predicted values from the estimated model

### Usage


## S3 method for class 'gamljGlmResults'
predict(object, ...)
## S3 method for class 'gamljGzlmResults'
predict(object, type = "response", ...)
## S3 method for class 'gamljMixedResults'
predict(object, re.form = NULL, type = "response", ...)
## S3 method for class 'gamljGlmMixedResults'
predict(object, re.form = NULL, type = "response", ...)


### Arguments

 object a gamlj results object of the class ’gamlj*Results’ … additional arguments for specific predict methods other than the ones specified here. type the type of prediction required. The default is on the scale of the response variables (‘response’); Thus for binomial models the default is to compute the predicted probabilities. ‘link’ gives the scale of the linear predictors; is on the scale of the linear predictors; The ‘terms’ option returns a matrix giving the fitted values of each term in the model formula on the linear predictor scale. Cf. stats::predict(), stats::predict.lm() re.form (formula, NULL, or NA) specify which random effects to condition on when predicting. If NULL, include all random effects; if NA or ~0, include no random effects. Used only for the mixed models.

### Author(s)

Marcello Gallucci

### Examples


data('qsport')
gmod<-gamlj::gamljGlm(
formula = performance ~ hours,
data = qsport)
preds<-predict(gmod)



## Residuals values from GAMLj models

### Description

Returns residuals values from the estimated model

### Usage


## S3 method for class 'gamljGlmResults'
residuals(object, ...)
## S3 method for class 'gamljGzlmResults'
residuals(object, type = "deviance", ...)
## S3 method for class 'gamljMixedResults'
residuals(object, ...)
## S3 method for class 'gamljGlmMixedResults'
residuals(object, type = "deviance", ...)


### Arguments

 object a gamlj results object of the class ’gamlj*Results’ … additional arguments for specific residuals methods. type the type of residuals for generalized models. The alternatives are: ‘deviance’ (default), ‘pearson’, ‘working’, ‘response’, and ‘partial’. Can be abbreviated. Cf. stats::residuals(), stats::residuals.lm(), stats::residuals.glm()

### Author(s)

Marcello Gallucci

### Examples


data('qsport')
gmod<-gamlj::gamljGlm(
formula = performance ~ hours,
data = qsport)
preds<-residuals(gmod)



## R-squared and pseudo-rsquared for a list of (generalized) linear (mixed) models

### Description

This function calls the generic r.squared function for each of the models in the list and rbinds the outputs into one data frame

### Usage


rsquared.glmm(obj)


### Arguments

 obj single model or a list of fitted (generalized) linear (mixed) model objects

: Jon Lefcheck

### References

Lefcheck, Jonathan S. (2015) piecewiseSEM: Piecewise structural equation modeling in R for ecology, evolution, and systematics. Methods in Ecology and Evolution. 7(5): 573-579. DOI: 10.1111/2041-210X.12512

## Simple Effects on GAMLj results

### Description

This is a convenience function to re-estimates a GAMLj model adding simple effect analysis. If no options is passed, extracts the
simple effects tables already in the model results (if any). If new tests are defined, the simple effects tests tables
are returned.

### Usage


simpleEffects(object, ...)
## S3 method for class 'gamlj'
simpleEffects(object, formula = NULL, ...)


### Arguments

 object a gamlj results object of the class ‘gamlj’ … all options accepted by a gamlj model function. Relevant for new tests are ‘simpleVariable’ (the simple effect variable), ‘simpleModerator’ (the moderator), and ‘simple3way’ for the second moderator. formula a right hand side formula specifying the variables to test, of the form ‘~x:z’, ‘~x:z:w’ or ’~x*z’. The formula is not exanded, so the first variable is the simple effect variable, the second is the moderator, the third an optional additional moderator It has prevalence on other options defining a simple effects test via character options.

### Author(s)

Marcello Gallucci

### Examples


data(winkel)
wicksell$time<-factor(wicksell$time)
wicksell$group<-factor(wicksell$group)
gmod<-gamlj::gamljMixed(
formula = dv ~ 1 +group+ time:group+ time+( 1 | subj ),
data = wicksell)
simpleEffects(gmod,formula =~time:group)


## Update a GAMLj model

### Description

Re-estimates a GAMLj model applying new options to the original model

### Usage


## S3 method for class 'gamljGlmResults'
update(object, ...)
## S3 method for class 'gamljGzlmResults'
update(object, ...)
## S3 method for class 'gamljMixedResults'
update(object, ...)
## S3 method for class 'gamljGlmMixedResults'
update(object, ...)


### Arguments

 object of class ’gamlj*Results’ … any parameter to be passed to gamljGlm, gamljMixed, gamljGzlm, or gamljGlmMixed

### Author(s)

Marcello Gallucci

# Comments?

Got comments, issues or spotted a bug? Please open an issue on GAMLj at github“ or send me an email