I'll preface this by saying I'm primarily a SAS person (over R), but
I've been able to do this with "standard" analyses (e.g., lm or glm).
Basically, I want to pull a single number from the output, in this
case the p-value (yes, I know, "significance testing" is passe, but
some people still want it and at this point it's mostly curiosity...
and that nagging sense of "this just HAS to be possible...").
In an "ordinary" analysis, I can get things like that with the [$]
operator. Not so in S4 classes. I have figured out that [@] works
like [$] in S4 classes, but only sort of.
For the sake of illustration:
####################################################################
> fm <- occu(~HabType ~HabType, data=umf)
> summary(fm)
Call:
occu(formula = ~HabType ~ HabType, data = umf)
Occupancy (logit-scale):
Estimate SE z P(>|z|)
(Intercept) 0.245 0.248 0.988 0.323
HabType -0.489 0.351 -1.392 0.164
Detection (logit-scale):
Estimate SE z P(>|z|)
(Intercept) 2.30 0.334 6.90 5.28e-12
HabType 0.49 0.570 0.86 3.90e-01
AIC: 294.4622
Number of sites: 132
optim convergence code: 0
optim iterations: 18
Bootstrap iterations: 0
####################################################################
I want to extract the p-value for "HabType" in occupancy (0.164) and
store it as a variable.
I have tried using str(fm) and through that managed to get down to:
####################################################################
fmest <- fm@estimates
fmestst <- fmest@estimates$state
> fmestst@estimates
(Intercept) HabType
0.2453471 -0.4885544
####################################################################
fm@estimates@estimates$state@estimates did not work.
But I don't even see a "slot" for p-values
####################################################################
> str(fmestst)
Formal class 'unmarkedEstimate' [package "unmarked"] with 7 slots
..@ name : chr "Occupancy"
..@
short.name : chr "psi"
..@ estimates : Named num [1:2] 0.245 -0.489
.. ..- attr(*, "names")= chr [1:2] "(Intercept)" "HabType"
..@ covMat : num [1:2, 1:2] 0.0616 -0.0616 -0.0616 0.1232
..@ covMatBS : NULL
..@ invlink : chr "logistic"
..@ invlinkGrad: chr "logistic.grad"
####################################################################
Wondering if this was intentional (i.e., "we don't want you using p-
values") or if it's more about my ignorance of S4 classes.
Thanks for your time!
Shannon