[R] Predicition and CI for lognormal model

Chien-Pang Chin chienpang.c at gmail.com
Mon Oct 31 10:17:48 CET 2016


Hi, everyone

 

I have a model like.

 

cpue=catch*1000/Hook

glmmodel=glm(log(cpue)~yy+qq+cc+pp, family=gaussian)

 

and I want to estimate yy, qq, cc, pp effect and CI

 

A senior scientist suggested to use

        

        

        model <- cbind(yhat=predict.glm(glmmodel, se.fit=T), DATA)

yy_effect = with(model, tapply(fit, yy, mean))

yy_effect.se = with(model, tapply(se.fit, yy, mean))

STD_CPUE_yy = exp(yy_effect+yy_effect.se/2);

    

It's confusing me, because I don't understand 1). why calculate mean first
before exp, 2). why +se/2 and 3). How can I calculate CI for STD_CPUE_yy?

 

My previous code was.

 

        yhat = predict.glm(glmmodel, se.fit=T,interval = "predict")

pcpue =exp(yhat$fit)

   pcatch = pcpue*yftcpue$Hook/1000

model=cbind(yftcpue,pcatch,pcpue)

   

 #calculate mean predication for each yy

yypcatch= with(model, tapply(pcatch, yy, sum))

   yyhook= with(model, tapply(Hook, yy, sum))

    yypcatch/yyhook*1000

 

# calculate CI for each yy

        upp= model$fit+1.96*model$se.fit

        low= model$fit-1.96*model$se.fit

    

thanks for help

 

 


	[[alternative HTML version deleted]]



More information about the R-help mailing list