2
$\begingroup$

Can anyone familiar with nlme kindly explain how does the varIdent, with option fixed actually work?

Documentation says:

fixed....an optional numeric vector, or list of numeric values, specifying the values at which some or all of the coefficients in the variance function should be fixed.

What is coefficient in variance function to be fixed? Is it something like variance=kx, where k is the coefficient and x predictor, or variance itself is to be fixed (then it would be strange to use 'coefficient of variance function', unless variance function would be something like varCov=kI, where I is identity matrix).

What I really want to do is to fit a model, where variance is pre-set, a priori known for each value of outcome and was wondering if I can use varIdent for this purpose.

EDIT: after consulting some literature I understand now that varIdent models variance as var=k*var1, where var1 is variance of reference level of given predictor and option 'fixed' allows to pre-specify the values of the coefficient.

Now I would like to know if I can use varIdent also to model a priori known, exact values of variances associated with observations of continous outcome at different values of continous predictor, that is, use it to incorporate measurment error in the model.

For example, I have measurments Yobs with SDs ysd, what about model:

gls(Y~X, weights=varIdent(ysd), data=data) ?

Can anyone help?

$\endgroup$

1 Answer 1

3
$\begingroup$

If you have actual variances for each observation and wish to use these in your nlme model, you can indeed specify these directly using the weights argument in the gls function.

To fit a model with actual variances in nlme, try the following approach:

gls(Y ~ X, weights = varWeights(1/variances), data = data)

In this model:

Y is your outcome variable. X is your predictor(s). variances is a vector containing the actual variances for each observation. varWeights is used to specify the known variances as weights, which should be the inverse of the variances since gls uses precision weights (the inverse of the variance). By specifying 1/variances, you are incorporating the actual measurement error into the model, and each observation will contribute to the fitting process inversely proportional to its variance.

varIdent with the fixed option in nlme is used to specify fixed variances for different levels of a categorical factor, scaling the variances by an estimated proportionality constant. It's useful when variances differ across groups but are consistent within them. varFixed, on the other hand, assumes that the variance structure is known and constant across all observations, scaled by a single proportionality constant. It applies when you have a uniform variance adjustment factor for the entire dataset. Essentially, varIdent allows for group-specific variance scaling, while varFixed applies a global scaling factor.

$\endgroup$
5
  • $\begingroup$ Thanks, but will it treat the values really as absolute variances,not just proportional weights a la weighted regression? Looking into documentation does not help me to make it clear. $\endgroup$
    – NeuroPanda
    Commented Nov 9, 2023 at 18:32
  • $\begingroup$ I agree, the docs are not great to read, but that is my updated understanding! Maybe Ben Bolker will see this, and chime in. He is more of a mixed model expert than I :) $\endgroup$ Commented Nov 9, 2023 at 18:41
  • $\begingroup$ It would be good he can eventually add his comment. Thank you for your help as well. I was thinking maybe some metaregression package could have this covered as well, but I need compatibility with GAMs. $\endgroup$
    – NeuroPanda
    Commented Nov 9, 2023 at 18:47
  • $\begingroup$ Trying the suggested code resulted in error, varWeights requires varFun object as an input $\endgroup$
    – NeuroPanda
    Commented Nov 9, 2023 at 20:46
  • $\begingroup$ After some thinking and reading, I think that even using model with just proportions of variance as input, such as with varFix or within classic weighted least square framework might not be such a big problem. Indeed, if there is higher absolute variance in data, this will tend to be reflected in infered variance and in turn in higher standard error of the coefficients, so the estimates will tend to be unbiased ? $\endgroup$
    – NeuroPanda
    Commented Nov 9, 2023 at 23:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.