using linearComb for models with covariates, in order to backTransform

1,707 views
Skip to first unread message

PRadley

unread,
Jul 20, 2017, 6:24:02 AM7/20/17
to unmarked
Hello all,

I get the feeling this is probably pretty easy and straight forward.  But, I’m new to unmarked, and fairly new to R as well.  I’m analysing occupancy (occupancy and detection probability) for introduced rats on islands in an archipelago in the tropical Pacific using ‘occu’.  I have two replicates of 100 samples each, collected at 50 sample stations on tourist visited islands and 50 on non-tourist visited islands.  My covariate (‘siteCovs’) is thus “tourist”.  All went smoothly until I tried to backTransform occupancy (‘state’ variable) in my model with the covariate (as I’d read would happen).  However, I’m not entirely sure how to use the linearComb feature to produce as “scalar linear combination” that I can then backTransform.  Here is what it looks like (please forgive the sloppiness - I copied and pasted from history in R Studio):


Call:
occu(formula = ~1 ~ Tourist, data = umf)

Occupancy:
            Estimate     SE     z P(>|z|)
(Intercept)    0.984  0.344 2.863 0.00419
Tourist        9.640 41.505 0.232 0.81633

Detection:
 Estimate    SE    z  P(>|z|)
     1.41 0.207 6.85 7.56e-12

AIC: 226.0303 
> backTransform(fm2['det'])
Backtransformed linear combination(s) of Detection estimate(s)

 Estimate     SE LinComb (Intercept)
    0.804 0.0325    1.41           1

Transformation: logistic 
> backTransform(fm2['state'])
Error in .local(obj, ...) : 
  Cannot directly back-transform an unmarkedEstimate with length > 1.
Use linearComb() and then backTransform() the resulting scalar linear combination.



I tried to take a stab at this, based on material I had read and seen online, but I'm not sure this is correct:


> lcfm2 <- linearComb(fm2, c(1,1), type='state')
> lcfm2
Linear combination(s) of Occupancy estimate(s)

 Estimate   SE (Intercept) Tourist
     10.6 41.5           1       1

> backTransform(lcfm2)
Backtransformed linear combination(s) of Occupancy estimate(s)

 Estimate      SE LinComb (Intercept) Tourist
        1 0.00101    10.6           1       1

Transformation: logistic 


Am I close???  Thanks for any and all help, and your patience...


Paul Radley


Kery Marc

unread,
Jul 20, 2017, 6:34:32 AM7/20/17
to unma...@googlegroups.com
Hi Paul,

I think I would ALWAYS just use the predict function for prediction. In your case, do something analogous to the following (hab is a factor with three levels):

# Fit model p(time+wind), psi(hab)

summary(fm2.occ <- occu(~time+wind-1 ~hab, data=umf))

 

# Predict occupancy for habitat factor levels

newdat <- data.frame(hab = c("A", "B", "C"))

predict(fm2.occ, type="state", newdata = newdat, appendData = TRUE)


This gives this:
  Predicted         SE      lower     upper hab
1 0.1139666 0.07914607 0.02693418 0.3741059   A
2 0.6579139 0.15598369 0.33084338 0.8820925   B
3 0.7100853 0.13388848 0.40639000 0.8975695   C

Which is what you want.

Best regards  --- Marc





From: unma...@googlegroups.com [unma...@googlegroups.com] on behalf of PRadley [prati...@hotmail.com]
Sent: 20 July 2017 06:01
To: unmarked
Subject: [unmarked] using linearComb for models with covariates, in order to backTransform

--
You received this message because you are subscribed to the Google Groups "unmarked" group.
To unsubscribe from this group and stop receiving emails from it, send an email to unmarked+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

PRadley

unread,
Jul 20, 2017, 10:59:53 PM7/20/17
to unmarked
Thanks so much for the reply, Marc...

And that's good to hear, I'm headed in the correct direction.  Last night, well after I posted here, I came upon an overview of unmarked written by Fiske and Chandler and dated 14 May 2017.  I redid my analysis following that and it seems like it came out the way it should.  And your input here further confirms that.  The results look like this:


> newData <- data.frame(Tourist=0:1)
> round(predict(fm2, type='det', newdata=newData, appendData=TRUE), 2)
  Predicted   SE lower upper Tourist
1      0.52 0.05  0.41  0.62       0
2      0.89 0.03  0.80  0.94       1
> predict(fms, type='det', newdata=newData)
  Predicted         SE     lower     upper
1 0.5191853 0.05424816 0.4135946 0.6230897
2 0.8896665 0.03414701 0.8030614 0.9409851


And thanks again.  I'll have another question to post, about another data set, in the not too distant future...

Cheers,
Paul

Luís Santiago

unread,
Jan 10, 2022, 7:21:18 AM1/10/22
to unmarked
Hi Paul and Mark,

This post popped up when I was looking up for some information about the linearComb function and perhaps you could help me. I have been wondering what its useful for, given that I have seen examples where it is used and others where it isn't used. I haven't found much information online that enables me to understand it, to be honest. So, I was wondering if you could please explain its usefulness to me.

Thank you so much.
Regards,
Luís

Luís Santiago

unread,
Jan 10, 2022, 11:40:00 AM1/10/22
to unmarked

Actually, I have been looking further into it and I believe I might have found the answer to my question.
Say one is interested in modelling a species detection. If the detection is considered constant (~1), backTransformed is used. If, on the other hand, there are covariates associated with it, linearComb is used (  backTransform(linearComb(...)) ).
Am I thinking right?

Cheers,
Luís
Reply all
Reply to author
Forward
0 new messages