Skip to content
Back to formatted view

Raw Message

Message-ID: <a0468214-d301-fbef-6a02-0bb644b69c3a@gmail.com>
Date: 2019-05-21T15:32:20Z
From: Ben Bolker
Subject: predict function for a glmm
In-Reply-To: <AM0PR03MB4548027673D47D7AE3C46554C2070@AM0PR03MB4548.eurprd03.prod.outlook.com>

A few choices:

 if you use predict(..., type="response") you will get predicted
probabilities for each element.  You can use any of the standard methods
for scoring the accuracy of a binomial model (e.g. pick a cutoff value,
most typically 0.5, for making predictions and count the number of
correct/incorrect predictions, *or* use area under the curve).

 For example,

ModelMatrix::auc.default(response_var, predict(fit, type="response"))

ought to do the trick.


On 2019-05-21 9:13 a.m., Williamson, Michael via R-sig-mixed-models wrote:
> Good Afternoon,
> 
> I am running a GLMM model using the glmmTMB function. I've been told I should run the model on 80% of my data, then test the outputs on the remaining 20% using the predict function in order to test the robustness of the model. I have a binomial response variable (off shore = 1 not offshore =0) for the model.
> 
> My code is this:
> 
> OffMod_80 <- glmmTMB(offshore ~ sex + log(size) + species*daynight+ species*season +
>                     (1|code), family=binomial(), data=Off_80)
> 
> pred_Off20 <- as.data.frame(predict(OffMod_80, newdata = Off_20))
> 
> This spits out a table of values from the predict function.
> 
> My question is, considering my response variable is non-normal what method can I use to compare these predicted outputs with my observed values to test the robustness of the model? Is this even the correct way to go about things for this data and model type?
> 
> Any help appreciated.
> 
> Michael Williamson
> London NERC DTP Candidate
> 
> Email: michael.williamson at kcl.ac.uk<mailto:michael.williamson at kcl.ac.uk> Phone: +447764836592 Skype: mikejwilliamson Twitter: @mjw_marine
> 
> Most recent paper:
> Williamson, M. J., Tebbs, E., Dawson, T., Jacoby D. (2019) 'Satellite Remote Sensing in Shark and Ray Ecology, Conservation and Management', Frontiers in Marine Science, 6, 1-23. https://doi.org/10.3389/fmars.2019.00135<https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdoi.org%2F10.3389%2Ffmars.2019.00135&data=01%7C01%7Cmichael.williamson%40kcl.ac.uk%7Cebe89eb38f9f4638c3af08d6b381355f%7C8370cf1416f34c16b83c724071654356%7C0&sdata=RSgPw0Ar9R1JvA0YDYfJhDOdwUYfy7sh2vZs2t5tO94%3D&reserved=0>
> 
> 
> 
> 	[[alternative HTML version deleted]]
> 
> _______________________________________________
> R-sig-mixed-models at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>