We use the following packages:
library(mice)
library(dplyr)
library(magrittr)
library(DAAG)
The following table shows numbers of occasions when inhibition (i.e., no flow of current across a membrane) occurred within 120 s, for different concentrations of the protein peptide-C. The outcome yes implies that inhibition has occurred.
conc 0.1 0.5 1 10 20 30 50 70 80 100 150
no 7 1 10 9 2 9 13 1 1 4 3
yes 0 0 3 4 0 6 7 0 0 1 7
Rno and yes over the rows (i.e. no + yes)yes over margin)margin as the weightsfitconc is somewhat skewed. Run the model again with a log-transformation for conc.log(conc).moths data frame in the DAAG package contains data from a study of the effect of habitat on the densities of two species of moth (A and P). The quasipoisson distribution is a reasonable model for these data. Try modeling the variable A using this distribution. Is there a better link function than the standard?n <- 1000
x <- runif(n)
sh <- 2
y <- rgamma(n,scale=log(2+3*x)/sh,shape=sh)
Specify the link function and run a glm regressing y on x. Hint: Look at the help file for family. You need to make an object of type “link-glm”, containing the items needed for glm to run: a link function, an inverse link, the derivative of the inverse link, and a function that describes the domain of the inverse link.
End of Practical