[R] Confidence Intervals on Standard Curve

Ben Ward benjamin.ward at bathspa.org
Sun Feb 20 19:27:50 CET 2011


It is, I tried a glm with a poisson distribution, as was suggested to me 
previously, but the Residual Deviance was too high - the book I'm 
reading says it suggests overdispersion because it's way above the 
Residual degrees of freedom:

glm(formula = Approximate.Counts ~ X..Light.Transmission, family = poisson,
     data = Standard)

Deviance Residuals:
    Min      1Q  Median      3Q     Max
-6.434  -2.822  -1.257   4.319   9.432

Coefficients:
                         Estimate Std. Error z value Pr(>|z|)
(Intercept)            7.7584256  0.0058981  1315.4 <2e-16 ***
X..Light.Transmission -0.0497474  0.0004951  -100.5 <2e-16 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

(Dispersion parameter for poisson family taken to be 1)

     Null deviance: 15709.90  on 39  degrees of freedom
Residual deviance:   671.91  on 38  degrees of freedom
AIC: 1030.7

Number of Fisher Scoring iterations: 4

It suggested using quasi-poisson but that didn't alter anything, so then 
used a negative binomial and gained the result:

glm.nb(formula = Approximate.Counts ~ X..Light.Transmission,
     data = Standard, init.theta = 67.14797983, link = log)

Deviance Residuals:
     Min       1Q   Median       3Q      Max
-1.5281  -0.9208  -0.1883   0.9685   2.0121

Coefficients:
                       Estimate Std. Error z value Pr(>|z|)
(Intercept)            7.69797    0.02819  273.11 <2e-16 ***
X..Light.Transmission -0.04410    0.00141  -31.26 <2e-16 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

(Dispersion parameter for Negative Binomial(67.148) family taken to be 1)

     Null deviance: 905.35  on 39  degrees of freedom
Residual deviance:  40.39  on 38  degrees of freedom
AIC: 517.21

Number of Fisher Scoring iterations: 1


               Theta:  67.1
           Std. Err.:  16.1

  2 x log-likelihood:  -511.21

Which shows a much lower Residual Deviance, and AIC. I plot it and It is 
also pretty good. I'm yet to assess it with plot(model). This is my 
first proper go with GLM so I'm not confident at evaluating them, 
although I am aware that a better model of the data has lower AIC, and 
Residual Deviance should not be orders above the degrees of freedom.

However, the

Y ~ X + Y^2

Produces the best fitting line - it is pretty much on the data points - 
I'm trying to make a standard curve, with which to take readings from a 
spectrophotometer off of. Rather than what I would normally use models 
for - such as hypothesis testing and analysis of data from experiments.

Thanks,
Ben.

On 20/02/2011 11:53, nzcoops wrote:
> model<- lm(Approximate.Counts~X..Light.Transmission +
> I(Approximate.Counts^2), data=Standards)
>
> Might not be addressing the problem, don't you have Y ~ X + Y^2 here? That's
> a violation of the assumptions of an lm isn't it?
>
> Also for plotting CI on a curve look into ggplot2::geom_ribbon, it's much
> nicer than just plotting lines and is easy to use. had.co.nz should set you
> right for setting this up.



More information about the R-help mailing list