# GlmSimulatoR v0.2.3

Monthly downloads

## Creates Ideal Data for Generalized Linear Models

Have you ever struggled to find "good data" for a generalized linear model? Would you like
to test how quickly statistics converge to parameters, or learn how picking different
link functions affects model performance? This package creates ideal data for both common
and novel generalized linear models so your questions can be empirically answered.

## Readme

# GlmSimulatoR

Often the first problem in understanding the generalized linear model in a practical way is finding good data. Common problems include finding data with a small number of rows, the response variable does not follow a family in the glm framework, or the data is messy and needs a lot of work before statistical analysis can begin. This package alleviates all of these by allowing you to create the data you want. With data in hand, you can empirically answer any question you have.

The goal of this package is to strike a balance between mathematical flexibility and simplicity of use. You can control the sample size, link function, number of unrelated variables, and ancillary parameter when applicable. Default values are carefully chosen so data can be generated without thinking about mathematical connections between weights, links, and distributions.

## Installation

You can install the released version of GlmSimulatoR from CRAN with:

```
install.packages("GlmSimulatoR")
```

And the development version from GitHub with:

```
# install.packages("devtools")
devtools::install_github("gmcmacran/GlmSimulatoR")
```

## Example 1: Create Textbook Data for Linear Model

```
library(GlmSimulatoR)
library(ggplot2)
set.seed(1)
simdata <- simulate_gaussian(N = 100, weights = 1, xrange = 10, ancillary = 1) #GlmSimulatoR function
ggplot(simdata, aes(x = X1, y = Y)) +
geom_point()
```

```
rm(simdata)
```

## Example 2: Do glm and lm Estimate The Same Weights?

```
library(GlmSimulatoR)
set.seed(2)
simdata <- simulate_gaussian() #GlmSimulatoR function
linearModel <- lm(Y ~ X1 + X2 + X3, data = simdata)
glmModel <- glm(Y ~ X1 + X2 + X3, data = simdata, family = gaussian(link = "identity"))
summary(linearModel)$coefficients
#> Estimate Std. Error t value Pr(>|t|)
#> (Intercept) 2.9121432 0.09159228 31.79464 2.042126e-211
#> X1 0.9821122 0.03471228 28.29294 1.784922e-169
#> X2 2.0393412 0.03456867 58.99392 0.000000e+00
#> X3 3.0431138 0.03487595 87.25536 0.000000e+00
summary(glmModel)$coefficients
#> Estimate Std. Error t value Pr(>|t|)
#> (Intercept) 2.9121432 0.09159228 31.79464 2.042126e-211
#> X1 0.9821122 0.03471228 28.29294 1.784922e-169
#> X2 2.0393412 0.03456867 58.99392 0.000000e+00
#> X3 3.0431138 0.03487595 87.25536 0.000000e+00
rm(linearModel, glmModel, simdata)
```

In the summary, the weights and standard errors are the same.

## See Vignettes For More Examples

## Functions in GlmSimulatoR

Name | Description | |

%>% | Pipe operator | |

GlmSimulatoR-package | GlmSimulatoR: Creates Ideal Data for Generalized Linear Models | |

simulate_gaussian | Create ideal data for a generalized linear model. | |

No Results! |

## Vignettes of GlmSimulatoR

Name | ||

count_data_and_overdispersion.Rmd | ||

dealing_with_right_skewed_data.Rmd | ||

exploring_links_for_the_gaussian_distribution.Rmd | ||

introduction.Rmd | ||

stepwise_search.Rmd | ||

tweedie_distribution.Rmd | ||

No Results! |

## Last month downloads

## Details

Type | Package |

License | GPL-3 |

Encoding | UTF-8 |

LazyData | true |

RoxygenNote | 6.1.1 |

VignetteBuilder | knitr |

NeedsCompilation | no |

Packaged | 2020-06-15 23:19:35 UTC; gmcma |

Repository | CRAN |

Date/Publication | 2020-06-16 10:50:02 UTC |

#### Include our badge in your README

```
[![Rdoc](http://www.rdocumentation.org/badges/version/GlmSimulatoR)](http://www.rdocumentation.org/packages/GlmSimulatoR)
```