Re: [R] How to specify a quadratic term in the contrast function

2025-02-18 Thread Kevin Thorpe
I don’t know if this will make a difference, but I believe it is generally preferred to use the poly() function (for lm()/glm()) or the pol() function (for rms functions) to include the quadratic (and higher order terms). Kevin > On Feb 18, 2025, at 12:23 PM, Ben Bolker wrote: > > Looking a

Re: [R] How to specify a quadratic term in the contrast function

2025-02-18 Thread Ben Bolker
Looking at the 'contrasts' function, it seems to be imported from 'rms' and to take only 'rms'-type fits (which are different from base-R [g]lm() fits) as input. I'm not sure exactly what contrasts you're trying to generate, but I would probably use the emmeans package for the task, since

[R] How to specify a quadratic term in the contrast function

2025-02-18 Thread Sorkin, John
I am using the contrast package to produce contrasts from a glm model that contains a quadratic term: fit0 <- glm(y ~ x + I(x*x),data=mydata) I would like to know how to specify the quadratic term, I(x*x), in the contrast function. When I try to use contrast(fit0,list(x=4)) I receive an error me