Closed BertvanderVeen closed 1 year ago
Should work now, but I may need to do a few more checks
I know this is closed, but I find the same problem when trying to use 'poly(x, degree=2)' in a formula. Sometimes I get the error 'unexpected numeric constant' and sometimes '$ operator is invalid for atomic vectors', depending (it seems) on what family I specify.
Thanks for posting, James. Unfortunately I cannot reproduce your issue, can you provide me with an example? Then I will look into it. What version of the package are you using?
I'm using gllvm_1.3.1 (and unfortunately R 4.1.0, bc my organization is slow approving software). This code fails for me:
That makes sense, this was fixed in a later version. You can work around by setting up the X matrix including the predictors that you want in the model, and without using the formula argument. So something along the lines of:
newX = data.frame(poly(X$glorys_sst, degree = 2, raw = TRUE), X$Area_swept_km2)
model <- gllvm(Y, X = newX, num.lv = 1, family="tweedie")
But please refrain from commenting on closed issues; start a new issue if you think you have found a bug, and a topic in the discussion forum otherwise.
An example is:
which gives as output:
Error in scale(fallen.leaves) : object 'fallen.leaves' not found
. Any function of predictors will do, e.g., the same happens withscale
.The formula argument for the latent variables does not have the same issue:
model <- gllvm(y = spider$abund, X = spider$x, lv.formula = ~log(soil.dry) + log1p(bare.sand) + log1p(fallen.leaves) + log1p(moss) + log1p(herb.layer) + log1p(reflection), num.RR = 2, family = "poisson")
works just fine.