To fit a glm model in R, you can use the built-in glm() function. The basic syntax of glm() is:
27 chars2 lineswhere:
formula is a symbolic description of the model.family is a description of the error distribution and link function to be used in the model.data is the data set containing the variables used in the model.For example, to fit a linear regression model with normal errors, you could use:
58 chars2 linesThis model assumes a normal distribution of errors and uses the default identity link function.
You can also fit models with other error distributions and link functions, such as logistic regression or Poisson regression, by specifying the appropriate family argument.
160 chars3 linesOnce you have fitted the model, you can use the summary() function to obtain a summary of the model and the predict() function to obtain predicted values for new data.
gistlibby LogSnag