Linear, generalized and mixed models
Linear, generalized and mixed models
New model › type "Linear regression" or "Linear mixed model": one quantitative Y, the X variables of the Variables tab (transformations and cross terms included; a qualitative variable through its categories, one of them the reference). Without X: the null model, useful to compare AICs. The default scaling keeps the variables' units (coefficients per unit); UV gives coefficients per standard deviation.
A mixed model (nlme) adds nested random effects, the widest first: a random intercept for each site, then for each sector within its site (an observation ID or a qualitative variable). It can add an autocorrelation in time (CAR1, continuous time: missing years are fine; the time is an ID or a variable, of numbers or of dates, and φ is then from one year to the next: see Dates as time) within the last level or, through "within each", within a finer one that has no random effect of its own: the sector within its site, when only the site has a random effect. Coefficients and variances are estimated by REML; the log-likelihood, AIC, AICc and BIC come from the ML fit, the only one that compares models with different fixed effects. Cross-validation defaults to the first random effect: each site is predicted by the fixed effects of the model fitted without it, as a site never seen.
Random slopes: under each random effect chosen, "Random slopes by site" ticks the quantitative X variables whose slope changes from one site to another, most often the year: each site has its own trend, which varies around the model's fixed slope; it is (1 + year | site) in an R formula. The variable must also be an X term of the model, quantitative and on its own (transformed or not), not a curve: otherwise the model is refused, naming it. With nlme (a mixed model, or a GLM or GAM with the normal distribution and CAR1, fitted by mgcv::gamm), each level has nlme's general covariance matrix (random = ~ year | site; with nested levels, the list list(site = ~ year, sector = ~ 1)): the variance of its intercept, that of each slope and their correlation. A slope's standard deviation, in units of Y per unit of X, says how much the sites' trends differ from the mean trend: about 95 % of the sites are within ±2 standard deviations of the fixed slope. The correlation says whether the high sites have steeper slopes (above 0) or shallower ones (below); it is that of the intercept taken at x = 0. The Summary gives the variance and standard deviation of each intercept and each slope, and each slope's correlation with its level's intercept (with several slopes at one level, their correlations with each other are estimated but not in this table: summary(m) in the script of Export to R gives them). With a slope, a level's variance changes with x and its share of the random variance has no single value: the Summary gives each level's share of its mean variance over the observations, and the marginal and conditional R2 take it too, as Johnson (2014) extends those of Nakagawa and Schielzeth: the mean over the observations of zᵢᵀΣzᵢ, Σ the level's matrix and zᵢ = (1, the values of its slopes).
Centring: a variable far from 0, such as the year (≈ 2010), puts the random intercept far from the data (at year 0), where its correlation with the slope is near ±1; the fit often stops short there, on a slope whose standard deviation is nearly 0. Nuée doesn't centre without saying so: the Summary flags a singular fit (a correlation beyond ±0.99, or a slope's standard deviation, times that of its variable over the observations, below 1 % of the residual standard deviation) and, when the variable is far from 0 (its mean beyond its standard deviation), advises centring it, scaling Ctr or UV in the Variables tab: it is the same model, which nlme then usually finds, the intercept taken at the variable's mean. A centred variable and a singular fit: the data can't estimate this slope or this correlation; compare by AIC with the model without it. A failed fit still reads "The model could not be fitted".
In a GLM or GAM fitted by mgcv::gam (another distribution than the normal, or without CAR1), a random slope is a term s(site, year, bs = "re") (Wood, 2017): independent of the random intercept, with no correlation, as mgcv can't correlate them. That model depends on where x is 0: with x centred, the random intercept is each site's level at the mean of x; the year left uncentred leaves little room for the slope's variance. The Summary says so. Refitted with CAR1 (mgcv::gamm), such a model has its slopes correlated, as in nlme.
With random slopes: cross-validation predicts a site never seen by the fixed effects; the AIC selection chooses only the fixed effects, and the group of a variable with a random slope stays in every model (a random slope goes around its variable's fixed slope); in Block contributions, without that variable, only its fixed slope is removed and its random slope stays (the test of the mean slope, with the same random effects); two models with different random slopes don't have the same random effects: no likelihood-ratio test between them, they compare by AIC on the same observations; Fit with CAR1 keeps the slopes; predictions are those of the fixed effects. Not covered: in nlme, a slope uncorrelated with the intercept ((0 + year | site), (1 | site) + (0 + year | site), ||), refused in the R formula; the random slope of a qualitative variable, a cross term or a curve.
Type "Generalized linear model (GLM)" or "Additive model (GAM)" (mgcv), for a Y that isn't normal. Distribution of Y: Poisson for counts; negative binomial for counts that vary more than a Poisson allows (its θ estimated); zero-inflated Poisson for counts with more zeros than a Poisson gives (its θ₁ and θ₂ estimated); binomial for presence-absence (0 or 1); gamma for positive values; Tweedie for densities with zeros (its power p estimated); beta for proportions strictly between 0 and 1 (its precision φ estimated); or normal. The link is log (counts, gamma, Tweedie; for the zero-inflated Poisson, that of its Poisson parameter μ), logit (binomial, beta) or identity (normal). Effort (offset): a variable such as an area, a duration or a number of visits, whose log enters the model with a coefficient of 1, which then describes a density (an effort of 0 or less is refused). Random effects as above make a GLMM or a GAMM. With the normal distribution and at least one random effect, a GLM or GAM can take the autocorrelation in time too: it is then fitted by mgcv::gamm, as an nlme mixed model whose curves are random effects (coefficients, curves, variances and φ by REML; logLik, AIC, AICc and BIC from an ML fit, comparable only with other models fitted that way). With another distribution it is refused: mgcv::gamm would use penalized quasi-likelihood (PQL), with no true likelihood nor AIC. In an additive model, the X variables ticked in the Curve column of the Variables tab enter through a smooth curve (a spline) instead of a straight line, for an effect that rises then falls, or a threshold; the data decide how curved it is (its edf; 1 is a straight line). Its basis dimension k bounds how curved it can be: 10 at most, less when the variable has few values; type another one (3 to 100) in the box beside the tick, as s(x, k = 5) does in R. A curve per category: the list beside k offers the model's qualitative X variables ("one per sector"), as s(year, by = sector) does in mgcv: each sector has its own curve, each of dimension k, with its edf, test, concurvity, effect and thresholds. Each is centred on its category's observations (mgcv's identifiability constraint): the qualitative variable must stay in X, its main effect giving the difference in level between the categories; without it every category would have the same mean, and Nuée then refuses the model rather than add that term without saying so. The factor mgcv sees comes from the model's 0/1 category columns (its levels, the categories observed, in their order); a category added to the data after the model was defined has no column, hence no curve: its rows are left out of the model with the incomplete observations, and in a test set they stay without a prediction. A variable with a curve per category can't also be in a cross term with a qualitative variable (each category already has its curve). Curves and random effects are estimated by REML, and the AIC comes from an ML fit; a GLM without them is fitted by maximum likelihood, as glm() and MASS::glm.nb() do. The Summary of a Poisson model warns when the counts are overdispersed (Pearson's chi-square above 1.5 times its degrees of freedom): its p values are then too small, and the negative binomial suits the counts better. Zero-inflated Poisson and beta (mgcv's ziP and betar families; Wood, Pya & Säfken 2016). In the zero-inflated Poisson, a hurdle model, a count is zero with probability 1 − p and otherwise follows a Poisson distribution of parameter μ truncated at zero; the linear predictor is log(μ) (mgcv calls this link "identity"; exp(coefficient) multiplies μ, and so does the effort), and p is tied to it by log(−log(1 − p)) = θ₁ + θ₂ log(μ), θ₁ and θ₂ estimated with the model; θ₁ = 0 and θ₂ = 1 give back the Poisson distribution, so its AIC compares with those of the Poisson and negative binomial models of the same counts. Its fitted values, predictions, cross-validation and test set are expected counts, p μ / (1 − e^(−μ)); it has no adjusted R², only the deviance explained. It needs counts with at least one zero. Many zeros don't make zero inflation (too many zeros given the model's mean may): compare the models by AIC and look at the quantile residuals; when X variables explain the zeros themselves, the model may be poorly identified. The beta distribution is for proportions strictly between 0 and 1 (a cover, a share of time), of mean μ with the logit link and variance μ (1 − μ) / (1 + φ), its precision φ estimated (Ferrari & Cribari-Neto 2004); its AIC compares with that of a normal model of the same proportions. A response at 0 or 1 is refused, with the number of such values: mgcv would move them just inside (its eps), which isn't harmless for the fit; bring them inside yourself, saying so (Edit › New variable, for example (y * (n - 1) + 0.5) / n for n observations; Smithson & Verkuilen 2006), or take the binomial for presence-absence. Both take random effects, curves and the spatial smooth (no CAR1 autocorrelation); only the zero-inflated Poisson takes an effort. θ₁, θ₂ and φ show in the Summary, the report and the coefficients side by side. Without a curve or random effect, mgcv's ML fit of these two families sometimes stops on a LAPACK error: Nuée then finds the distribution's parameters that maximize the likelihood itself (each fit at fixed parameters by mgcv), and its exported script does the same.
Spatial smooth (General tab, for a GAM of a project with coordinates, see Maps and spatial data): a surface of the observations' coordinates, s(x, y), a thin plate regression spline on plane coordinates (Wood 2003) or a spline on the sphere for longitudes and latitudes (s(lat, lon, bs = "sos")), of basis dimension k (empty: 30 at most, fewer with few places). It takes up the spatial structure the terms don't explain: check with Plots › Spatial autocorrelation of the model's residuals, and compare the models by AIC. Observations without coordinates are left out of the model. Its edf and test are in the Summary's curves table, and its value at each observation is a column of the model's results that the map can show. The R formula writes it s(x, y), s(x, y, k = 40) or s(lat, lon, bs = "sos"). Export to R redoes it: the script puts the coordinates in the columns sx and sy of the model's table and the term in the formula (with its k, thin plate or on the sphere), its row in the curves table and a map of its value at each observation.
Model conditions (a regression's Summary): pointers in words, each ✓ or ⚠ with what to do: the residuals' distribution (Shapiro–Wilk, on the quantile residuals for counts, presence-absence and positive values), a spread of the residuals that changes with the fitted values, influential observations (Cook's distance beyond 4/n, linear model), overdispersion and an excess of zeros (counts), collinear quantitative terms (VIF > 5), curves confounded with the other terms, and the residuals' spatial autocorrelation when the project has coordinates. With many observations a test sees harmless departures, with few it sees none: the residual plots remain the reference.
R formula (General tab): the model written as in R, for instance
y ~ a * b + log10(c) + I(a^2) + s(d) + offset(log(effort)) + (1 | site/sector).
Edit it, then Apply (Ctrl+Enter): it sets the variables and their transformations (log, log10, log1p, exp, sqrt, I(x^p), I(a * x + b), the logit log((x - a) / (b - x))), the cross terms (a:b; a*b for a, b and a:b; a:b without a: a enters without a main effect; I(a^2) when a is in the model too, else the square of a), the curves s(x), s(x, k = 5) and s(x, by = f) (one per category of f, which must also be a term; s(x, by = f, k = 5)), the effort offset(log(x)) and the nested random intercepts (1 | site/sector), the widest first, with their random slopes as lme4 writes them: (1 + year | site) or (year | site); (1 + year | site/sector), a slope at each level; one term per level, (1 + year | site) + (1 | site:sector).
A curve makes the model additive, random effects make it mixed. R reads the formula without ever running it: anything else (another function, code) is refused with the reason, and the formula isn't kept, only the settings it gives.
Views: Summary (R2, or marginal and conditional R2 for a mixed model, Nakagawa and Schielzeth; adjusted R2 and deviance explained for a GLM or GAM (marginal and conditional R2 when fitted by mgcv::gamm, the curves in the fixed part), with each curve's edf, test and concurvity (the share of the curve the other terms reproduce; above 0.8, in red, it is confounded with them; a row per category for a curve per category);
Q2 and RMSEcv; AIC; the variance of each random effect and its share (with random slopes, see above); φ of the autocorrelation), Coefficients (each term's effect with its 95 % interval, red when p ≤ 0.05; with a log link, exp(estimate) is the multiplicative effect of one unit more, with the logit the odds ratio), Effects (each quantitative term's effect as its variable varies, the others fixed, with its 95 % band and the observed values below it: a GAM's curves, straight lines otherwise, one per category for a term crossed with a qualitative variable or a curve per category, with the categories' legend; on the scale of the link, log or logit, when there is one; for a curve, Thresholds: the effect and its slope with 95 % simultaneous bands from 2000 draws of the coefficients, the ranges where the slope's band excludes 0, clearly rising or falling, shaded and listed, and the edf, below 1.5 nearly a straight line, as Simpson (2018) reads thresholds; a curve with one per category (a curve per category, or a curve crossed with a qualitative variable) has the thresholds of the category chosen in the list beside the box, over the variable's percentiles in that category), Observed / predicted, Residuals (standardized, against the fitted values, normal Q-Q plot, by group of a random effect; Cook's distance for a linear regression; the quantile residuals too for counts, presence-absence and positive values, below), Block contributions (AIC): each block of the Block column (or each variable) removed and the model refitted by ML, a main effect with the cross terms that contain it and the curves per category it makes (the With column names them); ΔAIC above 2 means the block clearly improves the model, a likelihood-ratio test gives its p. Observations with a missing value in Y, X, a random effect, the time or the effort are left out (the summary counts them).
Residuals of a GLM or GAM with the Poisson, negative binomial, binomial, gamma, zero-inflated Poisson or beta distribution: beside the standardized deviance residuals (the default), the randomized quantile residuals of Dunn and Smyth (1996), r = Φ⁻¹(u), F the model's distribution at each observation's fitted value (its random effects and effort included; the negative binomial with its fitted θ, the binomial with one trial, the gamma with the shape 1 / its estimated scale, the zero-inflated Poisson as mgcv defines it with its θ₁ and θ₂, the beta of shapes μ φ and (1 − μ) φ): u = F(y) for the gamma and the beta, and for counts or 0/1 u drawn uniformly between F(y − 1) and F(y), with a fixed seed, so that the plot doesn't change from one look to the next (the session's random numbers are left as they were). The Pearson or deviance residuals of counts are far from normal even when the model is right; these residuals are normal when it is. Not offered for Tweedie (no distribution function in the packages that come with R) nor for the normal distribution, where they would be the standardized residuals.
Plots › Residual autocorrelation: the autocorrelation of a regression's residuals in time within each group, the groups pooled, as nlme::ACF computes it: at lag k, observations k steps apart in their group's time order (a missing year is skipped), lags 0 to 10 at most, with the band ±1.96/√n of each lag (n: its pairs), as nlme draws it. A model with CAR1 keeps its time and groups and shows two series: its residuals without the autocorrelation, and its normalized residuals, which show none left when CAR1 is enough (the note reads lag 1). For another model, choose the time (an ID or a variable, of numbers or of dates: the year) and the groups: by default those of its random effects (the sector within its site), otherwise an ID or a qualitative variable; either can take a finer level within it (the sector within the site of a random effect, or a sector whose names repeat from one site to another). Beyond the band at lag 1, the note suggests a CAR1 autocorrelation, to compare by AIC. For a GLM or a GAM, Pearson residuals ((y − fitted) / √variance) or deviance residuals (each observation's signed share of the deviance), the same for the normal distribution; a mixed model's residuals are those within its groups (given the random effects), as in nlme::ACF. Nuée computes the normalized residuals in each group's time order: nlme's own are right only on rows sorted by group, then by time. Within the groups of its random effects, with or without a finer level, Fit with CAR1 makes it a new model: the same settings with a CAR1 autocorrelation along that time within those groups (an LMM, or a GLM or GAM with the normal distribution, then fitted by mgcv::gamm; the button is offered only then, and a refusal of the engine is shown), named like a refit (M1 (1)) and selected with its default views open. An LMM on the same observations stays in the AIC set of the model without CAR1: the two compare by AIC in Prediction › Compare models (the likelihood-ratio test doesn't test an autocorrelation). The note says when they don't: observations without a time or a group stay out of the new model, and mgcv::gamm's likelihood doesn't compare with mgcv::gam's. File › Model report can include the plot.
Plots › AIC selection (also under each regression in the explorer): which variables to keep. Each combination of the model's groups of terms (the blocks of the Block column, otherwise the variables), from the null model to the full model, is fitted by ML on the same observations and ranked by AICc; a cross term or a square enters only with its main effects (a qualitative variable through all its categories) and the cross terms of part of its factors, a curve per category only with its qualitative variable's main effect. Only the fixed effects are chosen: the random effects, the autocorrelation, the effort and the curves' settings stay those of the model, and the group of a variable with a random slope stays in every model, out of the groups to choose. Up to 8 groups (256 combinations), every combination is fitted (a mixed model with CAR1 on 240 rows takes about 10 s); beyond, a backward elimination from the full model removes, step by step, the group whose removal lowers AICc the most. The view suggests the best model (lowest AICc) and, when it differs, the most parsimonious within ΔAICc ≤ 2 (fewest parameters; Burnham and Anderson, 2002); it plots each group's importance (the sum of the Akaike weights of the models that contain it) and lists the 20 best models, or those within ΔAICc < 10, with a column per group, k, logLik, AICc, ΔAICc, the weight and the cumulative weight. Fit this model, on the suggestion or on any row (click the row first), makes it a new model: the same settings with only those groups' variables (a cross term keeps its factors), on the same observations, fitted as usual (REML for the estimates) and named like a refit (M1 (1)). Once the selection has run, the Methods text describes it, the model report can include it, and Export to R redoes it.
Plots › Trend power (also under each linear regression or linear mixed model in the explorer): with this many sites counted every year, how many years until a trend is detected? Choose the time (a quantitative X, untransformed: the year), the trend to detect (a change per year in the units of the model's Y; with a log10 or ln response, also in % per year, converted to the slope log(1 + %/100) on that scale, an approximation with log10(x + 1), close only where x is large against 1), α (a two-sided test), the numbers of years (from, to) and the numbers of units of the first random effect (the sites; the data's own number is always among them). Every unit is counted once a year, its nested levels as in the data, their mean numbers rounded (2.75 sectors per site: 3); a linear regression counts observations per year. The variances are the model's REML estimates (random effects, residual variance, CAR1 φ), and the model's other terms stay out of the designs (their effects held constant). For each design, the variance of the generalized least squares estimator of the slope with these variances known, (X'V⁻¹X)⁻¹ with V the design's covariance (Diggle et al., 2002), gives the power Φ(|β|/se − z) + Φ(−|β|/se − z): power against the number of years, a line per number of units, the 80 % line, a sentence ready for a report ("With 12 units of “site”, each counted every year, a decline of 3% per year in “densite” is detected with 80% power after 11 years"), and the table. Every unit being counted every year, the random intercepts change nothing in the slope's variance: the residual variance, φ, the years and the number of series counted decide it. A simulation checks the formula at one design (by default the data's own): N data sets (200 by default) drawn from the model with the trend, each refitted by nlme with the same structure (REML), the power being the share of slopes with p ≤ α (Johnson et al., 2015), with its Monte Carlo error. Its seed is fixed (the same data sets every time; the session's random numbers are left as they were), and the view says first how long it will take: the R engine fits one model at a time and does nothing else meanwhile (a simulation that would take more than 15 minutes, or of more than 20,000 observations per data set, is refused). The two may differ: the simulation estimates the variances and φ in each data set (from few units or years they are uncertain) and tests the slope with nlme's t, where the formula takes them as known and uses the normal distribution. Not covered, and refused with the reason: GLMs and GAMs, random slopes, a model without a quantitative X that can be the time, a CAR1 along a time in other units than the trend's. Once computed, the Methods text describes it, the model report can include it, and Export to R redoes it (the simulation with the same draws). Plots › Adjusted means (also under each regression that has a qualitative variable, in the explorer): the mean of each category of a qualitative X adjusted for the model's other terms, as R's emmeans package computes it (Lenth; its default conventions, without the package): the estimated marginal means of Searle, Speed and Milliken (1980). Choose the variable (a main effect or a factor of a cross term). Each mean is the model's prediction on a reference grid, averaged: the grid has every combination of the observed categories of the model's qualitative variables; each quantitative variable is at its mean over the model's observations (a transformed variable at the transform of its mean, as emmeans: log10 of the mean of x, not the mean of log10(x)), the cross terms and squares evaluated at these values (the product of the means), a curve (GAM) at the mean of its variable, the effort at 1 (densities, as emmeans' offset = 0); the mean of a category averages the grid's rows that have it, with equal weights over the categories of the other qualitative variables. Its standard error is √(L V Lᵀ), V the covariance of the coefficients (nlme's for a mixed model, mgcv's Bayesian one for a GLM or GAM, as emmeans), with its 95 % interval. Below, every pair of categories: the difference with its interval and p, adjusted by Tukey's method (the default: the studentized range for the number of means compared; Tukey 1953, Kramer 1956), by Holm's (the p-values; the intervals by Bonferroni's, as emmeans, Holm's method giving none) or unadjusted. "Within each level of" another qualitative variable crossed with the first (the treatment within each habitat): the first's categories compared within each category of the other, the adjustment within each. "For each category › the slope of x", for a quantitative variable crossed with it (year × sector): the slope of x in each category (per unit of the term, transformed if it is), the derivative of the predictions as emtrends takes it (a forward difference of a thousandth of x's range), and the pairs of slopes; for a straight line, the slopes of the Effects view. The degrees of freedom are those emmeans takes by default: the residual ones for a linear regression, and for a GLM or GAM whose scale is estimated (normal, gamma, Tweedie); nlme's containment rule for a mixed model (the smallest of those of the coefficients a mean or a pair involves in R's default coding, the first category as reference, as emmeans on R's own fit; the intercept counting for the number of groups of the first random effect minus one: typically, the mean of a sector has the number of sites minus one, a pair of sectors within sites the inner df; for a habitat that varies only between sites, the mean of the first habitat has the number of sites minus one, the others and the pairs the habitat's df, the sites minus one minus its coefficients); z (asymptotic) for a Poisson, binomial, negative binomial, zero-inflated Poisson or beta distribution, as emmeans for glm() and as the model's Coefficients (on an mgcv::gam object, emmeans uses the residual df whatever the distribution). With a log or logit link, the means are on the response scale (exp; inverse logit: probabilities, or mean proportions for the beta distribution), their intervals transformed from the link scale, and the pairs are ratios of means or odds ratios, tested on the link scale, as emmeans' type = "response"; the link scale on demand. With the zero-inflated Poisson, the means are expected counts, p μ / (1 − e^(−μ)) at each category's linear predictor log(μ) (θ₁ and θ₂ taken as known; their standard errors by the delta method, their intervals transformed, that value increasing with log(μ)), and the pairs ratios of expected counts, tested on their log by the delta method, as emmeans' regrid(transform = "log"); on the link scale, log(μ). A transformed Y (log10, ln…) stays on its scale, as the view says: back-transformed, a mean of logarithms is a median (a geometric mean), not a mean. A combination of categories that no observation has is not estimable (emmeans: nonEst): its mean and its pairs are left out, and named. A click on a pair in the table gives its sentence ready for a report (copy button); Ctrl+C copies both tables. Once computed, the Methods text describes it (Searle et al. 1980, Lenth's emmeans, Tukey 1953 and Kramer 1956, or Holm 1979), the model report can include it, and Export to R redoes it in base R (the grid, the model's rows L, the covariance and the degrees of freedom: the same numbers). Not covered: weights other than equal (emmeans' weights = "proportional"…), contrasts other than pairs (against a control), a quantitative variable at another value than its mean.
Prediction › Predict observations, Predict a file: Y predicted by the fixed effects (for a mixed model, a group never seen), on the model's scale of Y (its transformation included), next to Y observed when it is known. A file's columns are matched to the model's variables by name, the effort included (without it, the predictions are for an effort of 1, and the note says so). ⚠ marks a value outside the range of the model's observations: an extrapolation.
Prediction › Compare models: Q2 and RMSEcv for every model; AIC, ΔAIC and Akaike weights (the probability that each model is the best of its set) between the regressions of the same response on the same observations only (an "AIC set", lettered A, B...), and only those whose likelihoods compare: Poisson, negative binomial and zero-inflated Poisson models of the same counts, but not a normal model of them; normal, gamma or beta models of the same values;
Tweedie models with each other; GLMMs and GAMMs (mgcv's conditional likelihood) with each other.
Under the AIC table, Nested models: the likelihood-ratio test between each pair of nested regressions of the same AIC set, as anova(m1, m2) on ML fits. The smaller model's fixed terms are among the bigger one's (its columns lie within the bigger one's), with the same distribution, effort, random effects (their slopes included) and autocorrelation; χ² = 2 × (logLik of the bigger − logLik of the smaller) on Δdf, the difference in their numbers of parameters, and its p. For linear regressions and GLMs it is the difference of their logLik (of their deviances for a Poisson or binomial GLM, as anova(glm1, glm2, test = "Chisq")). Random effects and autocorrelation aren't tested this way: a zero variance is on the boundary of its range, where the χ² distribution no longer holds; compare them by AIC. With curves or mgcv random effects, the df are edf and the test is approximate, as the table says. Every nested pair is listed (2000 at most); the table's search box finds those of a model.
Prediction › Compare models › Coefficients side by side (the choice at the top of the view): several regressions as papers present them, a row per term and a column per model. Tick the project's regressions to show (all of them at first). Each cell is the estimate with its 95 % interval, or with its standard error, from the model's Coefficients table (its decimals those of two significant digits of the standard error), in red when p ≤ 0.05, empty when the model lacks the term. The rows are the intercept and the first model's terms, then the others' terms in their order: two models share a row when they have a term of the same name. Below: n, AIC and AICc (ML fit), R² (a linear regression), the marginal and conditional R² (a mixed model) or the share of the deviance explained (a GLM or GAM), the standard deviation σ of each random effect (and the residual one of an nlme model), CAR1's φ and each curve's edf. A model with a log or logit link keeps its estimates on the link's scale, as in its Coefficients view, and the note says so. Ctrl+C (or the copy button) puts the table on the clipboard as text and as a table, which Excel and Word paste as a table, with stars for p (* ≤ 0.05, ** ≤ 0.01, *** ≤ 0.001) and their legend; File › Export model results (Ctrl+E), from this view, writes it, with each model's coefficients in numbers beside it.
File › Export: the observations (observed, fitted, predicted in cross-validation, residuals), the coefficients, the fit statistics, the random effects (each random intercept and slope, and their correlation) and the curves, a table each. File › Model report: the summary and the coefficients, each term's effect, each curve's thresholds, observed / predicted and the residuals (the quantile residuals too, for counts, presence-absence and positive values).
File › Export to R: a script or report for a regression too, with lm, nlme::lme, mgcv::gam or mgcv::gamm: its rows and terms, the fits (REML and ML; its random slopes included), the cross-validation by its groups, then the coefficients, AIC, R2, variances, curves with their concurvity and thresholds (the same draws as the Thresholds view), the quantile residuals (the same draws as the Residuals view), test set and plots, checked against Nuée's results before it is written.
Cross terms with a qualitative variable (Cross terms tab, or a * b and a:b in the R formula): a qualitative variable enters a cross term through each of its categories, once at most (neither squared nor cubed). year × sector lets the slope of the year differ from one sector to another: its coefficients are, for each sector but the reference one, the difference between the year's slope in that sector and its slope in the reference sector, which is the coefficient of the year. The reference category is the one the fit leaves out (the last category observed), the same in the main effect and in the cross term. For a density monitored by sector, a coefficient of 0.2 for year*sector(S2), the year's being 0.05, reads: the density rises by 0.25 a year in S2, 0.2 more than in the reference sector. Without the year in X (a factor without a role in the Cross terms tab, or y ~ sector + sector:year), each coefficient of year × sector is the year's slope in that sector; without the sector in X (y ~ year + year:sector), the slopes differ but the sectors share one intercept. habitat × treatment: each coefficient is the difference between a treatment's effect (compared with the reference treatment) in a habitat and the same effect in the reference habitat; three variables (year × sector × habitat) give differences of differences. A category's own coefficient (sector(S2)) is then its difference from the reference category where the terms crossed with it are 0: where the year is 0 (with the years in their units, year 0, far outside the data; at the mean year when the year is centred, Ctr or UV), in the reference habitat for habitat × treatment. The columns are ordered as R orders its terms, the main effects first, so that the results are those of lm(), nlme::lme() and mgcv with factors whose first level is Nuée's reference. A combination of categories no observation has (a treatment never given in a habitat) can't be estimated: it is left out, and the Summary names it among the terms never observed. Effects: a quantitative term crossed with categories has one line per category (a curve when the term is a GAM's curve), its slope being its coefficient plus that of its product with the category, with its 95 % band from the coefficients' covariance and, under the plot, each slope per unit with its interval. For a curve, Thresholds are those of the category chosen: the shared curve plus that category's slope; a curve per category (s(x, by = f), above) gives each category its own shape, not the same curve tilted. In the AIC selection and the contributions table, a cross term enters and leaves whole (all its categories), only with its main effects and its lower-order cross terms. The Methods text names each reference category and says what a category's coefficient and the cross terms' coefficients are. Prediction: a category the model has seen gets its own prediction; a category, or a combination of categories, it hasn't seen (absent from the model's observations, from the other groups in cross-validation, or unknown to the project in a file) gets none: the model would predict it as the reference category, or without its slope, and R likewise refuses a level it hasn't seen. This is the rule for every qualitative variable of a regression (main effects, cross terms, curves per category; LM, LMM, GLM, GAM, mgcv::gamm), not for the other models (PLS...). Such observations are counted and named: in cross-validation, the Summary gives how many stayed without a prediction and of which variable, Q2 and RMSEcv being computed on the others; when none is left (sectors proper to each site, cross-validated by site), Q2 is missing, and the Summary says the model can't be cross-validated by these groups with that variable as a fixed X: make it a random effect, or choose other cross-validation groups. The test set counts them apart from its RMSEP, bias and external Q2; Prediction › Predict marks them ⊘ (column Unseen category, in the exported table too). The Methods text and the script of Export to R do the same.
One model per response
Model › One model per response (for a regression: LM, LMM, GLM or GAM): the same model, its terms, random effects, distribution, curves, observations and the transformation of its response, fitted to each response ticked, one species after another (a filter and All / None help pick them). For each term, the p-values are corrected over the responses: Benjamini–Hochberg (FDR) by default, or Holm, or Bonferroni. The view shows, for the term chosen: each response's coefficient with its 95 % interval as a forest plot, in red where the corrected p is at most 0.05 (a curve: its edf); the term's effect in small multiples, one small plot per response (36 at most); and a table with each model's N, AIC, R² and Q². A response that can't be fitted is named with the reason, and the others are kept. "Also keep each model in the project" adds them all, each with its own views.
This page is part of the guide installed with Nuée (USER-GUIDE.txt, also in Help › User guide).