It seems that whenever I use any of the rsq package functions (pcor for partial correlations; rsq and rsq.partial for R-squared) on a binomial glm which uses the two-column notation, I get an error - see below. The model actually is correct, fit goes perfectly, no data missing.
Is there something I can do about it?
Reproducible example:
require(rsq)
data(esoph)
model1 <- glm(cbind(ncases, ncontrols) ~ agegp + tobgp * alcgp,
data = esoph, family = binomial)
pcor(model1)
Error in cbind(ncases, ncontrols) : object 'ncases' not found
rsq(model1)
Error in cbind(ncases, ncontrols) : object 'ncases' not found
rsq.partial(model1)
Error in cbind(ncases, ncontrols) : object 'ncases' not found
You have to use attach(esoph) before applying the model. Like
data(esoph)
model1 <- glm(cbind(ncases, ncontrols) ~ agegp + tobgp * alcgp,
data = esoph, family = binomial)
attach(esoph)
pcor(model1)
# $adjustment
#[1] FALSE
#$variable
#[1] "agegp" "tobgp" "alcgp" "tobgp:alcgp"
#$partial.cor
#[1] 0.8092124 0.0000000 0.0000000 0.3815876
#Warning message:
#In (nLevels > 1) & (varcls == "factor") :
#longer object length is not a multiple of shorter object length
rsq(model1)
# [1] 0.826124
rsq.partial(model1)
#$adjustment
#[1] FALSE
#$variable
#[1] "agegp" "tobgp" "alcgp" "tobgp:alcgp"
#$partial.rsq
#[1] 6.548247e-01 -6.661338e-16 0.000000e+00 1.456091e-01
detach(esoph)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With