Learn R Programming

spaMM (version 2.4.35)

fixed: Fixing some parameters

Description

The fitting functions allow some parameters to be fixed rather than estimated, by way of etaFix (linear predictor coefficents) for all fitting functions, of the fixed argument for all (co-)variance parameters in fitme, of ranFix (random-effect and residual dispersion parameters) in HLfit and corrHLfit, and of ranPars in HLCor. The diversity of names may be confusing, but keep in mind that ranFix allows one to fix parameters that HLfit and corrHLfit would otherwise estimate, while ranPars can be used to set required parameters for HLCor, which it would otherwise be unable to estimate (e.g., Matern correlation parameters).

Each of these arguments is a list.

ranFix elements taken into account by HLfit include phi (variance of residual error, for gaussian and Gamma HGLMs), lambda (random-effect variances), and ranCoefs (variance-correlation information for random-coefficient terms). To assign values for only some random-effect terms, lambda and ranCoefs can be incomplete, e.g. lambda=c(NA,1) or lambda=c("2"=1) (note the name) to assign a value only to the variance of the second of two random effects. ranCoefs is a list of numeric vectors, each numeric vector specifying the variance and correlation parameters for a random-coefficient term. This input matches the printed summary of a fit. The elements must be given in the order of the lower.tri of a covariance matrix, as shown e.g. by m2 <- matrix(NA, ncol=2,nrow=2); m2[lower.tri(m2,diag=TRUE)] <- seq(3); m2. For example, to assign variances values 3 and 7, and correlation value -0.05, to a second random effect, one can use ranCoefs=list("2"=c(3,-0.05,7)) (note the name).

Additional ranFix elements are taken into account by corrHLfit, as follows. For the Mat<U+00E9>rn model, these are the correlation parameters are rho (scale parameter(s)), nu (smoothness parameter), and (optional) Nugget (see Matern). The rho parameter can itself be a vector with different values for different geographic coordinates. For the adjacency model, the only correlation parameter is a scalar rho (see adjacency). For the AR1 model, the only correlation parameter is a scalar ARphi (see AR1).

ranPars elements taken into account by HLCor include all the above ranFix elements.

The only etaFix element considered here is beta, which should be a vector of (a subset of) the coefficients (\(\beta\)) of the fixed effects, with names as shown in a fit without such given values. In contrast to an offset specification, it affects by default the REML correction for estimation of dispersion parameters, which depends only on which \(\beta\) coefficients are estimated rather than given. This default behaviour will be overridden whenever a non-null REMLformula is provided to HLfit or the other fitting functions (see Example).

fixed elements taken into account by fitme include all the above ranFix and etaFix elements.

Arguments

Details

REMLformula is the preferred way to control non-standard REML fits. Alternatively, with a non-NULL etaFix$beta, REML can also be performed as if all \(\beta\) coefficients were estimated, by adding attribute keepInREML=TRUE to etaFix$beta. Using an REMLformula will override such a specification.

Examples

Run this code
# NOT RUN {
data("wafers")
# Fixing random-coefficient parameters:
HLfit(y~X1+(X2|batch), data=wafers, ranFix=list(ranCoefs=list("1"=c(2760, -0.1, 1844))))
# fixing coefficients of the linear predictor, but with REML as if they were not fixed:
HLfit(y ~X1+X2+X1*X3+X2*X3+I(X2^2)+(1|batch), data=wafers, family=Gamma(log),
      etaFix=list(beta=c("(Intercept)"=5.61208, X1=0.08818, X2=-0.21163, X3=-0.13948, 
                         "I(X2^2)"=-0.10378, "X1:X3"=-0.08987, "X2:X3"=-0.08779)),
      REMLformula=y ~X1+X2+X1*X3+X2*X3+I(X2^2)+(1|batch))

data("Loaloa")
# Fixing some Matern correlation parameters, in corrHLfit:
corrHLfit(cbind(npos,ntot-npos)~elev1+elev2+elev3+elev4+maxNDVI1+seNDVI
           +Matern(1|longitude+latitude),
             data=Loaloa,family=binomial(),ranFix=list(nu=0.5,Nugget=2/7))
# Fixing all mandatory Matern correlation parameters, in HLCor:
HLCor(cbind(npos,ntot-npos)~elev1+elev2+elev3+elev4+maxNDVI1+seNDVI
           +Matern(1|longitude+latitude),
             data=Loaloa,family=binomial(),ranPars=list(nu=0.5,rho=0.7))
# }

Run the code above in your browser using DataLab