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. The varFixed function is not suitable here because it assumes the variances are known only up to a proportionality constant, which is not the case if you have exact variances.
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.